From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: How to configure undo steps for single-character insert? Date: Thu, 14 May 2009 13:43:07 +0200 Message-ID: <87fxf7rjuc.fsf@thinkpad.tsdh.de> References: <873ab8f9cl.fsf@iki.fi> <87y6t0dr5c.fsf@iki.fi> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1242302200 5919 80.91.229.12 (14 May 2009 11:56:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 May 2009 11:56:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 14 13:56:31 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M4ZY1-0001dw-KG for geh-help-gnu-emacs@m.gmane.org; Thu, 14 May 2009 13:56:26 +0200 Original-Received: from localhost ([127.0.0.1]:47127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M4ZY1-00042x-1b for geh-help-gnu-emacs@m.gmane.org; Thu, 14 May 2009 07:56:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M4ZLU-0007Yl-0U for help-gnu-emacs@gnu.org; Thu, 14 May 2009 07:43:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M4ZLP-0007Ug-8i for help-gnu-emacs@gnu.org; Thu, 14 May 2009 07:43:27 -0400 Original-Received: from [199.232.76.173] (port=55501 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M4ZLO-0007US-TB for help-gnu-emacs@gnu.org; Thu, 14 May 2009 07:43:22 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:36847 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M4ZLO-0007ju-7c for help-gnu-emacs@gnu.org; Thu, 14 May 2009 07:43:22 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1M4ZLK-0006iC-7O for help-gnu-emacs@gnu.org; Thu, 14 May 2009 11:43:18 +0000 Original-Received: from dhcp42.uni-koblenz.de ([141.26.71.42]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 May 2009 11:43:18 +0000 Original-Received: from tassilo by dhcp42.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 May 2009 11:43:18 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 149 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dhcp42.uni-koblenz.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux) Cancel-Lock: sha1:qS2i2gqjPoqKo6jaxvYflyDxiwo= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64421 Archived-At: Teemu Likonen writes: Hi Teemu, >> I guess you use the org version integrated into emacs 23, right? >> Newer versions of org-mode implement a better undo, but that won't >> make it into emacs 23.1. > > No, I use the Org mode that is integrated with Emacs 22 in Debian > GNU/Linux. Oh, even older. > Is there not a simple user option for this? Nope, I don't think so. Looking at org-mode's git repo: ,----[ cd ~/repos/el/org-mode; git log ] | commit 8b0d614702678b69d4ba520cb33f9177c0832f74 | Author: Carsten Dominik | Date: Wed Feb 25 12:43:24 2009 +0100 | | Undo: Cluster self-insert characters for undo | | Undo will now remove up to 20 characters typed consecutively, just | like Emacs normally does. We need a special implementation for this | because Org has its own self-insert command. | | The code for doing this is a patch by Martin Pohlack. `---- ,----[ cd ~/repos/el/org-mode; git diff 8b0d614702678b69d4ba520cb33f9177c0832f74^ 8b0d614702678b69d4ba520cb33f9177c0832f74 ] | diff --git a/doc/org.texi b/doc/org.texi | index e3c927d..fa105db 100644 | --- a/doc/org.texi | +++ b/doc/org.texi | @@ -10745,6 +10745,9 @@ links, among other things. | @i{Pete Phillips} helped during the development of the TAGS feature, and | provided frequent feedback. | @item | +@i{Martin Pohlack} provided the code snippet to bundle character insertion | +into bundles of 20 for undo. | +@item | @i{T.V. Raman} reported bugs and suggested improvements. | @item | @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality | diff --git a/lisp/ChangeLog b/lisp/ChangeLog | index c837af2..aceff8b 100755 | --- a/lisp/ChangeLog | +++ b/lisp/ChangeLog | @@ -1,3 +1,12 @@ | +2009-02-25 Carsten Dominik | + | + * org-table.el (orgtbl-self-insert-command): Cluster undo for 20 | + characters. | + | + * org.el (org-self-insert-cluster-for-undo): New option. | + (org-self-insert-command): Cluster undo for 20 characters. | + (org-self-insert-command-undo-counter): New variable. | + | 2009-02-24 Carsten Dominik | | * org-exp.el (org-export-as-html): Fix problem with closing colone | diff --git a/lisp/org-table.el b/lisp/org-table.el | index 08ceb34..0eae745 100644 | --- a/lisp/org-table.el | +++ b/lisp/org-table.el | @@ -3568,14 +3568,27 @@ overwritten, and the table is not marked as requiring realignment." | (goto-char (match-beginning 0)) | (self-insert-command N)) | (setq org-table-may-need-update t) | - (let (orgtbl-mode a) | - (call-interactively | - (or (key-binding | - (or (and (listp function-key-map) | - (setq a (assoc last-input-event function-key-map)) | - (cdr a)) | - (vector last-input-event))) | - 'self-insert-command))))) | + (let* (orgtbl-mode | + a | + (cmd (or (key-binding | + (or (and (listp function-key-map) | + (setq a (assoc last-input-event function-key-map)) | + (cdr a)) | + (vector last-input-event))) | + 'self-insert-command))) | + (call-interactively cmd) | + (if (and org-self-insert-cluster-for-undo | + (eq cmd 'self-insert-command)) | + (if (not (eq last-command 'orgtbl-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) | + (and (> org-self-insert-command-undo-counter 0) | + buffer-undo-list | + (not (cadr buffer-undo-list)) ; remove nil entry | + (setcdr buffer-undo-list (cddr buffer-undo-list))) | + (setq org-self-insert-command-undo-counter | + (1+ org-self-insert-command-undo-counter)))))))) | | (defvar orgtbl-exp-regexp "^\\([-+]?[0-9][0-9.]*\\)[eE]\\([-+]?[0-9]+\\)$" | "Regular expression matching exponentials as produced by calc.") | diff --git a/lisp/org.el b/lisp/org.el | index 388d777..0fef029 100644 | --- a/lisp/org.el | +++ b/lisp/org.el | @@ -903,6 +903,14 @@ See also the variable `org-table-auto-blank-field'." | (const :tag "on" t) | (const :tag "on, optimized" optimized))) | | +(defcustom org-self-insert-cluster-for-undo t | + "Non-nil means cluster self-insert commands for undo when possible. | +If this is set, then, like in the Emacs command loop, 20 consequtive | +characters will be undone together. | +This is configurable, because there is some impact on typing performance." | + :group 'org-table | + :type 'boolean) | + | (defcustom org-table-tab-recognizes-table.el t | "Non-nil means, TAB will automatically notice a table.el table. | When it sees such a table, it moves point into it and - if necessary - | @@ -13286,7 +13294,18 @@ overwritten, and the table is not marked as requiring realignment." | (self-insert-command N)) | (setq org-table-may-need-update t) | (self-insert-command N) | - (org-fix-tags-on-the-fly))) | + (org-fix-tags-on-the-fly) | + (if org-self-insert-cluster-for-undo | + (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) | + (and (> org-self-insert-command-undo-counter 0) | + buffer-undo-list | + (not (cadr buffer-undo-list)) ; remove nil entry | + (setcdr buffer-undo-list (cddr buffer-undo-list))) | + (setq org-self-insert-command-undo-counter | + (1+ org-self-insert-command-undo-counter))))))) | | (defun org-fix-tags-on-the-fly () | (when (and (equal (char-after (point-at-bol)) ?*) `---- So it's not a too trivial patch, and I guess it won't apply to the emacs 22 org version... Bye, Tassilo