* Re: `special' keys in keyboard macros [not found] <16257.16532.727889.658851@tfkp07.physik.uni-erlangen.de> @ 2003-10-11 5:37 ` Richard Stallman 2003-10-14 21:21 ` Stefan Monnier 0 siblings, 1 reply; 7+ messages in thread From: Richard Stallman @ 2003-10-11 5:37 UTC (permalink / raw) Cc: emacs-devel When emacs runs in its own X window [for short: "emacs (X)"] I get the keyboard macro ;; "emacs (X)" (fset 'foo [return left right up down insert delete backspace]) On the other hand "emacs -nw" gives me for the same key sequence ;; "emacs -nw" (fset 'bar "\C-m\C-[OD\C-[OC\C-[OA\C-[OB\C-[[2~\C-[[3~\C-?") The problem is: "emacs -nw" cannot make use of the keyboard macro foo and "emacs (X)" cannot make use of the macro bar either. The cause of this problem is obvious; what's amazing is that I never thought of it until you pointed it out. It seems that a solution might be to do the processing through function-key-map before recording keys in the keyboard macro. I looked at the code, and this is not trivial, so I won't try to write it now. I think it would take a bit of hard debugging to make this work right in all cases. Basically, you'd need to make read_key_sequence remove, from the keyboard macro being defined, the characters it reads, and then record the translated versions of them. To be entirely correct, the characters you record should not have been translated through key-translation-map, only through function-key-map. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-11 5:37 ` `special' keys in keyboard macros Richard Stallman @ 2003-10-14 21:21 ` Stefan Monnier 2003-10-15 20:00 ` Richard Stallman 0 siblings, 1 reply; 7+ messages in thread From: Stefan Monnier @ 2003-10-14 21:21 UTC (permalink / raw) Cc: emacs-devel, Roland Winkler > To be entirely correct, the characters you record should not have been > translated through key-translation-map, only through function-key-map. It is not possible to do this 100% correctly. Maybe we can record the pre-processed keys and temporarily bind function-key-map and key-translation-map to nil while executing a macro, but that seems risky as well. Another possibility is to record commands names instead of keys. All in all, it seems that a "quick" 90% solution might be the best available option. Stefan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-14 21:21 ` Stefan Monnier @ 2003-10-15 20:00 ` Richard Stallman 2003-10-15 21:27 ` Kim F. Storm 0 siblings, 1 reply; 7+ messages in thread From: Richard Stallman @ 2003-10-15 20:00 UTC (permalink / raw) Cc: emacs-devel, Roland.Winkler Maybe we can record the pre-processed keys and temporarily bind function-key-map and key-translation-map to nil while executing a macro, but that seems risky as well. You are right that we would want to turn off processing of function-key-map when replaying a macro, if it records the results of function-key-map translation. key-translation-map is a different story entirely. It should be handled as now: processed when executing the macro. Another possibility is to record commands names instead of keys. That is possible, but I tend to think it is the wrong approach. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-15 20:00 ` Richard Stallman @ 2003-10-15 21:27 ` Kim F. Storm 2003-10-16 10:18 ` Roland Winkler 0 siblings, 1 reply; 7+ messages in thread From: Kim F. Storm @ 2003-10-15 21:27 UTC (permalink / raw) Cc: Roland.Winkler, Stefan Monnier, emacs-devel Richard Stallman <rms@gnu.org> writes: > Another possibility is to record commands names instead of keys. > > That is possible, but I tend to think it is the wrong approach. I agree. For example, it is not sufficient to record just commands names for commands like self-insert-command and digit-argument which make no sense "out of context". -- Kim F. Storm <storm@cua.dk> http://www.cua.dk ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-15 21:27 ` Kim F. Storm @ 2003-10-16 10:18 ` Roland Winkler 2003-10-16 12:36 ` Robert J. Chassell 2003-10-16 23:07 ` Richard Stallman 0 siblings, 2 replies; 7+ messages in thread From: Roland Winkler @ 2003-10-16 10:18 UTC (permalink / raw) Cc: emacs-devel, rms, Stefan Monnier On Oct 15 2003 Kim F. Storm wrote: > Richard Stallman <rms@gnu.org> writes: > > > Another possibility is to record commands names instead of keys. > > > > That is possible, but I tend to think it is the wrong approach. > > I agree. > > For example, it is not sufficient to record just commands names for > commands like self-insert-command and digit-argument which make no > sense "out of context". I think it would be neat to have some better support for converting "dirty", quickly hacked keyboard macros into "clean" elisp commands. The command edit-kbd-macro gives some idea how the keys are translated into commands. But for more complex keyboard macros (such as those using recursive edit during execution of the macro) it will be rather tricky to provide an automated mechanism for converting keyboard macros into elisp commands. Up to now, I do not even have an idea what kind of new features might be useful to support such a conversion. In any case, it appears to me that this is a rather different issue than what I addressed in the bug report. Roland ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-16 10:18 ` Roland Winkler @ 2003-10-16 12:36 ` Robert J. Chassell 2003-10-16 23:07 ` Richard Stallman 1 sibling, 0 replies; 7+ messages in thread From: Robert J. Chassell @ 2003-10-16 12:36 UTC (permalink / raw) Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> wrote I think it would be neat to have some better support for converting "dirty", quickly hacked keyboard macros into "clean" elisp commands. A decade or more ago, David Gillespie included a function that converted key strokes to Emacs Lisp in his Emacs Calc mode. Instead of running `kmacro-start-macro/ kmacro-start-macro' and end up with a keyboard macro, you would run this function the same way (possibly bound to the same keys) and end up with an Emacs Lisp defun. Unfortunately, I cannot find the feature any more. It is not in any recent version of Calc, nor any other place I have looked. Nor can I remember what it is called, except that I think it had `edit' in its name. Someone with more access to old Emacs Lisp libraries might find it. Or maybe it is hidden in the current Emacs Calc code and I just have not seen it. As with the RMIME libraries I mentioned earlier, this code is not likely to come with proper papers (although it was, if I remember rightly, part of Calc mode -- so maybe it does have papers). In any case, the defuns produced were not the best; and would need enhancement to emulate the current `kmacro-start-macro/ kmacro-start-macro' tools. But you should be able to look at the code and run the function as it is, and see what it does -- it could be a help. -- Robert J. Chassell Rattlesnake Enterprises http://www.rattlesnake.com GnuPG Key ID: 004B4AC8 http://www.teak.cc bob@rattlesnake.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: `special' keys in keyboard macros 2003-10-16 10:18 ` Roland Winkler 2003-10-16 12:36 ` Robert J. Chassell @ 2003-10-16 23:07 ` Richard Stallman 1 sibling, 0 replies; 7+ messages in thread From: Richard Stallman @ 2003-10-16 23:07 UTC (permalink / raw) Cc: emacs-devel, monnier, storm I think it would be neat to have some better support for converting "dirty", quickly hacked keyboard macros into "clean" elisp commands. The command edit-kbd-macro gives some idea how the keys are translated into commands. But for more complex keyboard macros (such as those using recursive edit during execution of the macro) it will be rather tricky to provide an automated mechanism for converting keyboard macros into elisp commands. It is a reasonable feature to add, and in fact Multics Emacs had such a feature. However, I think that many of the features in etc/TODO are more important than this. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-10-16 23:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <16257.16532.727889.658851@tfkp07.physik.uni-erlangen.de> 2003-10-11 5:37 ` `special' keys in keyboard macros Richard Stallman 2003-10-14 21:21 ` Stefan Monnier 2003-10-15 20:00 ` Richard Stallman 2003-10-15 21:27 ` Kim F. Storm 2003-10-16 10:18 ` Roland Winkler 2003-10-16 12:36 ` Robert J. Chassell 2003-10-16 23:07 ` Richard Stallman
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).