From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel 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 Message-ID: References: <20200904211737.15548.63989@vcs0.savannah.gnu.org> <20200904211738.DA94720667@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1037"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Andrii Kolomoiets Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 13 22:28:21 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kHYbl-0000Bg-Nl for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Sep 2020 22:28:21 +0200 Original-Received: from localhost ([::1]:59068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHYbk-0006UQ-Qv for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Sep 2020 16:28:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHYbH-000642-Jj for emacs-devel@gnu.org; Sun, 13 Sep 2020 16:27:51 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:59429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHYbF-0006Ar-4B for emacs-devel@gnu.org; Sun, 13 Sep 2020 16:27:50 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D600410023C; Sun, 13 Sep 2020 16:27:47 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C4B45100059; Sun, 13 Sep 2020 16:27:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600028865; bh=rcSoV8aUlhxAenr1uAPk6/nxTGx8t8v73PrvH0X+iCI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=M0s8yAUOritBwmV+lGwut/OzkJY4CtQF5zNHB/l0ilOW+qpGzAZPzavCwj1Vvpue1 cksR3BY3S1miY4WREuKeOpk0v3UjJ2LSMonN7YWJn9i0HXAXUaSceL7rh9+ouNNi8V 5nuiYGzHuh+bqpmp3aVARcQlkYOXlU9kVctb6Hkbstwpftro7k5bIqmWylDeNvwxVe lzvUx0YEtm1yNtAB026L/u71RN88ff9TzeRHvsOr9Qw/d+Jv5/wcSU0SFTKmInGHxm ZyxxnzbLfqFf38ZERvwsRuQSp1EMjtRZOBB6PAY+IrOvnv73TgKN7w+ziQwJS1YNrJ 8rV/9x6FI+B+A== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9F3FA1201D0; Sun, 13 Sep 2020 16:27:45 -0400 (EDT) In-Reply-To: (Andrii Kolomoiets's message of "Sun, 13 Sep 2020 21:58:20 +0300") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/13 15:03:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:255571 Archived-At: > 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)