-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fixed #7, Right click regenerate the menu at the new location. #8
Conversation
right-click-context.el
Outdated
(if (symbolp value) | ||
(call-interactively value t) | ||
(eval value)))) | ||
(setq popup-menu-keymap ori-popup-menu-keymap))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert popup-menu-keymap
here.
right-click-context.el
Outdated
(call-interactively value t) | ||
(eval value))))) | ||
(let ((ori-popup-menu-keymap (copy-sequence popup-menu-keymap))) | ||
(define-key popup-menu-keymap [mouse-3] #'right-click-context-click-menu-popup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bind mouse-3
for generating new menu at new cursor location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
(interactive) | ||
(when (memq this-command '(right-click-context-click-menu)) | ||
(popup-delete (nth (1- (length popup-instances)) popup-instances)) | ||
(call-interactively #'right-click-context-click-menu))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kill the current popup
and generate the menu at the new location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are few descriptions for what I changed.
right-click-context.el
Outdated
(if (symbolp value) | ||
(call-interactively value t) | ||
(eval value))))) | ||
(let ((ori-popup-menu-keymap (copy-sequence popup-menu-keymap))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ori-
prefix is not required. There is no need to back up the original values. Because Emacs Lisp is dynamic scope, the value bound by the variable in let is valid only in that let expression.
diff --git a/right-click-context.el b/right-click-context.el
index d30c8c8..05401af 100644
--- a/right-click-context.el
+++ b/right-click-context.el
@@ -219,14 +219,13 @@ You probably want to just add follows code to your .emacs file (init.el).
(defun right-click-context-menu ()
"Open Right Click Context menu."
(interactive)
- (let ((ori-popup-menu-keymap (copy-sequence popup-menu-keymap)))
+ (let ((popup-menu-keymap (copy-sequence popup-menu-keymap)))
(define-key popup-menu-keymap [mouse-3] #'right-click-context-click-menu-popup)
(let ((value (popup-cascade-menu (right-click-context--build-menu-for-popup-el (right-click-context--menu-tree) nil))))
(when value
(if (symbolp value)
(call-interactively value t)
- (eval value))))
- (setq popup-menu-keymap ori-popup-menu-keymap)))
+ (eval value))))))
You can evaluate popup-menu-keymap
to ensure that the original keymap is uncontaminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! This is definitely good to know! :D
right-click-context.el
Outdated
(call-interactively value t) | ||
(eval value))))) | ||
(let ((ori-popup-menu-keymap (copy-sequence popup-menu-keymap))) | ||
(define-key popup-menu-keymap [mouse-3] #'right-click-context-click-menu-popup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
right-click-context.el
Outdated
@@ -207,15 +207,26 @@ You probably want to just add follows code to your .emacs file (init.el). | |||
(call-interactively #'mouse-set-point)) | |||
(right-click-context-menu)) | |||
|
|||
;;;###autoload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this line is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
right-click-context.el
Outdated
@@ -207,15 +207,26 @@ You probably want to just add follows code to your .emacs file (init.el). | |||
(call-interactively #'mouse-set-point)) | |||
(right-click-context-menu)) | |||
|
|||
;;;###autoload | |||
(defun right-click-context-click-menu-popup () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command is probably not a command for the end user to execute explicitly. Can you change the name of this command to right-click-context--click-menu-popup
as private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely! Renamed!
@jcs090218 Great job! |
I just fixed all issues you pointed out! :D Feel free to point out more! |
@jcs090218 Awesome! LGTM |
Thank you! |
@zonuexe I'm assure that you would have a better solution than mine, but I would still like to give it a try. :D