[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 2a1d5eb8f6 4/6: Add code to integrate menu with
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 2a1d5eb8f6 4/6: Add code to integrate menu with context-menu-mode |
Date: |
Fri, 31 Mar 2023 12:57:39 -0400 (EDT) |
branch: externals/denote
commit 2a1d5eb8f668724e5b37e085e64ff00d44f3eb1a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add code to integrate menu with context-menu-mode
Enable it with:
(add-hook 'context-menu-functions #'denote-context-menu)
Read what I published about the menu:
<https://protesilaos.com/codelog/2023-03-31-emacs-denote-menu/>.
---
denote.el | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/denote.el b/denote.el
index 530b9178f4..c0954419c5 100644
--- a/denote.el
+++ b/denote.el
@@ -3224,8 +3224,7 @@ This command is meant to be used from a Dired buffer."
;;;;; Define menu
-(easy-menu-define denote-global-menu global-map
- "Menu with all Denote commands, each available in the right context."
+(defvar denote--menu-contents
'("Denote"
["Create a note" denote
:help "Create a new note in the `denote-directory'"]
@@ -3268,7 +3267,23 @@ This command is meant to be used from a Dired buffer."
:help "Apply colors to Denote file name components in Dired"
:enable (derived-mode-p 'dired-mode)
:style toggle
- :selected (bound-and-true-p denote-dired-mode)]))
+ :selected (bound-and-true-p denote-dired-mode)])
+ "Contents of the Denote menu.")
+
+(easy-menu-define denote-global-menu global-map
+ "Menu with all Denote commands, each available in the right context."
+ denote--menu-contents)
+
+(defun denote-context-menu (menu _click)
+ "Populate MENU with Denote commands at CLICK."
+ (define-key menu [denote-separator] menu-bar-separator)
+ (let ((easy-menu (make-sparse-keymap "Denote")))
+ (easy-menu-define nil easy-menu nil
+ denote--menu-contents)
+ (dolist (item (reverse (lookup-key easy-menu [menu-bar])))
+ (when (consp item)
+ (define-key menu (vector (car item)) (cdr item)))))
+ menu)
;;;;; Register `denote:' custom Org hyperlink
- [elpa] externals/denote updated (d76bebd71e -> b755832873), ELPA Syncer, 2023/03/31
- [elpa] externals/denote b755832873 6/6: Add links to video demo of Denote, ELPA Syncer, 2023/03/31
- [elpa] externals/denote a4c06fcede 3/6: Fix symbol name in denote-link-or-create docstring, ELPA Syncer, 2023/03/31
- [elpa] externals/denote 2a1d5eb8f6 4/6: Add code to integrate menu with context-menu-mode,
ELPA Syncer <=
- [elpa] externals/denote bd4ac5d806 1/6: Ensure that 'denote-file-prompt' uses its own history, ELPA Syncer, 2023/03/31
- [elpa] externals/denote 64bc2823d2 2/6: Fix symbol name in denote-open-or-create docstring, ELPA Syncer, 2023/03/31
- [elpa] externals/denote ecccc046be 5/6: Document integration with context-menu-mode (also see 2a1d5eb), ELPA Syncer, 2023/03/31