emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5477070 3/3: Add a command line (and MIME handler) function to st


From: Lars Ingebrigtsen
Subject: master 5477070 3/3: Add a command line (and MIME handler) function to start eww
Date: Sun, 9 Aug 2020 07:05:48 -0400 (EDT)

branch: master
commit 54770707ad7bbb6ef9ad636ee71e08bea5347715
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a command line (and MIME handler) function to start eww
    
    * lisp/net/eww.el (eww-browse): New command (bug#42768) to be used
    from the command line.
    
    * doc/misc/eww.texi (Command Line): Document it.
---
 doc/misc/eww.texi | 16 ++++++++++++++++
 etc/NEWS          |  6 ++++++
 lisp/net/eww.el   | 18 ++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index f9901b6..85be112 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -52,6 +52,7 @@ modify this GNU manual.''
 * Overview::
 * Basics::
 * Advanced::
+* Command Line::
 
 Appendices
 * History and Acknowledgments::
@@ -337,6 +338,21 @@ thus allowing for the use of the usual substitutions, such 
as
 @code{\[eww-reload]} for the current key binding of the
 @code{eww-reload} command.
 
+@node Command Line
+@chapter Command Line Usage
+
+It can be convenient to start eww directly from the command line.  The
+@code{eww-browse} function can be used for that:
+
+@example
+emacs -f eww-browse https://gnu.org
+@end example
+
+This also allows registering Emacs as a @acronym{MIME} handler for the
+@samp{"text/x-uri"} media type.  How to do that varies between
+systems, but typically you'd register the handler to call @samp{"emacs
+-f eww-browse %u"}.
+
 @node History and Acknowledgments
 @appendix History and Acknowledgments
 
diff --git a/etc/NEWS b/etc/NEWS
index 2f204a5..9dffd0f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -604,6 +604,12 @@ mode buffer.
 ** EWW
 
 +++
+*** New Emacs command line convenience function.
+The 'eww-browse' command has been added, which allows you to register
+Emacs as a MIME handler for "text/x-uri", and will call eww on the
+supplied URL.  Usage example: emacs -f eww-browse https://gnu.org
+
++++
 *** 'eww-download-directory' will now use the XDG location, if defined.
 However, if "~/Downloads/" already exists, that will continue to be
 used.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index edb2f72..e7170b3 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -277,6 +277,24 @@ This list can be customized via `eww-suggest-uris'."
     (nreverse uris)))
 
 ;;;###autoload
+(defun eww-browse ()
+  "Function to be run to parse command line URLs.
+This is meant to be used for MIME handlers or command line use.
+
+Setting the handler for \"text/x-uri;\" to
+\"emacs -f eww-browse %u\" will then start up Emacs and call eww
+to browse the url.
+
+This can also be used on the command line directly:
+
+ emacs -f eww-browse https://gnu.org
+
+will start Emacs and browse the GNU web site."
+  (interactive)
+  (eww (pop command-line-args-left)))
+
+
+;;;###autoload
 (defun eww (url &optional arg buffer)
   "Fetch URL and render the page.
 If the input doesn't look like an URL or a domain name, the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]