unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected
@ 2021-11-23 19:30 Narendra Joshi
  2021-11-24 12:27 ` Eli Zaretskii
  2021-11-24 16:58 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Narendra Joshi @ 2021-11-23 19:30 UTC (permalink / raw)
  To: emacs-devel

Hi,

I think `vcursor.el` has a bug that causes `point` (the real cursor) to
move to where the virtual cursor is whenever `vcursor-copy-{word,line}`
are used. 

We need to wrap the `goto-char` call below in something like
`save-excursion`:

--8<---------------cut here---------------start------------->8---
1 file changed, 3 insertions(+), 4 deletions(-)
lisp/vcursor.el | 7 +++----

modified   lisp/vcursor.el
@@ -785,12 +785,11 @@ vcursor-get-char-count
 
 This is called by most of the virtual-cursor copying commands to find
 out how much to copy."
-
   (vcursor-check)
   (with-current-buffer (overlay-buffer vcursor-overlay)
-    (let ((start (goto-char (overlay-start vcursor-overlay))))
-      (- (progn (apply func args) (point)) start)))
-  )
+    (save-excursion
+      (let ((start (goto-char (overlay-start vcursor-overlay))))
+        (- (progn (apply func args) (point)) start)))))
 
 ;; Make sure the virtual cursor is active.  Unless arg is non-nil,
 ;; report an error if it is not.
--8<---------------cut here---------------end--------------->8---

Best regards,
-- 
Narendra Joshi




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected
  2021-11-23 19:30 vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected Narendra Joshi
@ 2021-11-24 12:27 ` Eli Zaretskii
  2021-11-24 20:41   ` Narendra Joshi
  2021-11-24 16:58 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-11-24 12:27 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: emacs-devel

> From: Narendra Joshi <narendraj9@gmail.com>
> Date: Tue, 23 Nov 2021 20:30:55 +0100
> 
> I think `vcursor.el` has a bug that causes `point` (the real cursor) to
> move to where the virtual cursor is whenever `vcursor-copy-{word,line}`
> are used. 
> 
> We need to wrap the `goto-char` call below in something like
> `save-excursion`:

Thanks, but I think save-excursion should be deeper, immediately befor
we call goto-char.  It is not good practice to change buffers inside
save-excursion.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected
  2021-11-23 19:30 vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected Narendra Joshi
  2021-11-24 12:27 ` Eli Zaretskii
@ 2021-11-24 16:58 ` Stefan Monnier
  2021-11-24 20:07   ` Narendra Joshi
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2021-11-24 16:58 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: emacs-devel

> I think `vcursor.el` has a bug that causes `point` (the real cursor) to
> move to where the virtual cursor is whenever `vcursor-copy-{word,line}`
> are used. 
>
> We need to wrap the `goto-char` call below in something like
> `save-excursion`:


Thanks, pushed to `master`.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected
  2021-11-24 16:58 ` Stefan Monnier
@ 2021-11-24 20:07   ` Narendra Joshi
  0 siblings, 0 replies; 5+ messages in thread
From: Narendra Joshi @ 2021-11-24 20:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Great, thanks :)

On Wed, 24 Nov 2021, 17:58 Stefan Monnier, <monnier@iro.umontreal.ca> wrote:

> > I think `vcursor.el` has a bug that causes `point` (the real cursor) to
> > move to where the virtual cursor is whenever `vcursor-copy-{word,line}`
> > are used.
> >
> > We need to wrap the `goto-char` call below in something like
> > `save-excursion`:
>
>
> Thanks, pushed to `master`.
>
>
>         Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 743 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected
  2021-11-24 12:27 ` Eli Zaretskii
@ 2021-11-24 20:41   ` Narendra Joshi
  0 siblings, 0 replies; 5+ messages in thread
From: Narendra Joshi @ 2021-11-24 20:41 UTC (permalink / raw)
  To: emacs-devel


Sounds good to me, please move the `save-excursion` call nearer to
`goto-char` if/when you have the time. Thank you for the explanation :) 

Best regards,
-- 
Narendra Joshi




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-24 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 19:30 vcursor.el: `vcursor-copy-word` and `vcursory-copy-line` not working as expected Narendra Joshi
2021-11-24 12:27 ` Eli Zaretskii
2021-11-24 20:41   ` Narendra Joshi
2021-11-24 16:58 ` Stefan Monnier
2021-11-24 20:07   ` Narendra Joshi

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).