From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Andrii Kolomoiets <andreyk.mad@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188)
Date: Sun, 13 Sep 2020 16:27:44 -0400 [thread overview]
Message-ID: <jwv5z8h77l0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m2363lijw3.fsf@gmail.com> (Andrii Kolomoiets's message of "Sun, 13 Sep 2020 21:58:20 +0300")
> Take a look at the new patch. ewoc-invalidate now save and restore
> point line and column offset in the current node.
Wow! That seems more complex than we'd like it to be.
Hmm...
Maybe doing it inside ewoc--refresh-node makes it easier, as in the
100% untested patch below.
Stefan
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index fcb3d5a29e..f5ff41491d 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -205,15 +205,22 @@ ewoc--insert-new-node
(defun ewoc--refresh-node (pp node dll)
"Redisplay the element represented by NODE using the pretty-printer PP."
- (let ((inhibit-read-only t)
- (m (ewoc--node-start-marker node))
- (R (ewoc--node-right node)))
- ;; First, remove the string from the buffer:
- (delete-region m (ewoc--node-start-marker R))
- ;; Calculate and insert the string.
- (goto-char m)
- (funcall pp (ewoc--node-data node))
- (ewoc--adjust m (point) R dll)))
+ (let* ((m (ewoc--node-start-marker node))
+ (R (ewoc--node-right node))
+ (end (ewoc--node-start-marker R))
+ (inhibit-read-only t)
+ (percent (when (and (<= m (point) end) (< m end))
+ (/ (- (point) m) 1.0 (- end m)))))
+ (save-excursion
+ ;; First, remove the string from the buffer:
+ (delete-region m end)
+ ;; Calculate and insert the string.
+ (goto-char m)
+ (funcall pp (ewoc--node-data node))
+ (setq end (point))
+ (ewoc--adjust m (point) R dll))
+ (when percent
+ (goto-char (+ m (* percent (- end m)))))))
(defun ewoc--wrap (separator func)
(lambda (data)
@@ -352,11 +359,10 @@ ewoc-map
((footer (ewoc--footer ewoc))
(pp (ewoc--pretty-printer ewoc))
(node (ewoc--node-nth dll 1)))
- (save-excursion
- (while (not (eq node footer))
- (if (apply map-function (ewoc--node-data node) args)
- (ewoc--refresh-node pp node dll))
- (setq node (ewoc--node-next dll node))))))
+ (while (not (eq node footer))
+ (if (apply map-function (ewoc--node-data node) args)
+ (ewoc--refresh-node pp node dll))
+ (setq node (ewoc--node-next dll node)))))
(defun ewoc-delete (ewoc &rest nodes)
"Delete NODES from EWOC."
@@ -471,9 +477,8 @@ ewoc-invalidate
Delete current text first, thus effecting a \"refresh\"."
(ewoc--set-buffer-bind-dll-let* ewoc
((pp (ewoc--pretty-printer ewoc)))
- (save-excursion
- (dolist (node nodes)
- (ewoc--refresh-node pp node dll)))))
+ (dolist (node nodes)
+ (ewoc--refresh-node pp node dll))))
(defun ewoc-goto-prev (ewoc arg)
"Move point to the ARGth previous element in EWOC.
@@ -576,9 +581,8 @@ ewoc-set-hf
(hf-pp (ewoc--hf-pp ewoc)))
(setf (ewoc--node-data head) header
(ewoc--node-data foot) footer)
- (save-excursion
- (ewoc--refresh-node hf-pp head dll)
- (ewoc--refresh-node hf-pp foot dll))))
+ (ewoc--refresh-node hf-pp head dll)
+ (ewoc--refresh-node hf-pp foot dll)))
\f
(provide 'ewoc)
next prev parent reply other threads:[~2020-09-13 20:27 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 [this message]
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
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=jwv5z8h77l0.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=andreyk.mad@gmail.com \
--cc=emacs-devel@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 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).