auto-complete / popup-el

Visual Popup Interface Library for Emacs
GNU General Public License v3.0
445 stars 96 forks source link

Any way to intercept C-g #118

Closed super-tomcat closed 3 years ago

super-tomcat commented 3 years ago

Hi, is there anyway to intercept the user pressing C-g when they cancel the popup menu, so that i can take some action before my program ends?

It seems to me that when using popup-menu* it just cancels without informing the calling program.

thanks

jcs090218 commented 3 years ago

Hi, is there anyway to intercept the user pressing C-g when they cancel the popup menu, so that i can take some action before my program ends?

Hi, I don't want do you mean here. Do you mean that you want to do some execution before the popup menu ends? 😕

super-tomcat commented 3 years ago

Hi, is there anyway to intercept the user pressing C-g when they cancel the popup menu, so that i can take some action before my program ends?

Hi, I don't want do you mean here. Do you mean that you want to do some execution before the popup menu ends? 😕

Yes, i need to set some variables back before quitting.

jcs090218 commented 3 years ago

I think you can add advice after popup-delete function? Not sure if this will work.

(advice-add 'popup-delete :after (lambda (popup) (message "do somthing"))
super-tomcat commented 3 years ago

I think you can add advice after popup-delete function? Not sure if this will work.

(advice-add 'popup-delete :after (lambda (popup) (message "do somthing"))

I couldnt get that to work, i am using... popup-menu not popup-create.... would that work for popup-menu ??

super-tomcat commented 3 years ago

I found a way using (inhibit-quit t) with:

(unless (with-local-quit
                  (progn

etc

After user presses C-g i can then intercept, do what i need and set Quit flag to t with (setq quit-flag t)

jcs090218 commented 3 years ago

Glad you figure it out yourself! ;)

Close this now!