From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: Al Petrofsky Newsgroups: gmane.emacs.devel Subject: Changes to make the C-x @ commands work with function keys Date: Mon, 11 Feb 2002 17:38:08 -0800 Message-ID: <200202120138.RAA07371@radish.petrofsky.org> NNTP-Posting-Host: quimby2.netfonds.no X-Trace: quimby2.netfonds.no 1013478615 8875 195.204.10.66 (12 Feb 2002 01:50:15 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 12 Feb 2002 01:50:15 GMT Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16aS5G-0002J3-00 for ; Tue, 12 Feb 2002 02:50:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16aRuW-0005TB-00; Mon, 11 Feb 2002 20:39:08 -0500 Original-Received: from radish.petrofsky.org ([216.240.48.33]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16aRtc-0005SA-00 for ; Mon, 11 Feb 2002 20:38:13 -0500 Original-Received: (from al@localhost) by radish.petrofsky.org (8.9.3/8.9.3/Debian 8.9.3-21) id RAA07371; Mon, 11 Feb 2002 17:38:08 -0800 Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1018 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1018 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