From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pohlack Subject: undo grouping Date: Tue, 24 Feb 2009 21:22:50 +0100 Message-ID: <49A4571A.8070509@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 1Lc3nl-0006hW-6i for emacs-orgmode@gnu.org; Tue, 24 Feb 2009 15:22:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lc3ni-0006dz-U0 for emacs-orgmode@gnu.org; Tue, 24 Feb 2009 15:22:48 -0500 Received: from [199.232.76.173] (port=45454 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lc3ni-0006dl-PK for emacs-orgmode@gnu.org; Tue, 24 Feb 2009 15:22:46 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]:43700) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lc3ni-00039K-FN for emacs-orgmode@gnu.org; Tue, 24 Feb 2009 15:22:46 -0500 Received: from [217.235.122.142] (helo=[192.168.1.106]) by os.inf.tu-dresden.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) id 1Lc3ng-0000P4-D2 for emacs-orgmode@gnu.org; Tue, 24 Feb 2009 21:22:44 +0100 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 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