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: Wed, 30 Sep 2020 23:08:42 +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="34080"; 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 Wed Sep 30 22:09:49 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 1kNiQ8-0008mf-GA for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Sep 2020 22:09:48 +0200 Original-Received: from localhost ([::1]:43924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNiQ7-0005Ff-Ir for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Sep 2020 16:09:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNiPC-0004oS-9W for emacs-devel@gnu.org; Wed, 30 Sep 2020 16:08:50 -0400 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNiP9-0008K3-J1 for emacs-devel@gnu.org; Wed, 30 Sep 2020 16:08:49 -0400 Original-Received: by mail-wm1-x334.google.com with SMTP id x23so740214wmi.3 for ; Wed, 30 Sep 2020 13:08:46 -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=Icpmn+iA38Mvv4NLDveRK4xI85leaZqyrvXLwB4rUuk=; b=rJTti1U9iJ7OkzQkoswBhdz77GDltOO4JMOLoDSPEREz4iGSEWqq2X1dknf43G6VFO FLa7WU200ZvGZqO8KEk48Rzm0roMyDGyqyilu8sYeGdBmCeAe033XYToo540W+2yg7Ge fOR+v9OII0kF7yq0AfpoH8fQ8+8E8VDom59+X0kbWyKX+JMrCQ3O0yfuj9gUgcklG1Gj eY92BOg41kGaN8S9dJzl6mxwytL4BuRJTAiVVQ1IRZCve1K+jOx0vUcLo/vvaKRF3KX3 6UMbRBAn5zSRAFh8mEDwvHoNsJmUnNLBRcV6GIxSGF/QrYucbflE3aG3cUwLdTLeDuwS vIGQ== 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=Icpmn+iA38Mvv4NLDveRK4xI85leaZqyrvXLwB4rUuk=; b=qMouO7wDhD9XDN77fycY2kVjuWdTQR/hxT0Fm5/ehCsLT6x/V8iiQP0sHO5gaNKUM9 USTQ8v3JrIj3HD+bESR6B4RT8sDyydf5EatnrnTG0Adw7t1LXm9oqL7CrChuNyDmVDAa H4KK9VQBvmNRWXAyvs/vmfyy0ECI777obBhLEdnGbSQ2K4qqkefbyiFZ9y0v1QGYleUO gL54J8tnW7aRv/CMA2lFIRlR1KX8jeF6Oe0gKLUTVTMazfSmNx33m7eOW4FisW88AQyw qbO8DrO+xISHjM+2qFLiohUf0qqugJC5uTIuJ1SmQnncC3YM+WeOoV0uqzRIpwPSJ68/ QC0g== X-Gm-Message-State: AOAM532Sw16wRxuWAhr2X6+hRTHuJfoRDHY9pmjC0niTzP1dDsuQLny+ KdwxnXJhnEJXBCMAjQrll6zijTQaWSg= X-Google-Smtp-Source: ABdhPJyZxUtrkATLFkLJAFszSlSkghlbqAkDsap8XBTmGyhG1EfPJpcCcKmX6/LrBRwL0P3KnLdvlQ== X-Received: by 2002:a1c:a444:: with SMTP id n65mr4734062wme.122.1601496525136; Wed, 30 Sep 2020 13:08:45 -0700 (PDT) Original-Received: from muffinmac ([91.206.110.145]) by smtp.gmail.com with ESMTPSA id p11sm4388964wma.11.2020.09.30.13.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 13:08:44 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 28 Sep 2020 13:13:27 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=andreyk.mad@gmail.com; helo=mail-wm1-x334.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:256799 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier 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! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=ewoc-save-point-in-windows.patch 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) --=-=-=--