emacs-devel
[Top][All Lists]
Advanced

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

Re: Longlines mode in menu


From: Lennart Borgman (gmail)
Subject: Re: Longlines mode in menu
Date: Wed, 18 Jun 2008 23:17:01 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

David Reitter wrote:
On 18 Jun 2008, at 21:50, Lennart Borgman (gmail) wrote:
Could you show me exactly how and what you bind. I want to test and I had some trouble with bindings like this

   (define-key map [down] 'osxkeys-visual-line-down-in-buffers)


I'm binding this:

    (define-key map '[(up)] 'visual-line-up)
    (define-key map '[(down)] 'visual-line-down)

Thanks.

I'm actually binding this in my mode's "low priority keymap" so that other minor modes can override.
I use the code below.

That said, it should work from the normal minor mode keymap as well.

- D


(defun aquamacs-install-low-priority-global-key-map (keymap &optional target)
  "Install keys from keymap keymap into the target (or global) map."
  (let ((target (or target (current-global-map)))
    (overwritten (make-sparse-keymap)))
    (map-keymap
   (lambda (key command)
     (let ((old (lookup-key  target `[,key])))
       (if (keymapp command)  ; key is a prefix key
       (if (keymapp old)
           ;; recurse
           (setq old (aquamacs-install-low-priority-global-key-map
              command old)))
     (define-key target `[,key] command))
     ;; also save "nil" entries for unassigned keys
       (define-key overwritten `[,key] old)))
   keymap)
    overwritten))

Couldn't you just use a minor mode and put it last in minor-mode-map-alist? AFAICS new modes are entered first in that list by default.




reply via email to

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