unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Al Petrofsky <al@petrofsky.org>
Subject: Changes to make the C-x @ commands work with function keys
Date: Mon, 11 Feb 2002 17:38:08 -0800	[thread overview]
Message-ID: <200202120138.RAA07371@radish.petrofsky.org> (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


             reply	other threads:[~2002-02-12  1:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-12  1:38 Al Petrofsky [this message]
2002-02-12  8:44 ` Changes to make the C-x @ commands work with function keys 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200202120138.RAA07371@radish.petrofsky.org \
    --to=al@petrofsky.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).