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: Fri, 20 Jun 2008 20:50:15 +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

Stefan Monnier wrote:
Thanks. What key bindings do you suggest? Maybe this could be
a minor mode?

It should be either a global minor mode which adds `remap' bindings to
the global map, or a buffer-local minor mode which adds the same remap
bindings but via a minor-mode map.


Maybe something like this? I think it is essential to be able to use the original move and kill commands too.

  (defalias 'original-next-line 'next-line "test")
  (defalias 'original-previous-line 'previous-line "test")
  (defalias 'original-kill-line 'kill-line "test")

  (defvar visual-line-map
    (let ((map (make-sparse-keymap)))
      (define-key map [remap next-line] 'visual-line-down)
      (define-key map [remap previous-line] 'visual-line-up)
      (define-key map [(control down)] 'original-next-line)
      (define-key map [(control up)] 'original-previous-line)
      (define-key map [remap kill-line] 'kill-visual-line)
      (define-key map [(control shift ?k)] 'original-kill-line)
      (define-key map [remap kill-whole-line] 'kill-whole-visual-line)
      map))

  (define-minor-mode visual-line-mode
    "Define key binding for visual line moves etc."
    :lighter " vl"
    :global t
    :keymap visual-line-map
    :group 'convenience)





reply via email to

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