[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin
From: |
Stefan Monnier |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> 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)))
(provide 'ewoc)
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/04
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/05
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/05
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/13
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188),
Stefan Monnier <=
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/15
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/15
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/18
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/18
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/18
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/18
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/24
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Stefan Monnier, 2020/09/28
- Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188), Andrii Kolomoiets, 2020/09/30