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: Tue, 24 Feb 2009 21:22:50 +0100	[thread overview]
Message-ID: <49A4571A.8070509@os.inf.tu-dresden.de> (raw)

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	other threads:[~2009-02-24 20:22 UTC|newest]

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

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=49A4571A.8070509@os.inf.tu-dresden.de \
    --to=mp26@os.inf.tu-dresden.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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