emacs-devel
[Top][All Lists]
Advanced

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

Re: New global bindings


From: Paul R
Subject: Re: New global bindings
Date: Tue, 03 Jun 2008 19:35:38 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Point nb 1 is easy to fix, maybe I can live with nb 3, but nb 2 seems to
> be more problematic.  So I think we need to find some other key-bindings
> for that.  I think a prefix key followed by +, -, and = (repeatable like
> C-x e e e e e, maybe even allowing switching between + and -) is the
> best choice.

It is one more case where I think emacs should provide a binding of
the form C-x C-+ + + + + ...

'+' would mean "repeat last command" as long as no other key is hit.
Additionnaly, we could declare "-" as a valid candidate.
Why not :

(global-set-key-autorepeat '("\C-x\C-" . ("+" . zoom-in)
                                         ("-" . zoom-out)))

to allow auto-repeat on + and - after either C-x C-- or C-x C-+. 

I'd be happy if emacs could provide a primitive for this. It could
display a transient helper in the echo area to remind what keys are
temporary bound to special functions.

Currently, I use the following code :

;;;; 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, for example :

(global-set-key "\C-xmn" (lambda () (interactive) (auto-repeat-command 
'marker-visit-next)))

This is clearly not optimal, but it works and I have not looked for a
cleaner implementation, yet.

This type of binding is ideal for any command that :
 - is not very often called
 - when called, will probably be called several time in a row
They are a lot of places where such default behaviour would provide
intuitive and non-intrusive bindings.

What do you think ?

-- 
      Paul




reply via email to

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