unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188)
Date: Wed, 30 Sep 2020 23:08:42 +0300	[thread overview]
Message-ID: <m2tuvfc9it.fsf@gmail.com> (raw)
In-Reply-To: <jwveeml25hi.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 28 Sep 2020 13:13:27 -0400")

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

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

>> There are still the case when point position is not saved on
>> ewoc-invalidate - when the buffer is displayed in the other window:
>
> Plus when the buffer is "displayed in a window configuration saved in
> a register", plus when invalidate is called from within
> `save-excursion`, plus ....
>
> Arguably Emacs should provide some way to better handle those issues
> (e.g. provide a hook that can be used to influence the way markers move
> in response to text removal+insertion), but until it does, I recommend
> you live with the occasional suboptimal behavior.

Ok, I will.  But take a look at the attached patch, please.  Few
additional lines and the point is saved in all windows!  Not sure about
those additional cases you mention though, but if the behavior will be
suboptimal, I'll be ready :)

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ewoc-save-point-in-windows.patch --]
[-- Type: text/x-patch, Size: 1790 bytes --]

diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index 5112322cfd..b71ae5864c 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -209,10 +209,19 @@ ewoc--refresh-node
          (R (ewoc--node-right node))
          (end (ewoc--node-start-marker R))
          (inhibit-read-only t)
-         (offset (if (= (point) end)
-                     'end
-                   (when (< m (point) end)
-                     (- (point) m)))))
+         (get-offset (lambda (point)
+                       (if (= point end)
+                           'end
+                         (when (< m point end)
+                           (- point m)))))
+         (offset (funcall get-offset (point)))
+         (windows (mapcar (lambda (w)
+                            (unless (eq w (selected-window))
+                              (let ((offset (funcall get-offset
+                                                     (window-point w))))
+                                (when offset
+                                  (cons w offset)))))
+                          (get-buffer-window-list nil nil t))))
     (save-excursion
       ;; First, remove the string from the buffer:
       (delete-region m end)
@@ -224,7 +233,14 @@ ewoc--refresh-node
     (when offset
       (goto-char (if (eq offset 'end)
                      end
-                   (min (+ m offset) (1- end)))))))
+                   (min (+ m offset) (1- end)))))
+    (mapc (lambda (w)
+            (when (window-live-p (car w))
+              (set-window-point (car w)
+                                (if (eq (cdr w) 'end)
+                                    end
+                                  (min (+ m (cdr w)) (1- end))))))
+          windows)))
 
 (defun ewoc--wrap (func)
   (lambda (data)

      reply	other threads:[~2020-09-30 20:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200904211737.15548.63989@vcs0.savannah.gnu.org>
     [not found] ` <20200904211738.DA94720667@vcs0.savannah.gnu.org>
2020-09-04 21:44   ` master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188) Stefan Monnier
2020-09-05 19:34     ` Andrii Kolomoiets
2020-09-05 19:41       ` Stefan Monnier
2020-09-13 18:58         ` Andrii Kolomoiets
2020-09-13 20:27           ` Stefan Monnier
2020-09-15 19:14             ` Andrii Kolomoiets
2020-09-15 20:32               ` Stefan Monnier
2020-09-18 14:57                 ` Andrii Kolomoiets
2020-09-18 15:23                   ` Stefan Monnier
2020-09-18 15:47                     ` Andrii Kolomoiets
2020-09-18 15:53                       ` Stefan Monnier
2020-09-24 20:21                         ` Andrii Kolomoiets
2020-09-28 17:13                           ` Stefan Monnier
2020-09-30 20:08                             ` Andrii Kolomoiets [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2tuvfc9it.fsf@gmail.com \
    --to=andreyk.mad@gmail.com \
    --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 public 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).