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

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

Re: repeat-on-final-keystroke


From: Oliver Scholz
Subject: Re: repeat-on-final-keystroke
Date: Mon, 24 Apr 2006 12:40:33 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Enzo Vitale <enzo.vitale@epfl.ch> writes:

> Dear Emacs experts,
>
> I have rebound the 'bs-cycle-next' command to 'C-x b' and I would very
> much like it to behave as 'repeat' in the sense that continuing to
> press
> simply the last character of the key-binding ('b' in this case) had
> the effect of scrolling one by one the list of active buffers.
>
> Currently, I have to retype 'C-x b' each time, very annoying when
> editing tens of different buffers, which is typical for me during code
> development.

IMNSHO, if you have tens of different buffers, you need something more
efficient than buffer cycling ... well, there is no accounting for
taste.

> By the way, the same would also be very useful with the 'undo' command
> (C-x u), and probably many more...

Use `C-/' for undo then.

> Is this possible ?

The way to find this out is by looking at the definition of functions
which already do this, like `repeat'. After cursory skimming it, I'd
say offhand that for your purpose it is sufficient to tinker with
`last-input-event', `read-event' and `unread-command-events'. For
instance:

(defun my-bs-cycle-next ()
  (interactive)
  (let ((dont-stop t))
    (bs-cycle-next)
    (while dont-stop
      (let ((last last-input-event)
            (event (read-event)))
        (if (eq event last)
            (bs-cycle-next)
          (push event unread-command-events)
          (setq dont-stop nil))))))

(define-key global-map (kbd "C-c b") #'my-bs-cycle-next)



    Oliver
-- 
5 Floréal an 214 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

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