Lisp HUG Maillist Archive

Custom editor commands and Undo

If I write my own editor command (which might delete a couple of
characters and insert some others) how can I make sure that the
modification as a whole is "registered" as one Undo step, i.e. such
that C-x u will revoke the whole command?

Thanks,
Edi.


Re: Custom editor commands and Undo

Hi Edi,

On Jul 17, 2005, at 5:56 PM, Edi Weitz wrote:

> If I write my own editor command (which might delete a couple of
> characters and insert some others) how can I make sure that the
> modification as a whole is "registered" as one Undo step, i.e. such
> that C-x u will revoke the whole command?
>


See the recording-for-undo macro in the editor source (macros.lisp).  
For an example, see the function newline-and-indent in indent.lisp.

Best,


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: Custom editor commands and Undo

Unable to parse email body. Email id is 4141

Re: Custom editor commands and Undo

On Mon, 18 Jul 2005 11:04:30 +0100 (BST), Nick Levine <ndl@ravenbrook.com> wrote:

> I think the editor:collect-undo macro might help?

While the macro John recommended does what I want I run into errors
when using this one.  Hmm, maybe I'm just too dumb.

Anyway, my problems are solved... :)

Thanks,
Edi.


Re: Custom editor commands and Undo

Unable to parse email body. Email id is 4145

Re: Custom editor commands and Undo

On Sun, 17 Jul 2005 19:37:26 -0400, John DeSoi <desoi@pgedit.com> wrote:

> See the recording-for-undo macro in the editor source (macros.lisp).
> For an example, see the function newline-and-indent in indent.lisp.

Thanks, that's what I was looking for.


Re: Custom editor commands and Undo

On Mon, 18 Jul 2005 15:36:41 +0100 (BST), Nick Levine <ndl@ravenbrook.com> wrote:

> As a matter of interest, what was the error?

I've written a replacement for LispWorks' "Complete Symbol" function
which uses DELETE-NEXT-CHARACTER-COMMAND and SELF-INSERT-COMMAND to
change the contents of the buffer.  If I wrap

  (editor:collect-undo (editor:current-buffer)
    ...)

around this code and press C-x u after using it I get

  ** Processor Fault #xC0000005 at #x20B82959 (#<function
  EDITOR::DELETE-CHARACTERS 20B82932>).

As I said, this might as well be my fault.  I'm not really a wizard as
far as hacking the LW editor is concerned.  (Not that I'm a wizard in
anything else... :)

Cheers,
Edi.


Re: Custom editor commands and Undo

Unable to parse email body. Email id is 4153

Re: Custom editor commands and Undo

On Tue, 19 Jul 2005 09:39:54 +0100, Martin Simmons <martin@lispworks.com> wrote:

> This can happen if you modify more than one buffer inside the
> EDITOR:COLLECT-UNDO form (including the sending messages to the echo
> area).

Ah, yes, that explains it.  I was sending messages to the echo area.

Thanks,
Edi.


Updated at: 2020-12-10 08:51 UTC