emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch: enhanced mark navigation commands


From: paul r
Subject: Re: Patch: enhanced mark navigation commands
Date: Wed, 5 Mar 2008 13:23:11 +0100

> GIven that M-n and M-p are widely used bindings, I don't think you'll
> win many fans by adding global bindings for them, unless the new
> bindings clearly don't conflict or interact in strange ways with other
> uses.


M-n and M-p are also usefull and intuitive as forward-paragraph and
backward-paragraph.

I take this opportunity to propose something. It is clear that we all
must make choices on how to bind quick shortcuts. Usually, one wants a
simple and quick shortcut for operations (s)he does a lot. Of course,
if Adrian wants to jump 4 marks backward, he does not want to type,
for instance, C-x M-m p ( which would mean command - mark - previous )
4 times.
Given they are good chances that he would hit the keybinding 4 times
in a row, without doing any other operation in the middle, one could
take advantage of this special pattern, by letting him hit only 'p' as
long as he wants to keep jumping. This is exactly the behaviour of C-x
e and I find it very cleaver. Loop breaks when any other key it hit.
AFAIK, there is no common practice to make this kind of keybinding, at
least yet. That's why I use the following few lines that are rather
ugly but work well :

;;;; Auto-repeat any command by pressing last shortcut key
(defun auto-repeat-command (command)
 (let ((repeat-repeat-char
        (when (eq last-command-char
                  last-command-event)
          last-command-char)))
   (call-interactively command)
   (while (eq (read-event) repeat-repeat-char)
     ;; Make each repetition undo separately.
     (auto-repeat-command command)
     (setq unread-command-events (list last-input-event)))))


Then, mark jumping can be bound this way :

(global-set-key "\C-x\M-mn" (lambda () (interactive)
                            (auto-repeat-command 'marker-visit-next)))
(global-set-key "\C-x\M-mp" (lambda () (interactive)
                            (auto-repeat-command 'marker-visit-prev)))


Please understand I'm not proposing any particular implementation, but
only something I consider as a desirable behaviour that could be
encouraged when bindings functions that are likely to be called
several times in a row.
Hoping I was clear and used not-too-bad english,

-- paul




reply via email to

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