emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Martin Pohlack <mp26@os.inf.tu-dresden.de>
To: emacs-orgmode@gnu.org
Subject: undo grouping
Date: Wed, 25 Feb 2009 09:58:07 +0100	[thread overview]
Message-ID: <49A5081F.5060601@os.inf.tu-dresden.de> (raw)

[resent, as the previous attempts didn't make it to the list ...]

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.

;; 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))))

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

Feedback welcome.


             reply	other threads:[~2009-02-25  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-25  8:58 Martin Pohlack [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-02-24 20:22 Martin Pohlack
2009-02-25  9:08 ` Martin Pohlack
2009-02-25 12:51 ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49A5081F.5060601@os.inf.tu-dresden.de \
    --to=mp26@os.inf.tu-dresden.de \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).