emacs-devel
[Top][All Lists]
Advanced

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

Re: Function to insert a key sequence


From: Jeff Kowalczyk
Subject: Re: Function to insert a key sequence
Date: Sat, 26 Dec 2009 22:14:18 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Deniz Dogan <deniz.a.m.dogan <at> gmail.com> writes:
> Attached is a little function for inserting a key sequence entered by
> the user into the current buffer. I don't know if it fits into any
> existing Emacs library, but I find it quite useful, so I thought I'd
> just throw it out there.

Deniz,

Thanks, this function is interesting. It could be useful in tools like
ScreencastMode [1].

Is this version intended for use with Emacs 23? I had to change read-key to
read-key-sequence to get the prompt, but the function does not exit on C-g:


(defun insert-key-sequence ()
  "Reads a sequence of keys until C-g is hit, and inserts the
prettified key sequence with C-g excluded."
  (interactive)
  (let ((result "")
        key)
    (while (progn
             (setq key (read-key-sequence "Enter the key sequence: "))
             (unless (eq 7 key)
               (setq result (concat result (key-description (list key)) " ")))
             (not (eq 7 key))))
    (when (not (string= result ""))
      (insert result)
      (backward-delete-char 1))))


Thanks,
Jeff

[1] http://www.emacswiki.org/emacs/ScreencastMode





reply via email to

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