Browse Source

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
Kyle Meyer 4 years ago
parent
commit
591ea3eafb
1 changed files with 4 additions and 2 deletions
  1. 4 2
      lisp/ox.el

+ 4 - 2
lisp/ox.el

@@ -6878,10 +6878,12 @@ back to standard interface."
       (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))))