emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Gustavo Barros <gusbrs.2016@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] ox: Prevent dispatcher from starting in scrolled window
Date: Sat, 27 Jun 2020 01:03:02 +0000	[thread overview]
Message-ID: <87d05l722h.fsf@kyleam.com> (raw)
In-Reply-To: <87sgf4bgu8.fsf@gmail.com>

Gustavo Barros writes:

> On Tue, Jun 09 2020 at 01:48, Kyle Meyer <kyle@kyleam.com> wrote:
>
>> I've tried to trigger it with your minimal configuration and haven't
>> observed the displacement you describe, even when making my frame 
>> height
>> very small.
>
> I was afraid there might be things in the environment which could affect 
> this (DE? distro? monitor size? Emacs configure options? I don't know), 
> but it does reproduce every single time for me with the recipe I 
> provided.

I've managed to trigger it now.  Your picture gave me the hint that
maybe my "making my frame height very small" wasn't the thing to do.
Plus I should have realized that the default-frame-alist in your minimal
configuration probably isn't going to matter on my end because I use a
tiling window manager.  So here's what I could trigger it:

  (setq scroll-margin 1)  ; or anything > 0
  (setq display-buffer-base-action '(display-buffer-at-bottom))

For reasons I don't really understand, if I make my frame height small
(say half my computer screen) the issue goes away.

Anyway, I'm able to resolve the issues I see with this patch.  Can you
confirm that it fixes things on your end?

-- >8 --
Subject: [PATCH] ox: Prevent dispatcher from starting in scrolled window

* lisp/ox.el (org-export--dispatch-ui): Restore buffer position after
inserting text to avoid auto-scrolling at start.

When filling in the dispatch buffer, point ends up at the end of the
buffer, which can cause the buffer to be re-centered on point when
org-fit-window-to-buffer is called, in particular if scroll-margin is
above zero and there is a vertical split.  Avoid this by putting point
where it was before the buffer was refreshed.

Reported-by: Gustavo Barros <gusbrs.2016@gmail.com>
https://orgmode.org/list/87tv3a56vv.fsf@gmail.com
---
 lisp/ox.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 869164737..456dd9bef 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6878,10 +6878,12 @@ (defun org-export--dispatch-ui (options first-key expertp)
       (with-current-buffer "*Org Export Dispatcher*"
 	;; Refresh help.  Maintain display continuity by re-visiting
 	;; previous window position.
-	(let ((pos (window-start)))
+	(let ((pt (point))
+	      (wstart (window-start)))
 	  (erase-buffer)
 	  (insert help)
-	  (set-window-start nil pos)))
+	  (goto-char pt)
+	  (set-window-start nil wstart)))
       (org-fit-window-to-buffer)
       (org-export--dispatch-action
        standard-prompt allowed-keys entries options first-key expertp))))

base-commit: f471768a54d8921ff383516af6a605adc061af30
-- 
2.26.2



  reply	other threads:[~2020-06-27  1:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29  4:56 Bug: Export dispatcher scrolling with hidden top [9.3.6 (9.3.6-17-g389288-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20200224/)] Gustavo Barros
2020-06-02 11:03 ` Gustavo Barros
2020-06-02 11:45   ` Bastien
2020-06-09  4:48   ` Kyle Meyer
2020-06-09 11:48     ` Gustavo Barros
2020-06-27  1:03       ` Kyle Meyer [this message]
2020-06-27  2:00         ` [PATCH] ox: Prevent dispatcher from starting in scrolled window Gustavo Barros
2020-06-27  4:06           ` Kyle Meyer
2020-09-04  8:45             ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d05l722h.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=gusbrs.2016@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).