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

Fixed #7, Right click regenerate the menu at the new location. #8

Merged
merged 2 commits into from
May 28, 2019
Merged

Conversation

jcs090218
Copy link
Contributor

@zonuexe I'm assure that you would have a better solution than mine, but I would still like to give it a try. :D

(if (symbolp value)
(call-interactively value t)
(eval value))))
(setq popup-menu-keymap ori-popup-menu-keymap)))
Copy link
Contributor Author

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.

(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)
Copy link
Contributor Author

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.

Copy link
Owner

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)))
Copy link
Contributor Author

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.

Copy link
Contributor Author

@jcs090218 jcs090218 left a 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.

(if (symbolp value)
(call-interactively value t)
(eval value)))))
(let ((ori-popup-menu-keymap (copy-sequence popup-menu-keymap)))
Copy link
Owner

@zonuexe zonuexe May 27, 2019

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.

Copy link
Contributor Author

@jcs090218 jcs090218 May 28, 2019

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

(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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

@@ -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 ()
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! Renamed!

@zonuexe
Copy link
Owner

zonuexe commented May 27, 2019

@jcs090218 Great job!
I have confirmed that this change works well.
I can wait until tomorrow, merge this and then fix minor points.

@jcs090218
Copy link
Contributor Author

I just fixed all issues you pointed out! :D Feel free to point out more!

@zonuexe
Copy link
Owner

zonuexe commented May 28, 2019

@jcs090218 Awesome! LGTM

@zonuexe zonuexe merged commit 6e4fb8d into zonuexe:master May 28, 2019
@zonuexe
Copy link
Owner

zonuexe commented May 28, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants