emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] undo grouping


From: Carsten Dominik
Subject: Re: [Orgmode] undo grouping
Date: Wed, 25 Feb 2009 13:51:08 +0100


Excellent, thank you very much.

I have installed this code (not using advice, but directly).

- Carsten

On Feb 24, 2009, at 9:22 PM, Martin Pohlack wrote:

Hi All,

I hacked together a small workaround for the ungrouped undo-list entries (undo works only characterwise in org-mode, but usually chunks together
several key strokes in, e.g., text-mode).

I have this piece of code in my emacs startup script.

-----–----------------------------- >8-----------------------------------
;; implement undo grouping for org-mode
(setq org-self-insert-command-undo-counter 0)
(defadvice org-self-insert-command (after compact-undo-list () activate)
 "Compact the undo list by removing some boundaries."
 (if (not (eq last-command 'org-self-insert-command))
     (setq org-self-insert-command-undo-counter 1)
   (if (>= org-self-insert-command-undo-counter 20)
       (setq org-self-insert-command-undo-counter 1)
     (when (> org-self-insert-command-undo-counter 0)
       (when buffer-undo-list
         (when (not (cadr buffer-undo-list)) ; remove nil entry
           (setcdr buffer-undo-list (cddr buffer-undo-list)))))
     (incf org-self-insert-command-undo-counter))))
-----–----------------------------- >8-----------------------------------

The advice post-processes the local buffer-undo-list and removes some
undo-boundaries.  The behavior is modeled after emacs' command_loop.

Feedback welcome.

Cheers,
Martin


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode





reply via email to

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