summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2023-01-14 11:48:55 +0200
committerEli Zaretskii <eliz@gnu.org>2023-01-14 11:48:55 +0200
commit9a1dbb7f088c95a46a3be6334572ebece83d2dde (patch)
tree5a71a1d46f8c598ffe3826f9eff333dfe73c428f
parentac2a6fc83fac6390892b068a830ebe0f22364e05 (diff)
downloademacs-9a1dbb7f088c95a46a3be6334572ebece83d2dde.tar.gz
Teach 'eww-open-file' about prefix argument
* lisp/net/eww.el (eww-open-file): Accept a new optional argument NEW-BUFFER to show FILE in a new buffer. (Bug#60809) * etc/NEWS: * doc/misc/eww.texi (Basics): Document the new feature.
-rw-r--r--doc/misc/eww.texi7
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/net/eww.el11
3 files changed, 20 insertions, 7 deletions
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index bc556ed88e2..836eb38503e 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -92,9 +92,10 @@ searched via @code{eww-search-prefix}. The default search engine is
either prefix the file name with @code{file://} or use the command
@kbd{M-x eww-open-file}.
- If you invoke @code{eww} with a prefix argument, as in @w{@kbd{C-u
-M-x eww}}, it will create a new EWW buffer instead of reusing the
-default one, which is normally called @file{*eww*}.
+ If you invoke @code{eww} or @code{eww-open-file} with a prefix
+argument, as in @w{@kbd{C-u M-x eww}}, they will create a new EWW
+buffer instead of reusing the default one, which is normally called
+@file{*eww*}.
@findex eww-quit
@findex eww-reload
diff --git a/etc/NEWS b/etc/NEWS
index 90a6c6a0522..cb83ec24a61 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -147,6 +147,15 @@ point is not in a comment or a string. It is by default bound to
*** New connection method "toolbox".
This allow accessing system containers provided by Toolbox.
+** EWW
+
++++
+*** 'eww-open-file' can now display the file in a new buffer.
+By default, the command reuses the '*eww*' buffer, but if called with
+the new argument non-nil, it will use a new buffer instead.
+Interactively, invoke 'eww-open-file' with a prefix argument to
+activate this behavior.
+
* New Modes and Packages in Emacs 30.1
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 763b2f07a5c..73d11c0ef52 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -488,14 +488,17 @@ For more information, see Info node `(eww) Top'."
;;;###autoload (defalias 'browse-web 'eww)
;;;###autoload
-(defun eww-open-file (file)
- "Render FILE using EWW."
- (interactive "fFile: ")
+(defun eww-open-file (file &optional new-buffer)
+ "Render FILE using EWW.
+If NEW-BUFFER is non-nil (interactively, the prefix arg), use a
+new buffer instead of reusing the default EWW buffer."
+ (interactive "fFile: \nP")
(let ((url-allow-non-local-files t))
(eww (concat "file://"
(and (memq system-type '(windows-nt ms-dos))
"/")
- (expand-file-name file)))))
+ (expand-file-name file))
+ new-buffer)))
(defun eww--file-buffer (file)
(with-current-buffer (generate-new-buffer " *eww file*")