* 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.
(defun dired-context-menu (menu)
(when (mouse-posn-property (event-start last-input-event) 'dired-filename)
- (define-key menu [dired-separator-1] menu-bar-separator)
+ (define-key menu [dired-separator-2] menu-bar-separator)
(let ((easy-menu (make-sparse-keymap "Immediate")))
(easy-menu-define nil easy-menu nil
'("Immediate"
(dolist (item (reverse (lookup-key easy-menu [menu-bar immediate])))
(when (consp item)
(define-key menu (vector (car item)) (cdr item)))))
- (define-key menu [dired-separator-2] menu-bar-separator))
+ (define-key menu [dired-separator-1] menu-bar-separator))
menu)
\f
["Exit" quit-window :help "Stop reading Info"]))
(defun Info-context-menu (menu)
- (when (mouse-posn-property (event-start last-input-event) 'mouse-face)
- (define-key menu [Info-separator-link-1] menu-bar-separator)
- (define-key menu [Info-mouse-follow-nearest-node]
- '(menu-item "Follow Link" Info-mouse-follow-nearest-node
- :help "Follow a link where you click"))
- (define-key menu [Info-separator-link-2] menu-bar-separator))
-
- (define-key-after menu [Info-separator-1] menu-bar-separator)
+ (define-key menu [Info-separator-2] menu-bar-separator)
(let ((easy-menu (make-sparse-keymap "Info")))
(easy-menu-define nil easy-menu nil
'("Info"
:help "Go back in history to the last node you were at"]
["Forward in History" Info-history-forward :visible Info-history-forward
:help "Go forward in history"]))
- (dolist (item (lookup-key easy-menu [menu-bar info]))
+ (dolist (item (reverse (lookup-key easy-menu [menu-bar info])))
(when (consp item)
- (define-key-after menu (vector (car item)) (cdr item)))))
- (define-key-after menu [Info-separator-2] menu-bar-separator)
+ (define-key menu (vector (car item)) (cdr item)))))
+
+ (when (mouse-posn-property (event-start last-input-event) 'mouse-face)
+ (define-key menu [Info-mouse-follow-nearest-node]
+ '(menu-item "Follow Link" Info-mouse-follow-nearest-node
+ :help "Follow a link where you click")))
+ (define-key menu [Info-separator-1] menu-bar-separator)
menu)
context-menu-region
context-menu-local
context-menu-minor)
- "List of functions that produce the contents of the context menu."
+ "List of functions that produce the contents of the context menu.
+Each function receives the menu as its argument and should return
+the same menu with changes such as added new menu items."
:type 'hook
:options '(context-menu-undo
context-menu-region
["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
(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)
(defun goto-address-context-menu (menu)
(when (mouse-posn-property (event-start last-input-event) 'goto-address)
- (define-key menu [goto-address-separator] menu-bar-separator)
+ (define-key menu [goto-address-separator-2] menu-bar-separator)
(define-key menu [goto-address-at-mouse]
'(menu-item "Follow Link" goto-address-at-mouse
- :help "Follow a link where you click")))
+ :help "Follow a link where you click"))
+ (define-key menu [goto-address-separator-1] menu-bar-separator))
menu)
(defcustom goto-address-url-face 'link
(defun prog-context-menu (menu)
(when (featurep 'xref)
- (define-key-after menu [prog-separator-1] menu-bar-separator)
+ (define-key-after menu [prog-separator-1] menu-bar-separator
+ 'separator-region-2)
(define-key-after menu [xref-find-def]
'(menu-item "Find Definition" xref-find-definitions-at-mouse
:visible (save-excursion
(mouse-set-point last-input-event)
(xref-backend-identifier-at-point (xref-find-backend)))
- :help "Find definition of function or variable"))
+ :help "Find definition of function or variable")
+ 'prog-separator-1)
(define-key-after menu [xref-pop]
'(menu-item "Back Definition" xref-pop-marker-stack
:visible (not (xref-marker-stack-empty-p))
- :help "Back to the position of the last search"))
- (define-key-after menu [prog-separator-2] menu-bar-separator))
+ :help "Back to the position of the last search")
+ 'xref-find-def)
+ (define-key-after menu [prog-separator-2] menu-bar-separator
+ 'xref-pop))
menu)
(defvar prog-mode-map