diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-05-05 11:45:35 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-05-05 11:55:00 +0200 |
commit | 1ca1d52e922ef63713ad25f39051e0f946dc11b7 (patch) | |
tree | a05c282e97dc9a4af5c62680b9e979a7f76b9748 | |
parent | 8638c14fbdb5a8ca4ed04c0343f246eed4e22760 (diff) | |
download | org-mode-1ca1d52e922ef63713ad25f39051e0f946dc11b7.tar.gz |
Fix `org-occur' when called non-interactively
* lisp/org.el (org-first-headline-recenter): Check if current buffer is
actually displayed in a window before trying to recenter view.
-rw-r--r-- | lisp/org.el | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index ba240fb..351d024 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7252,9 +7252,11 @@ show that drawer instead." (defun org-first-headline-recenter () "Move cursor to the first headline and recenter the headline." - (goto-char (point-min)) - (when (re-search-forward (concat "^\\(" org-outline-regexp "\\)") nil t) - (set-window-start (selected-window) (point-at-bol)))) + (let ((window (get-buffer-window))) + (when window + (goto-char (point-min)) + (when (re-search-forward (concat "^\\(" org-outline-regexp "\\)") nil t) + (set-window-start window (line-beginning-position)))))) ;;; Saving and restoring visibility |