瀏覽代碼

org-agenda: Call `recenter' only if buffer has a window

* lisp/org-agenda.el (org-agenda-list): Condition the call to
  `recenter` only when the buffer has a window associated.

This permit to call `org-agenda-list` in a `with-temp-buffer` like
below:

(with-temp-buffer
  (let ((org-agenda-sticky nil)
        (org-agenda-buffer-tmp-name (buffer-name)))
    (org-agenda-list 1)
    (buffer-string))
Pierre Téchoueyres 7 年之前
父節點
當前提交
befc92b9c0
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      lisp/org-agenda.el

+ 3 - 2
lisp/org-agenda.el

@@ -4261,8 +4261,9 @@ items if they have an hour specification like [h]h:mm."
 	  (insert tbl)))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
-      (unless (and (pos-visible-in-window-p (point-min))
-		   (pos-visible-in-window-p (point-max)))
+      (unless (or (not (get-buffer-window))
+		  (and (pos-visible-in-window-p (point-min))
+		       (pos-visible-in-window-p (point-max))))
 	(goto-char (1- (point-max)))
 	(recenter -1)
 	(if (not (pos-visible-in-window-p (or start-pos 1)))