all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: A problem (apparently) connected with window point
Date: Fri, 02 Apr 2021 08:13:38 -0400	[thread overview]
Message-ID: <jwvft0828rh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 875z159val.fsf@mbork.pl

> 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




  parent reply	other threads:[~2021-04-02 12:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02  4:15 A problem (apparently) connected with window point Marcin Borkowski
2021-04-02  5:54 ` Eli Zaretskii
2021-04-02 12:13 ` Stefan Monnier [this message]
2021-04-03  3:25   ` Marcin Borkowski
2021-04-03 15:22     ` Stefan Monnier

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=jwvft0828rh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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.