diff options
author | Juri Linkov <juri@linkov.net> | 2021-07-21 23:34:59 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-07-21 23:34:59 +0300 |
commit | ebac285d0ee567ed86e14b871cf0bac2de8655db (patch) | |
tree | 7544b94da3c0b02f1ac1b0e1bd357b09423f54d3 /lisp/net/eww.el | |
parent | 1493145e3048e057d8ac9e8c9c56d1f99a97eb53 (diff) | |
download | emacs-ebac285d0ee567ed86e14b871cf0bac2de8655db.tar.gz emacs-ebac285d0ee567ed86e14b871cf0bac2de8655db.tar.bz2 emacs-ebac285d0ee567ed86e14b871cf0bac2de8655db.zip |
Improve docstring of context-menu-functions and add eww-context-menu
* lisp/mouse.el (context-menu-functions): Explain function args in docstring.
* lisp/net/eww.el (eww-context-menu): New function.
(eww-mode): Add it to context-menu-functions.
* lisp/info.el (Info-context-menu): Move history items higher.
* lisp/progmodes/prog-mode.el (prog-context-menu): Add menu items
in the middle of the menu after the region menu items.
Diffstat (limited to 'lisp/net/eww.el')
-rw-r--r-- | lisp/net/eww.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index eec3ec7ba8b..b8761029864 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1021,6 +1021,36 @@ the like." ["Toggle Paragraph Direction" eww-toggle-paragraph-direction])) map)) +(defun eww-context-menu (menu) + (define-key menu [eww-separator-2] menu-bar-separator) + (let ((easy-menu (make-sparse-keymap "Eww"))) + (easy-menu-define nil easy-menu nil + '("Eww" + ["Back to previous page" eww-back-url + :visible (not (zerop (length eww-history)))] + ["Forward to next page" eww-forward-url + :visible (not (zerop eww-history-position))] + ["Reload" eww-reload t])) + (dolist (item (reverse (lookup-key easy-menu [menu-bar eww]))) + (when (consp item) + (define-key menu (vector (car item)) (cdr item))))) + + (when (or (mouse-posn-property (event-start last-input-event) 'shr-url) + (mouse-posn-property (event-start last-input-event) 'image-url)) + (define-key menu [shr-mouse-browse-url-new-window] + `(menu-item "Follow URL in new window" ,(if browse-url-new-window-flag + 'shr-mouse-browse-url + 'shr-mouse-browse-url-new-window) + :help "Browse the URL under the mouse cursor in a new window")) + (define-key menu [shr-mouse-browse-url] + `(menu-item "Follow URL" ,(if browse-url-new-window-flag + 'shr-mouse-browse-url-new-window + 'shr-mouse-browse-url) + :help "Browse the URL under the mouse cursor"))) + (define-key menu [eww-separator-1] menu-bar-separator) + + menu) + (defvar eww-tool-bar-map (let ((map (make-sparse-keymap))) (dolist (tool-bar-item @@ -1044,6 +1074,7 @@ the like." (setq-local eww-data (list :title "")) (setq-local browse-url-browser-function #'eww-browse-url) (add-hook 'after-change-functions #'eww-process-text-input nil t) + (add-hook 'context-menu-functions 'eww-context-menu 5 t) (setq-local eww-history nil) (setq-local eww-history-position 0) (when (boundp 'tool-bar-map) |