all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: phillip.lord@russet.org.uk (Phillip Lord)
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change f59d1be: Move undo amalgamation to lisp.
Date: Mon, 05 Oct 2015 17:24:51 +0100	[thread overview]
Message-ID: <87h9m52sh8.fsf@russet.org.uk> (raw)
In-Reply-To: <jwvy4fhfixv.fsf-monnier+emacsdiffs@gnu.org> (Stefan Monnier's message of "Mon, 5 Oct 2015 11:15:34 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +(defun undo-auto-pre-command-hook()
>> +  (when (and (eq last-command 'self-insert-command)
>> +             (eq this-command 'self-insert-command))
>
> I think this code should be called from self-insert-command rather than
> from pre-command-hook.


On a hook? Or do I just directly call a function defined in lisp form C?

Does the same argument apply to the post-command-hook and
after-change-functions also? I've been trying to use already existing
functionality where possible (as it stands, I've only reduced code in
the C layer -- the one thing I have added -- undo-size -- isn't used
anymore, and I may back out before I've finished).

> And it should also be called from delete-char.

Yes, next on my list. Wanted to do one thing first and check that it
didn't crash first.


>> +    ;; As last-command was s-i-c, there should be "insert" cons just
>> +    ;; before this. We need to check that there have not been too many insertions
>> +    (let ((last-before-nil
>> +           (cadr buffer-undo-list)))
>> +      (when
>> +          (> 20
>> +             (- (cdr last-before-nil)
>> +                (car last-before-nil)))
>
> We don't actually know that (cdr last-before-nil) and (car
> last-before-nil) are numbers.  The previous self-insert-command might
> have performed all kinds of buffer modifications (via abbrev-expansion,
> post-self-insert-hook, ...).

Hmmm. That's unfortunate -- I was trying to avoid "global" state and
just user buffer state; the undo-list seemed like a sensible place to
get this knowledge from.

Other ideas? A buffer-local "undo-auto-self-insert-counter" perhaps? Or
I could just use the logic above when it works and do nothing when it
doesn't which would be safe, but means a post-self-insert-hook might
break the blocks-of-20 amalgamation.

Phil



  reply	other threads:[~2015-10-05 16:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20151005134118.10933.50859@vcs.savannah.gnu.org>
     [not found] ` <E1Zj610-0002qx-SM@vcs.savannah.gnu.org>
2015-10-05 15:15   ` [Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change f59d1be: Move undo amalgamation to lisp Stefan Monnier
2015-10-05 16:24     ` Phillip Lord [this message]
2015-10-07 19:28       ` Stefan Monnier
2015-10-08 19:56         ` Phillip Lord
2015-10-08 20:53           ` Stefan Monnier
2015-10-09  8:31             ` Phillip Lord
2015-10-16 21:02         ` Phillip Lord
2015-10-18 16:51           ` Stefan Monnier
2015-10-21 19:27             ` Phillip Lord
2015-10-26 17:56               ` Stefan Monnier
2015-10-27 12:45                 ` Phillip Lord
2015-10-27 14:50                   ` Stefan Monnier
2015-10-28 10:01                     ` Phillip Lord
2015-10-28 13:05                       ` Stefan Monnier
2015-10-29 14:44                         ` Phillip Lord
2015-10-29 15:47                           ` Stefan Monnier
2015-10-30  8:44                             ` Phillip Lord
2015-10-30 13:28                               ` Stefan Monnier
2015-10-30 14:21                                 ` David Kastrup
2015-11-02 16:56                                   ` Phillip Lord
2015-11-02 19:37                                     ` David Kastrup

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=87h9m52sh8.fsf@russet.org.uk \
    --to=phillip.lord@russet.org.uk \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.