emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] undo grouping


From: Martin Pohlack
Subject: [Orgmode] undo grouping
Date: Tue, 24 Feb 2009 21:22:50 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090110)

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




reply via email to

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