diff options
Diffstat (limited to 'lisp/mouse.el')
| -rw-r--r-- | lisp/mouse.el | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 46dd0397d7f..502683d3d1e 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -298,9 +298,10 @@ and should return the same menu with changes such as added new menu items." | |||
| 298 | (function-item context-menu-buffers) | 298 | (function-item context-menu-buffers) |
| 299 | (function-item context-menu-vc) | 299 | (function-item context-menu-vc) |
| 300 | (function-item context-menu-ffap) | 300 | (function-item context-menu-ffap) |
| 301 | (function-item Man-context-menu) | ||
| 302 | (function-item hi-lock-context-menu) | 301 | (function-item hi-lock-context-menu) |
| 303 | (function-item context-menu-online-search) | 302 | (function-item occur-context-menu) |
| 303 | (function-item Man-context-menu) | ||
| 304 | (function-item dictionary-context-menu) | ||
| 304 | (function :tag "Custom function"))) | 305 | (function :tag "Custom function"))) |
| 305 | :version "28.1") | 306 | :version "28.1") |
| 306 | 307 | ||
| @@ -323,6 +324,8 @@ the function `context-menu-filter-function'." | |||
| 323 | (fun (mouse-posn-property (event-start click) | 324 | (fun (mouse-posn-property (event-start click) |
| 324 | 'context-menu-function))) | 325 | 'context-menu-function))) |
| 325 | 326 | ||
| 327 | (select-window (posn-window (event-start click))) | ||
| 328 | |||
| 326 | (if (functionp fun) | 329 | (if (functionp fun) |
| 327 | (setq menu (funcall fun menu click)) | 330 | (setq menu (funcall fun menu click)) |
| 328 | (run-hook-wrapped 'context-menu-functions | 331 | (run-hook-wrapped 'context-menu-functions |
| @@ -534,16 +537,6 @@ Some context functions add menu items below the separator." | |||
| 534 | :help "Find file or URL from text around mouse click")))) | 537 | :help "Find file or URL from text around mouse click")))) |
| 535 | menu) | 538 | menu) |
| 536 | 539 | ||
| 537 | (defun context-menu-online-search (menu click) | ||
| 538 | "Populate MENU with command to search online." | ||
| 539 | (save-excursion | ||
| 540 | (mouse-set-point click) | ||
| 541 | (define-key-after menu [online-search-separator] menu-bar-separator) | ||
| 542 | (define-key-after menu [online-search-at-mouse] | ||
| 543 | '(menu-item "Online search" mouse-online-search-at-point | ||
| 544 | :help "Search for region or word online"))) | ||
| 545 | menu) | ||
| 546 | |||
| 547 | (defvar context-menu-entry | 540 | (defvar context-menu-entry |
| 548 | `(menu-item ,(purecopy "Context Menu") ,(make-sparse-keymap) | 541 | `(menu-item ,(purecopy "Context Menu") ,(make-sparse-keymap) |
| 549 | :filter ,(lambda (_) (context-menu-map))) | 542 | :filter ,(lambda (_) (context-menu-map))) |
| @@ -3230,26 +3223,6 @@ is copied instead of being cut." | |||
| 3230 | (with-current-buffer (window-buffer window) | 3223 | (with-current-buffer (window-buffer window) |
| 3231 | (setq cursor-type (nth 3 state))))))) | 3224 | (setq cursor-type (nth 3 state))))))) |
| 3232 | 3225 | ||
| 3233 | (defvar eww-search-prefix) | ||
| 3234 | (defun mouse-online-search-at-point (event) | ||
| 3235 | "Query an online search engine at EVENT. | ||
| 3236 | If a region is active, the entire region will be sent, otherwise | ||
| 3237 | the symbol at point will be used. This command uses EWW's | ||
| 3238 | default search engine, as configured by `eww-search-prefix'." | ||
| 3239 | (interactive "e") | ||
| 3240 | (require 'eww) | ||
| 3241 | (let ((query (if (use-region-p) | ||
| 3242 | (buffer-substring (region-beginning) | ||
| 3243 | (region-end)) | ||
| 3244 | (save-excursion | ||
| 3245 | (mouse-set-point event) | ||
| 3246 | (thing-at-point 'symbol))))) | ||
| 3247 | (unless query | ||
| 3248 | (user-error "Nothing to search for")) | ||
| 3249 | (browse-url (concat | ||
| 3250 | eww-search-prefix | ||
| 3251 | (mapconcat #'url-hexify-string (split-string query) "+"))))) | ||
| 3252 | |||
| 3253 | 3226 | ||
| 3254 | ;;; Bindings for mouse commands. | 3227 | ;;; Bindings for mouse commands. |
| 3255 | 3228 | ||