diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-06-03 02:56:40 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-06-03 03:03:38 +0200 |
| commit | 669e7f4e62084967a11ab4d9d9dec41f385a636c (patch) | |
| tree | 6a7e8d4e5e87d415ba6822a69ac7c4f118cdeb72 | |
| parent | 2941f2ea36d61c1a84c3f79ebe47d604c9a92b5d (diff) | |
Add embark-context-menu
(context-menu-mode 1)
(add-hook 'context-menu-functions #'embark-context-menu 100)
| -rw-r--r-- | CHANGELOG.org | 6 | ||||
| -rw-r--r-- | README.org | 4 | ||||
| -rw-r--r-- | embark.el | 28 | ||||
| -rw-r--r-- | embark.texi | 4 |
4 files changed, 42 insertions, 0 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index 058be1c..dac0d45 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -1,5 +1,11 @@ #+title: Embark changelog +* Development +- =embark-target-buffer-at-point=: New target finder for buffers at point in + Ibuffer or Buffer-menu. +- =embark-context-menu=: Bew function which can be added to + =context-menu-functions=. The mouse context menu is activated via + =context-menu-mode=. * Version 1.1 (2024-04-18) - The =embark-consult= package contains a new exporter for =consult-location= targets (produced by several =consult= commands such @@ -375,6 +375,10 @@ starting configuration: ;; (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) + ;; Add Embark to the mouse context menu. Also enable `context-menu-mode'. + ;; (context-menu-mode 1) + ;; (add-hook 'context-menu-functions #'embark-context-menu 100) + :config ;; Hide the mode line of the Embark live/completions buffers @@ -1139,6 +1139,34 @@ added to `eldoc-documentation-functions'." targets ", "))))) +;;;###autoload +(defun embark-context-menu (menu event) + "Add Embark menu items to context MENU at the position of mouse EVENT." + (when-let (((not (minibufferp))) + (target (save-excursion + (mouse-set-point event) + (car (embark--targets))))) + (let* ((type (plist-get target :type)) + (target (embark--truncate-target (plist-get target :target))) + (action (embark--default-action type))) + (define-key menu [embark-act] + `( menu-item "Embark Act" + ,(lambda () + (interactive) + (mouse-set-point event) + (embark-act)) + :help ,(format "Act on %s ‘%s’" type target))) + (when (and action (symbolp action)) + (define-key menu [embark-dwim] + `( menu-item "Embark DWIM" + ,(lambda () + (interactive) + (mouse-set-point event) + (embark-dwim)) + :help ,(format "Run ‘%s’ on %s ‘%s’" + action type target)))))) + menu) + (defun embark--format-targets (target shadowed-targets rep) "Return a formatted string indicating the TARGET of an action. diff --git a/embark.texi b/embark.texi index a07b49f..e970e77 100644 --- a/embark.texi +++ b/embark.texi @@ -500,6 +500,10 @@ starting configuration: ;; (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) + ;; Add Embark to the mouse context menu. Also enable `context-menu-mode'. + ;; (context-menu 1) + ;; (add-hook 'context-menu-functions #'embark-context-menu 100) + :config ;; Hide the mode line of the Embark live/completions buffers |
