Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add right-click-context-click-menu for mouse click event #6

Merged
merged 1 commit into from
May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions right-click-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@
:group 'right-click-context
:type 'string)

(defcustom right-click-context-mouse-set-point-before-open-menu 'not-region
"Control the position of the mouse pointer before opening the menu."
:group 'right-click-context
:type '(choice (const :tag "When not Region activated" 'not-region)
(const :tag "Always set cursor to mouse pointer" 'always)
(const :tag "Not set cursor to mouse pointer" nil)))

(defvar right-click-context-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<mouse-3>") #'right-click-context-menu)
(define-key map (kbd "<mouse-3>") #'right-click-context-click-menu)
map)
"Keymap used in right-click-context-mode.")

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

;;;###autoload
(defun right-click-context-click-menu (event)
"Open Right Click Context menu by Mouse Click `EVENT'."
(interactive "e")
(when (or (eq right-click-context-mouse-set-point-before-open-menu 'always)
(and (null mark-active)
(eq right-click-context-mouse-set-point-before-open-menu 'not-region)))
(call-interactively #'mouse-set-point))
(right-click-context-menu))

;;;###autoload
(defun right-click-context-menu ()
"Open Right Click Context menu."
(interactive)
(call-interactively #'mouse-set-point)
(let ((value (popup-cascade-menu (right-click-context--build-menu-for-popup-el (right-click-context--menu-tree) nil))))
(when value
(if (symbolp value)
Expand Down