emacs-devel
[Top][All Lists]
Advanced

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

Re: REDO ?


From: Davis Herring
Subject: Re: REDO ?
Date: Mon, 23 Apr 2007 13:16:42 -0700 (PDT)
User-agent: SquirrelMail/1.4.8-4.el3.2lanl

> i've used kyle jones' redo.el for a few years, and wouldn't go back to
> the painful layering of undo-on-undo in order to redo.  undoing feels
> like a delicate, hazardous operation without redo, because of the
> obstacle of geometrically mounting undo length in the case of
> overshoot.  i used to get lost in that labrynth much too commonly, and
> expect that people unfamiliar with how well it is mitigated by redo
> don't realize what they're missing - but may recognize the experience
> of tension while undoing, needing to not overshoot...

My take on this is somewhat simpler.  I use the following function (which,
though it works fine for me, could easily screw things up badly, so use at
your own risk):

;; In order to propertly handle "already performing undos", this must be
;; bound to a key (not run via M-x).
(defun undo-permanently ()
  "Undo the most recent change and forget about it.
Selective undo is not supported, so no prefix argument is accepted, and
Transient Mark mode is ignored.
If already performing undos, undo one more change and then forget it and all
changes since."
  (interactive "*")
  (let (transient-mark-mode)
    (when (and (eq last-command 'undo)
               (not (eq pending-undo-list t)))
      ;; In Emacs 22, just test `undo-in-region' instead of all this:
      (let ((pbul buffer-undo-list))
        (while (not (eq pbul pending-undo-list))
          (if pbul (setq pbul (cdr pbul))
            (error "Can't `undo-permanently' during a selective undo")))))
    (undo)
    (message "Permanently undone!")
    (setq buffer-undo-list (unless (eq pending-undo-list t)
                             pending-undo-list))))

I bind this to "C-+" (only available on a window system), which on US
keyboards is one key over from "C-_".  Then I use it instead of "undo" for
all the trivial mistakes I make, and when I really want to back out of one
thing and do another, and to undo (ha) the growth of the undo-list if it
acquires too many "redundant" entries on the end.  It doesn't precisely
address your problem, but I find that it simplifies things and so makes
undo less painful.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

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