From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#35860: Delayed window positioning after buffer display Date: Mon, 17 Jun 2019 23:33:44 +0300 Organization: LINKOV.NET Message-ID: <871rzsdj5a.fsf@mail.linkov.net> References: <87o93ucjsi.fsf@mail.linkov.net> <83ef4p7prf.fsf@gnu.org> <87a7fc51qm.fsf@mail.linkov.net> <83k1eg5pmx.fsf@gnu.org> <87k1efhkgp.fsf@mail.linkov.net> <2347769f-9ab3-c1b6-699e-4e89a7d8eb1c@gmx.at> <875zpb4zdw.fsf@mail.linkov.net> <878su5i67f.fsf@mail.linkov.net> <87muik3svu.fsf@mail.linkov.net> <4d0733b1-4ee0-222b-395a-8f26ff76f2da@gmx.at> <87imt6jva7.fsf@mail.linkov.net> <87h88p8e5z.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="53529"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 35860@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 18 00:15:46 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hczuj-000DjI-LP for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 00:15:46 +0200 Original-Received: from localhost ([::1]:52220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hczui-0003PA-B6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Jun 2019 18:15:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59118) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hczt7-0001ft-0k for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2019 18:14:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hczt4-0001kP-Vy for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2019 18:14:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hczt4-0001k5-OE for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2019 18:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hczt4-0006sY-Hi for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2019 18:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jun 2019 22:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35860 X-GNU-PR-Package: emacs Original-Received: via spool by 35860-submit@debbugs.gnu.org id=B35860.156080958926331 (code B ref 35860); Mon, 17 Jun 2019 22:14:02 +0000 Original-Received: (at 35860) by debbugs.gnu.org; 17 Jun 2019 22:13:09 +0000 Original-Received: from localhost ([127.0.0.1]:43412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hczsC-0006qd-MA for submit@debbugs.gnu.org; Mon, 17 Jun 2019 18:13:09 -0400 Original-Received: from dog.birch.relay.mailchannels.net ([23.83.209.48]:8227) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hczrx-0006pr-PV for 35860@debbugs.gnu.org; Mon, 17 Jun 2019 18:13:07 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 68918141D1C; Mon, 17 Jun 2019 22:12:52 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (100-96-89-88.trex.outbound.svc.cluster.local [100.96.89.88]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C4A9214266A; Mon, 17 Jun 2019 22:12:51 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Mon, 17 Jun 2019 22:12:52 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Average-Drop: 5ba3e0ce34d7ceb1_1560809572252_2883200399 X-MC-Loop-Signature: 1560809572252:3126386906 X-MC-Ingress-Time: 1560809572252 Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTP id 707EA83C93; Mon, 17 Jun 2019 15:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=bN9ueeAXEGPvbLT0/ERkwQA1K+w=; b= 2z7dIzgmGylz/xnm8RU7onylq24/bGNYcvit1bItIwvpsSZWO6SxrL0bZAfzEKJg OGBFpoAyonOzkIwtjjB2Kk3OgIV3LTp1lLGbajwEUic31YUuZ0zXObgdkQ/SQcTB dNyuTuePnVKgkh/klOj7uYJolAGmVrFGp2gqRfJKfrc= Original-Received: from mail.jurta.org (m91-129-109-209.cust.tele2.ee [91.129.109.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id F0E0383C5D; Mon, 17 Jun 2019 15:12:42 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a9 In-Reply-To: (martin rudalics's message of "Mon, 17 Jun 2019 10:23:18 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddrudeikedgtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdelrddvtdelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtledrvddtledprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehruhgurghlihgtshesghhmgidrrghtnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160751 Archived-At: --=-=-= Content-Type: text/plain >> In my previous patch there is no need to check for the buffer, >> because a new general variable is declared as buffer-local. > > But the BUFFER argument of 'window--display-buffer' is not necessarily > the current buffer. Or do I miss something? Thanks for pointing out, fixed in a new patch. >>> What happens with these markers when 'display-buffer-no-window' gets >>> called? Or some user provided routine provokes an unhandled error? >>> You don't even check the marker buffer of these variables so some old, >>> completely unrelated marker could get reused here. >> >> There is no global effect because this feature is localized >> to a single buffer by its buffer-local scope. > > We would always have to assure that the marker's buffer and the > current buffer are the same. And we would have to make sure the > marker gets reset when an unhandled error occurs. Assured in a new patch. >> We could support an action alist too in addition to buffer-local variables, >> but we should leave an ability to set buffer-local variables, because >> neither view-lossage nor vc-git-print-log (two primary cases to test >> this feature) have no access to the 'action' arg of display-buffer. > > Maybe we could provide a new macro which encapsulates the use of these > variables in a more disciplied fashion (providing the necessary action > arguments for `display-buffer'). Frankly speaking, macros like with-help-window, with-temp-buffer-window are terribly ugly and look like a kludge. For example, after applying the following patch, all source files that use the changed macro, need to be recompiled, so everyone will need to do bootstrap after pushing it, and many other problems. I see no reason to use macros here. We need to replace these macros with the elegant solution that we already have of using action alists. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=window-start-and-point.2.patch diff --git a/lisp/help.el b/lisp/help.el index 42ff375565..24b5a26ed1 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -37,15 +37,8 @@ (add-hook 'temp-buffer-setup-hook 'help-mode-setup) (add-hook 'temp-buffer-show-hook 'help-mode-finish) -;; `help-window-point-marker' is a marker you can move to a valid -;; position of the buffer shown in the help window in order to override -;; the standard positioning mechanism (`point-min') chosen by -;; `with-output-to-temp-buffer' and `with-temp-buffer-window'. -;; `with-help-window' has this point nowhere before exiting. Currently -;; used by `view-lossage' to assert that the last keystrokes are always -;; visible. -(defvar help-window-point-marker (make-marker) - "Marker to override default `window-point' in help windows.") +(define-obsolete-variable-alias 'help-window-point-marker + 'delayed-window-point "27.1") (defvar help-window-old-frame nil "Frame selected at the time `with-help-window' is invoked.") @@ -481,7 +474,10 @@ view-lossage (comment-indent) (forward-line 1))) ;; Show point near the end of "lossage", as we did in Emacs 24. - (set-marker help-window-point-marker (point))))) + (setq delayed-window-point (point)) + (setq delayed-window-start (save-excursion + (forward-line (- 5 (window-height))) + (point)))))) ;; Key bindings @@ -1249,12 +1245,6 @@ help-window-setup (frame (window-frame window))) (when help-buffer - ;; Handle `help-window-point-marker'. - (when (eq (marker-buffer help-window-point-marker) help-buffer) - (set-window-point window help-window-point-marker) - ;; Reset `help-window-point-marker'. - (set-marker help-window-point-marker nil)) - ;; If the help window appears on another frame, select it if ;; `help-window-select' is non-nil and give that frame input focus ;; too. See also Bug#19012. @@ -1326,9 +1316,6 @@ help-window-setup ;; (3) An option (customizable via `help-window-select') to select the ;; help window automatically. - -;; (4) A marker (`help-window-point-marker') to move point in the help -;; window to an arbitrary buffer position. (defmacro with-help-window (buffer-or-name &rest body) "Evaluate BODY, send output to BUFFER-OR-NAME and show in a help window. This construct is like `with-temp-buffer-window' but unlike that @@ -1339,9 +1326,6 @@ with-help-window Most of this is done by `help-window-setup', which see." (declare (indent 1) (debug t)) `(progn - ;; Make `help-window-point-marker' point nowhere. The only place - ;; where this should be set to a buffer position is within BODY. - (set-marker help-window-point-marker nil) (let ((temp-buffer-window-setup-hook (cons 'help-mode-setup temp-buffer-window-setup-hook)) (temp-buffer-window-show-hook diff --git a/lisp/window.el b/lisp/window.el index a2335a6798..15a3665cec 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6795,6 +6795,22 @@ window--even-window-sizes (/ (- (window-total-height window) (window-total-height)) 2)) (error nil)))))) +(defvar delayed-window-point nil + "Marker to override default `window-point' in all windows. +`delayed-window-point' is a buffer-local marker you can move to a valid +position of the buffer shown in the window in order to override the standard +positioning mechanism (`point-min') chosen by window displaying functions.") +(make-variable-buffer-local 'delayed-window-point) +(put 'delayed-window-point 'permanent-local t) + +(defvar delayed-window-start nil + "Marker to override default `delayed-window-start' in all windows. +`delayed-window-start' is a buffer-local marker you can move to a valid +position of the buffer shown in the window in order to override the standard +positioning mechanism (`point-min') chosen by window displaying functions.") +(make-variable-buffer-local 'delayed-window-start) +(put 'delayed-window-start 'permanent-local t) + (defun window--display-buffer (buffer window type &optional alist) "Display BUFFER in WINDOW. WINDOW must be a live window chosen by a buffer display action @@ -6913,6 +6929,23 @@ window--display-buffer (when (consp preserve-size) (window-preserve-size window t (car preserve-size)) (window-preserve-size window nil (cdr preserve-size))))) + + (when (local-variable-p 'delayed-window-start buffer) + (let ((window-start (buffer-local-value 'delayed-window-start buffer))) + (when (or (not (markerp window-start)) + (eq (marker-buffer window-start) buffer)) + (set-window-start window window-start))) + (with-current-buffer buffer + (kill-local-variable 'delayed-window-start))) + + (when (local-variable-p 'delayed-window-point buffer) + (let ((window-point (buffer-local-value 'delayed-window-point buffer))) + (when (or (not (markerp window-point)) + (eq (marker-buffer window-point) buffer)) + (set-window-point window window-point))) + (with-current-buffer buffer + (kill-local-variable 'delayed-window-point))) + ;; Assign any window parameters specified. (let ((parameters (cdr (assq 'window-parameters alist)))) (dolist (parameter parameters) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 61c13026cc..5070e4b310 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1017,9 +1017,11 @@ vc-git-print-log ;; If the buffer exists from a previous invocation it might be ;; read-only. (let ((inhibit-read-only t)) - (with-current-buffer - buffer - (apply 'vc-git-command buffer + (with-current-buffer buffer + (insert (propertize "(Type 'd' here to show diffs with working version)\n" + 'font-lock-face 'shadow)) + (setq delayed-window-start (point)) + (apply 'vc-git-command buffer 'async files (append '("log" "--no-color") --=-=-=--