help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to configure undo steps for single-character insert?


From: Tassilo Horn
Subject: Re: How to configure undo steps for single-character insert?
Date: Thu, 14 May 2009 13:43:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]