help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

endless loop when redefining keys


From: Peter
Subject: endless loop when redefining keys
Date: Tue, 17 Oct 2023 17:55:18 +0200

In my first approach to set keys (a few years ago) I had this
for my <I'm already gone> function:

(fset 'save-and-exit
   "^U^X^C")
(global-unset-key (kbd "<f10>"))
(global-set-key (kbd "<f10>") 'save-and-exit)

Now I found that this does apparently not run my own (newly written)
kill-buffer-hook functions, or at least doesn't ask their questions.
So for a quick fix I removed the ^U from that code.

And now I have an endless loop and need to kill emacs from unix.
(Only when there is a modified buffer it should save)

I know that the 'fset' is now superfluous, and that I could just
bind <f10> to 'save-buffers-kill-emacs'. I kept it this way for now
only for documentation.
But then, why does it loop in this way? It is not from my macros -
I removed these for test.

To reproduce:

 - have a clean install
 - enter this into default.el:

(fset 'save-and-exit
   "^X^C")
(global-set-key (kbd "<f10>") 'save-and-exit)

 - run "emacs Testfile" and modify the Testfile
 - press <f10>


When pressing ^U^X^C the Testfile is just saved unconditionally - as
expected.
When pressing ^X^C, there is a prompt to save Testfile.
When clicking menu-File-Quit, there is a popup NOT asking for individual
buffers, but for all of them at once.
When closing the window from WM, the same popup.
But when pressing <f10> it computes forever.
~~~~~~~~~~~~~~~~~~~

Aapparently there are side-effects with defining keys, which I do not
yet understand and which can lead to unexpected looping.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]