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

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

Re: A problem (apparently) connected with window point


From: Stefan Monnier
Subject: Re: A problem (apparently) connected with window point
Date: Fri, 02 Apr 2021 08:13:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> The problem is that `reorder-sentence-copy-word-at-point' inserts every
> word at the beginning of the buffer.  (Try it, following the steps
> above.)  I very much suspect that this is because of the window point:

That's right.  To avoid the problem you have to understand that
`(with-current-buffer reorder-sentence--buffer ...)` will select the
right buffer but will place point at a location that depends on what was
the last use of that buffer (and redisplay *is* a use of that buffer,
which is why having the buffer displayed makes a difference).
In your case I think you have two options:

1- Take it for granted that the buffer is displayed and make
   `reorder-sentence-copy-word-at-point` move the corresponding
   window-point (either by selecting that window around the `insert` or
   by explicitly using `set-window-point`) and use that window-point as
   the insertion point (so the user can move the cursor in that window
   in order to insert word either at the end, beginning or elsewhere in
   the temp buffer).

2- Use your own notion of "point", e.g. by calling (goto-char <my-point>)
   before the `insert` and updating <my-point> as you see fit.
   In your example, I suspect using (point-max) for <my-point> might do
   the trick.


-- Stefan




reply via email to

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