all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: help-gnu-emacs@gnu.org
Subject: Re: How to configure undo steps for single-character insert?
Date: Thu, 14 May 2009 13:43:07 +0200	[thread overview]
Message-ID: <87fxf7rjuc.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: 87y6t0dr5c.fsf@iki.fi

Teemu Likonen <tlikonen@iki.fi> 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 <carsten.dominik@gmail.com>
| 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  <carsten.dominik@gmail.com>
| +
| +	* 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  <carsten.dominik@gmail.com>
|  
|  	* 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





  reply	other threads:[~2009-05-14 11:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14  7:10 How to configure undo steps for single-character insert? Teemu Likonen
2009-05-14  7:47 ` Tassilo Horn
     [not found] ` <mailman.7140.1242287296.31690.help-gnu-emacs@gnu.org>
2009-05-14  8:29   ` Teemu Likonen
2009-05-14 11:43     ` Tassilo Horn [this message]
     [not found]     ` <mailman.7150.1242301410.31690.help-gnu-emacs@gnu.org>
2009-05-14 15:17       ` Teemu Likonen

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

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

  git send-email \
    --in-reply-to=87fxf7rjuc.fsf@thinkpad.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.