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

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

Re: Keymap priorities - how do define a global, low-priority binding fro


From: david . reitter
Subject: Re: Keymap priorities - how do define a global, low-priority binding from a minor mode?
Date: 12 Apr 2006 01:54:54 -0700
User-agent: G2/0.2

Stefan,
Thanks, I'll put together a suggestion at some point - but probably
after the release.

>> Is using the global key map from a global minor mode a clean solution??
>It's not great, but it's the best we have.

For the record, here's an alternative, certainly somewhat ugly. The
`down' key is bound to the below function, which then looks up what the
binding would be if the global minor mode was switched off.
This stops short of advising `next-line' (which would affect a lot of
code). Modifying the global map would have been the alternative, but I
didn't do it because people using my mode like to override its key map
in their .emacs, and they couldn't do that if I hardcoded additional
bindings to be set when the mode is switched on and off.

(defun osxkeys-visual-line-down-in-buffers ()
"Moves the cursor down one (visual) line.
If the `down' key would normally be bound to something else than
`next-line' (as it is the case in minibuffers), the other binding
is called."
  (interactive)
  (let* (osx-key-mode  ;; turn off mode temporarily
         (binding (key-binding [down])))
    (if (eq binding 'next-line)
        (call-interactively (function visual-line-down))
      (call-interactively binding))))

;; mark functions for CUA
(dolist (cmd
         '( beginning-of-visual-line
            end-of-visual-line
            visual-line-down visual-line-up
            osxkeys-visual-line-up-in-buffers
            osxkeys-visual-line-down-in-buffers))
  (put cmd 'CUA 'move))



reply via email to

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