[Openmcl-devel] Swapping round and square brackets in Hemlock

John DeSoi desoi at pgedit.com
Wed Feb 10 20:14:26 PST 2010


On Feb 9, 2010, at 10:27 AM, varoun p wrote:

> I have the following in .emacs that does this :
> 
> (keyboard-translate ?\( ?\[)
> (keyboard-translate ?\[ ?\()
> (keyboard-translate ?\) ?\])
> (keyboard-translate ?\] ?\))
> 
> What is the equivalent for hemlock ?
> thanks in advance,


This is what I did. I'm new to CCL and Hemlock, so there might be something easier/better.



(defmacro key-alias (char binding &optional mode)
  (let ((name (format nil "Key Alias ~a" char))
        (docs (format nil "Command to customize binding for character: ~a" char))
        (mode-for (when mode (list :mode mode))))
  `(progn
     (hi:defcommand ,name (p)
       ,docs ,docs ;second string is function docs
       (setq p (or p 1))
       (let* ((point (hemlock::current-point-for-insertion)))
         (dotimes (i p)
           (hi:insert-character point ,char))))
     (hi:bind-key ,name ,binding , at mode-for))))


(key-alias #\( #k"[" "Lisp")
(key-alias #\) #k"]" "Lisp")
(key-alias #\[ #k"control-[" "Lisp")
(key-alias #\] #k"control-]" "Lisp")





John DeSoi, Ph.D.







More information about the Openmcl-devel mailing list