help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: left brackets insert both


From: Shug Boabby
Subject: Re: left brackets insert both
Date: 25 Mar 2005 10:23:32 -0800
User-agent: G2/0.2

excellent rgb! i have kept your original function as it is nice anyway,
but modified it to this:

(defmacro my-bothbraces-if-double (new-txt)
  "If the last key is the same as this key, insert new-txt and go back
a char"
  `(lambda (cnt)
     (interactive "p")
     (if (equal (preceding-char) last-command-char)
         (progn
           (insert ,new-txt)
           (backward-char))
       (self-insert-command cnt))))
(global-set-key "\"" (my-bothbraces-if-double "\""))
(global-set-key "\'" (my-bothbraces-if-double "\'"))
(global-set-key "\{" (my-bothbraces-if-double "\}"))
(global-set-key "\[" (my-bothbraces-if-double "\]"))
(global-set-key "\(" (my-bothbraces-if-double "\)"))
(global-set-key "\<" (my-bothbraces-if-double "\>"))

i hope it helps others!



reply via email to

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