From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pohlack Subject: undo grouping Date: Wed, 25 Feb 2009 09:58:07 +0100 Message-ID: <49A5081F.5060601@os.inf.tu-dresden.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LcFaq-0002xT-HO for emacs-orgmode@gnu.org; Wed, 25 Feb 2009 03:58:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LcFao-0002x4-Ky for emacs-orgmode@gnu.org; Wed, 25 Feb 2009 03:58:15 -0500 Received: from [199.232.76.173] (port=49466 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LcFao-0002x1-Hk for emacs-orgmode@gnu.org; Wed, 25 Feb 2009 03:58:14 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]:42465) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LcFan-0002kw-T3 for emacs-orgmode@gnu.org; Wed, 25 Feb 2009 03:58:14 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org [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. -----–----------------------------->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