diff options
| author | Eli Zaretskii | 2023-01-14 11:48:55 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2023-01-14 11:48:55 +0200 |
| commit | 9a1dbb7f088c95a46a3be6334572ebece83d2dde (patch) | |
| tree | 5a71a1d46f8c598ffe3826f9eff333dfe73c428f | |
| parent | ac2a6fc83fac6390892b068a830ebe0f22364e05 (diff) | |
| download | emacs-9a1dbb7f088c95a46a3be6334572ebece83d2dde.tar.gz emacs-9a1dbb7f088c95a46a3be6334572ebece83d2dde.zip | |
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.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 9 | ||||
| -rw-r--r-- | lisp/net/eww.el | 11 |
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 | |||
| 92 | either prefix the file name with @code{file://} or use the command | 92 | either prefix the file name with @code{file://} or use the command |
| 93 | @kbd{M-x eww-open-file}. | 93 | @kbd{M-x eww-open-file}. |
| 94 | 94 | ||
| 95 | If you invoke @code{eww} with a prefix argument, as in @w{@kbd{C-u | 95 | If you invoke @code{eww} or @code{eww-open-file} with a prefix |
| 96 | M-x eww}}, it will create a new EWW buffer instead of reusing the | 96 | argument, as in @w{@kbd{C-u M-x eww}}, they will create a new EWW |
| 97 | default one, which is normally called @file{*eww*}. | 97 | buffer instead of reusing the default one, which is normally called |
| 98 | @file{*eww*}. | ||
| 98 | 99 | ||
| 99 | @findex eww-quit | 100 | @findex eww-quit |
| 100 | @findex eww-reload | 101 | @findex eww-reload |
| @@ -147,6 +147,15 @@ point is not in a comment or a string. It is by default bound to | |||
| 147 | *** New connection method "toolbox". | 147 | *** New connection method "toolbox". |
| 148 | This allow accessing system containers provided by Toolbox. | 148 | This allow accessing system containers provided by Toolbox. |
| 149 | 149 | ||
| 150 | ** EWW | ||
| 151 | |||
| 152 | +++ | ||
| 153 | *** 'eww-open-file' can now display the file in a new buffer. | ||
| 154 | By default, the command reuses the '*eww*' buffer, but if called with | ||
| 155 | the new argument non-nil, it will use a new buffer instead. | ||
| 156 | Interactively, invoke 'eww-open-file' with a prefix argument to | ||
| 157 | activate this behavior. | ||
| 158 | |||
| 150 | 159 | ||
| 151 | * New Modes and Packages in Emacs 30.1 | 160 | * New Modes and Packages in Emacs 30.1 |
| 152 | 161 | ||
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'." | |||
| 488 | ;;;###autoload (defalias 'browse-web 'eww) | 488 | ;;;###autoload (defalias 'browse-web 'eww) |
| 489 | 489 | ||
| 490 | ;;;###autoload | 490 | ;;;###autoload |
| 491 | (defun eww-open-file (file) | 491 | (defun eww-open-file (file &optional new-buffer) |
| 492 | "Render FILE using EWW." | 492 | "Render FILE using EWW. |
| 493 | (interactive "fFile: ") | 493 | If NEW-BUFFER is non-nil (interactively, the prefix arg), use a |
| 494 | new buffer instead of reusing the default EWW buffer." | ||
| 495 | (interactive "fFile: \nP") | ||
| 494 | (let ((url-allow-non-local-files t)) | 496 | (let ((url-allow-non-local-files t)) |
| 495 | (eww (concat "file://" | 497 | (eww (concat "file://" |
| 496 | (and (memq system-type '(windows-nt ms-dos)) | 498 | (and (memq system-type '(windows-nt ms-dos)) |
| 497 | "/") | 499 | "/") |
| 498 | (expand-file-name file))))) | 500 | (expand-file-name file)) |
| 501 | new-buffer))) | ||
| 499 | 502 | ||
| 500 | (defun eww--file-buffer (file) | 503 | (defun eww--file-buffer (file) |
| 501 | (with-current-buffer (generate-new-buffer " *eww file*") | 504 | (with-current-buffer (generate-new-buffer " *eww file*") |