From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrii Kolomoiets Newsgroups: gmane.emacs.devel Subject: Re: master f450798: Don't move point in vc-dir on vc-register/vc-checkin (bug#43188) Date: Fri, 18 Sep 2020 17:57:29 +0300 Message-ID: References: <20200904211737.15548.63989@vcs0.savannah.gnu.org> <20200904211738.DA94720667@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39502"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 18 16:59:15 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 1kJHr0-000A9w-Ut for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Sep 2020 16:59:15 +0200 Original-Received: from localhost ([::1]:42542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJHqz-00083X-VD for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Sep 2020 10:59:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJHpR-0006E2-LP for emacs-devel@gnu.org; Fri, 18 Sep 2020 10:57:37 -0400 Original-Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:46942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJHpP-0006cG-It for emacs-devel@gnu.org; Fri, 18 Sep 2020 10:57:37 -0400 Original-Received: by mail-lj1-x22c.google.com with SMTP id a22so5307524ljp.13 for ; Fri, 18 Sep 2020 07:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vcBweug/v6RjOyaCobzIc7ZKzdja+yg36svYoQ9xroU=; b=AvfFI6wMwb0OjsCBVtDXAIY/0d178uLnwMQ8PB/C4J8x8HEYXw+Zh+ub8vWUc4TMI0 x6QKBego6wgu5ZSnmk1LWkkd6yifnXy4tUg1ogng9DmCbd+2sg9wVmmfaDrDR4xZ1gAy ZjxJaXD3YF76NracjrgJO8m1uki1xTlsTZ5V2a9llu2KRWGhXuY4LFU/Co35f1dnRhV5 qIcVBP1EUMpEhVJVv0x8ueINxOcWYNDBnHxjYLq+GElrx3wkJkpFyIMpewLZ/C/O0U/q 6pqdL36AaAqdTfAVPXHqz4JBB36iCZrKNXSiCZvSLBHigNtT9AGdYa87dEZ+sYuNlzQs 2mWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=vcBweug/v6RjOyaCobzIc7ZKzdja+yg36svYoQ9xroU=; b=K6lIy8jp/pcslgg9l49N73sttFgt/3AO9P0CoOmjQN+H6aI5q5KLOKdq6JCAVBYfBl ipVWR6mGMW8BauWeioLvOEQXfmWwefLGjbYGX85oI0IdV+avPnCM44JjJJAd6HJLLSDG Fqm1qXG883L+Psj9EbXySyl0Ife3VN4N2HVlnEDATKSMx+anVBByNyJYOUHzhyrfKqYJ tk5tyXdMUUkm57vhT1MvZ8TVrXHX69A74CLMLR64MXsN57ymTWKvwHf49VAR//YdHFv5 PKe7hNqHNW7/GHZScKmPmkKCHiBK3xCAfXbBqiSFPM4b/hY7VhzETuRmkrQ7uHHU+f3C IWPw== X-Gm-Message-State: AOAM530EZvV6Rc8P5VtggP8r4u7L9x2TBbyX6Z2xo/eOHhbKiEYSuFYJ oD8Tv3UwIErp20NWZS+QkbbXv12VGQU= X-Google-Smtp-Source: ABdhPJxMMz60+F9rABSs0IgHh/1mo336ALQ/zO8hoaFdWLI7218ySIcbXiG0dCBrQRehxC8J00/T5Q== X-Received: by 2002:a05:651c:c5:: with SMTP id 5mr12603830ljr.211.1600441052977; Fri, 18 Sep 2020 07:57:32 -0700 (PDT) Original-Received: from muffinmac ([91.206.110.141]) by smtp.gmail.com with ESMTPSA id y21sm641189ljk.110.2020.09.18.07.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 07:57:32 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Tue, 15 Sep 2020 16:32:39 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=andreyk.mad@gmail.com; helo=mail-lj1-x22c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:256092 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Also I would move point by offset rather than percent to save exactly >> the same position. > > Feel free to do that, yes (of course taking care of the case where the > new text is shorter than the original position). Done. Please see attached patch. Thanks! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Save-and-restore-point-in-ewoc-invalidate.patch >From b630aa0f63312585c65847e1cec4a61d57face98 Mon Sep 17 00:00:00 2001 From: Andrii Kolomoiets Date: Sat, 5 Sep 2020 22:18:59 +0300 Subject: [PATCH] Save and restore point in ewoc-invalidate * lisp/emacs-lisp/ewoc.el (ewoc--refresh-node): Save and restore point line and column offset. (eowc-map) (ewoc--invalidate) (ewoc-set-hf): Don't use save-excursion * lisp/vc/vc-dir.el (vc-dir-update): Don't save/restore point on calling 'ewoc-invalidate'. --- lisp/emacs-lisp/ewoc.el | 48 ++++++++++++++++++++++++++++-------------------- lisp/vc/vc-dir.el | 6 +----- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el index 78ada3e076..5112322cfd 100644 --- a/lisp/emacs-lisp/ewoc.el +++ b/lisp/emacs-lisp/ewoc.el @@ -205,15 +205,26 @@ 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) + (offset (if (= (point) end) + 'end + (when (< m (point) end) + (- (point) 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 offset + (goto-char (if (eq offset 'end) + end + (min (+ m offset) (1- end))))))) (defun ewoc--wrap (func) (lambda (data) @@ -342,11 +353,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." @@ -461,9 +471,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. @@ -566,9 +575,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) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 6c219005ce..cdf8ab984e 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -451,11 +451,7 @@ vc-dir-update (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry)) (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry)) (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil) - ;; `ewoc-invalidate' will kill line and insert new text, - ;; let's keep point column. - (let ((p (point))) - (ewoc-invalidate vc-ewoc node) - (goto-char p))) + (ewoc-invalidate vc-ewoc node)) ;; If the state is nil, the file does not exist ;; anymore, so remember the entry so we can remove ;; it after we are done inserting all ENTRIES. -- 2.15.1 --=-=-=--