* Changes to make the C-x @ commands work with function keys
@ 2002-02-12 1:38 Al Petrofsky
2002-02-12 8:44 ` Eli Zaretskii
2002-02-13 15:39 ` Richard Stallman
0 siblings, 2 replies; 6+ messages in thread
From: Al Petrofsky @ 2002-02-12 1:38 UTC (permalink / raw)
Below are some changes that make the C-x @ commands work with function
keys. This also makes them work with each other, i.e. C-x @ c C-x @ m
% will run query-replace-regexp. These aren't very convenient to
type, but if you can program your tty to send these C-x @ sequences
for you, then all the M-home, M-end, C-next, etc.. keybindings will be
conveniently available.
I simplified (and pessimized) the event-apply-modifier function,
rather than try to fix the bugs it had when mixing modifiers (e.g.,
adding control to M-a and adding meta to C-a returned different
results.)
-al
(defun read-function-mapped-event ()
"Read an event or function key.
Like `read-event', but input is first translated according to
`function-key-map' and `key-translation-map', so that a function key
event may be composed."
(let ((event (read-event)))
(if (consp event)
;; Don't touch mouse events.
event
;; Otherwise, block out the maps that are used after
;; key-translation-map, and call read-key-sequence.
(push event unread-command-events)
(let ((overriding-local-map (make-sparse-keymap))
(global (current-global-map)))
(unwind-protect
(progn (use-global-map (make-sparse-keymap))
(let ((vec (read-key-sequence-vector nil)))
(if (> (length vec) 1)
(setq unread-command-events
(cdr (append vec unread-command-events))))
(aref vec 0)))
(use-global-map global))))))
;; These functions -- which are not commands -- each add one modifier
;; to the following event.
(defun event-apply-alt-modifier (ignore-prompt)
"Add the Alt modifier to the following event.
For example, type \\[event-apply-alt-modifier] & to enter Alt-&."
`[,(event-apply-modifier (read-function-mapped-event) 'alt)])
(defun event-apply-super-modifier (ignore-prompt)
"Add the Super modifier to the following event.
For example, type \\[event-apply-super-modifier] & to enter Super-&."
`[,(event-apply-modifier (read-function-mapped-event) 'super)])
(defun event-apply-hyper-modifier (ignore-prompt)
"Add the Hyper modifier to the following event.
For example, type \\[event-apply-hyper-modifier] & to enter Hyper-&."
`[,(event-apply-modifier (read-function-mapped-event) 'hyper)])
(defun event-apply-shift-modifier (ignore-prompt)
"Add the Shift modifier to the following event.
For example, type \\[event-apply-shift-modifier] & to enter Shift-&."
`[,(event-apply-modifier (read-function-mapped-event) 'shift)])
(defun event-apply-control-modifier (ignore-prompt)
"Add the Control modifier to the following event.
For example, type \\[event-apply-control-modifier] & to enter Control-&."
`[,(event-apply-modifier (read-function-mapped-event) 'control)])
(defun event-apply-meta-modifier (ignore-prompt)
"Add the Meta modifier to the following event.
For example, type \\[event-apply-meta-modifier] & to enter Meta-&."
`[,(event-apply-modifier (read-function-mapped-event) 'meta)])
(defun event-apply-modifier (event modifier)
"Apply a modifier flag to event EVENT.
MODIFIER is the name of the modifier, as a symbol."
(let ((modified (event-convert-list `(,modifier
,@(delq 'click (event-modifiers event))
,(event-basic-type event)))))
(if (consp event)
(cons modified (cdr event))
modified)))
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Changes to make the C-x @ commands work with function keys
2002-02-12 1:38 Changes to make the C-x @ commands work with function keys Al Petrofsky
@ 2002-02-12 8:44 ` Eli Zaretskii
2002-02-12 16:40 ` Stefan Monnier
2002-02-12 17:56 ` Al Petrofsky
2002-02-13 15:39 ` Richard Stallman
1 sibling, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2002-02-12 8:44 UTC (permalink / raw)
Cc: emacs-devel
On Mon, 11 Feb 2002, Al Petrofsky wrote:
> Below are some changes that make the C-x @ commands work with function
> keys.
Sorry, I don't understand: this seems to work already. For example,
"C-x @ c <right>" invokes <C-right>. What am i missing?
(Btw, I always wondered how can this be useful for the Ctrl modifier,
since "C-x" requires Ctrl at least with `x'. Is there an assumption
that the user can arrange for some key to generate "C-x", but cannot
use Ctrl otherwise?)
> This also makes them work with each other, i.e. C-x @ c C-x @ m
> % will run query-replace-regexp.
I think this is a useful addition; it seems inconsistent that "C-x @"
doesn't allow to mix modifiers.
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Changes to make the C-x @ commands work with function keys
2002-02-12 8:44 ` Eli Zaretskii
@ 2002-02-12 16:40 ` Stefan Monnier
2002-02-12 17:56 ` Al Petrofsky
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2002-02-12 16:40 UTC (permalink / raw)
Cc: Al Petrofsky, emacs-devel
>
> On Mon, 11 Feb 2002, Al Petrofsky wrote:
>
> > Below are some changes that make the C-x @ commands work with function
> > keys.
>
> Sorry, I don't understand: this seems to work already. For example,
> "C-x @ c <right>" invokes <C-right>. What am i missing?
Pressing `Control' and `Home' might send the same sequence as just pressing
`Home', depending on the terminal emulator. In such a case
C-x @ c <home> allows you to run the command bound to <C-home>.
Whether the C-home binding is important enough to care, I don't know.
Stefan
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Changes to make the C-x @ commands work with function keys
2002-02-12 8:44 ` Eli Zaretskii
2002-02-12 16:40 ` Stefan Monnier
@ 2002-02-12 17:56 ` Al Petrofsky
2002-02-13 6:11 ` Eli Zaretskii
1 sibling, 1 reply; 6+ messages in thread
From: Al Petrofsky @ 2002-02-12 17:56 UTC (permalink / raw)
Cc: emacs-devel
> From: Eli Zaretskii <eliz@is.elta.co.il>
> On Mon, 11 Feb 2002, Al Petrofsky wrote:
>
> > Below are some changes that make the C-x @ commands work with function
> > keys.
>
> Sorry, I don't understand: this seems to work already. For example,
> "C-x @ c <right>" invokes <C-right>. What am i missing?
You must be running on a window system, where pressing right generates
a single <right> event. On a tty, pressing right generates something
like ESC O C. In 21.1, the C-x @ sequences modify just the single
event that follows (i.e. ESC), rather than modifying the translated
event that would follow after function-key-map processing.
> (Btw, I always wondered how can this be useful for the Ctrl modifier,
> since "C-x" requires Ctrl at least with `x'. Is there an assumption
> that the user can arrange for some key to generate "C-x", but cannot
> use Ctrl otherwise?)
Yes. An uncustomized tty will generate C-x when you type C-x, but
will not generate C-right when you type C-right. Termcap/terminfo
don't even provide a way to state what the byte sequence for C-right
would be. With the changes I proposed, the user can at least make a
private arrangement between his tty and emacs.
-al
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Changes to make the C-x @ commands work with function keys
2002-02-12 1:38 Changes to make the C-x @ commands work with function keys Al Petrofsky
2002-02-12 8:44 ` Eli Zaretskii
@ 2002-02-13 15:39 ` Richard Stallman
1 sibling, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2002-02-13 15:39 UTC (permalink / raw)
Cc: emacs-devel
It looks like a good idea to me. It is large enough to need legal
papers.
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-02-13 15:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-12 1:38 Changes to make the C-x @ commands work with function keys Al Petrofsky
2002-02-12 8:44 ` Eli Zaretskii
2002-02-12 16:40 ` Stefan Monnier
2002-02-12 17:56 ` Al Petrofsky
2002-02-13 6:11 ` Eli Zaretskii
2002-02-13 15:39 ` 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).