Skip to content

Commit 390f030

Browse files
authored
Merge pull request #6 from zonuexe/feature/click-menu
Add right-click-context-click-menu for mouse click event
2 parents ad0fd66 + 8b85363 commit 390f030

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

right-click-context.el

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@
6969
:group 'right-click-context
7070
:type 'string)
7171

72+
(defcustom right-click-context-mouse-set-point-before-open-menu 'not-region
73+
"Control the position of the mouse pointer before opening the menu."
74+
:group 'right-click-context
75+
:type '(choice (const :tag "When not Region activated" 'not-region)
76+
(const :tag "Always set cursor to mouse pointer" 'always)
77+
(const :tag "Not set cursor to mouse pointer" nil)))
78+
7279
(defvar right-click-context-mode-map
7380
(let ((map (make-sparse-keymap)))
74-
(define-key map (kbd "<mouse-3>") #'right-click-context-menu)
81+
(define-key map (kbd "<mouse-3>") #'right-click-context-click-menu)
7582
map)
7683
"Keymap used in right-click-context-mode.")
7784

@@ -190,11 +197,20 @@ You probably want to just add follows code to your .emacs file (init.el).
190197
right-click-context-mode-map
191198
:group 'right-click-context)
192199

200+
;;;###autoload
201+
(defun right-click-context-click-menu (event)
202+
"Open Right Click Context menu by Mouse Click `EVENT'."
203+
(interactive "e")
204+
(when (or (eq right-click-context-mouse-set-point-before-open-menu 'always)
205+
(and (null mark-active)
206+
(eq right-click-context-mouse-set-point-before-open-menu 'not-region)))
207+
(call-interactively #'mouse-set-point))
208+
(right-click-context-menu))
209+
193210
;;;###autoload
194211
(defun right-click-context-menu ()
195212
"Open Right Click Context menu."
196213
(interactive)
197-
(call-interactively #'mouse-set-point)
198214
(let ((value (popup-cascade-menu (right-click-context--build-menu-for-popup-el (right-click-context--menu-tree) nil))))
199215
(when value
200216
(if (symbolp value)

0 commit comments

Comments
 (0)