diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-08-09 21:29:22 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-08-09 21:39:18 -0400 |
commit | f6aa5341cb374299922d8423087253b5f222decc (patch) | |
tree | c166135b319d54077a13b877674d72f60133397e | |
parent | 11e874910275c27d77a0293d0c720a92f50e2b0a (diff) | |
download | org-mode-f6aa5341cb374299922d8423087253b5f222decc.tar.gz |
org-cycle-agenda-files: Fix agenda file check
* lisp/org.el (org-cycle-agenda-files): Raise error if there are no
agenda files, as intended. Simplify code.
-rwxr-xr-x | lisp/org.el | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lisp/org.el b/lisp/org.el index abba0f9..8966a89 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18558,18 +18558,15 @@ un-expanded file names." If the current buffer visits an agenda file, find the next one in the list. If the current buffer does not, find the first agenda file." (interactive) - (let* ((fs (org-agenda-files t)) - (files (append fs (list (car fs)))) - (tcf (if buffer-file-name (file-truename buffer-file-name))) + (let* ((fs (or (org-agenda-files t) + (user-error "No agenda files"))) + (files (copy-sequence fs)) + (tcf (and buffer-file-name (file-truename buffer-file-name))) file) - (unless files (user-error "No agenda files")) - (catch 'exit - (while (setq file (pop files)) - (if (equal (file-truename file) tcf) - (when (car files) - (find-file (car files)) - (throw 'exit t)))) - (find-file (car fs))) + (when tcf + (while (and (setq file (pop files)) + (not (equal (file-truename file) tcf))))) + (find-file (car (or files fs))) (if (buffer-base-buffer) (org-pop-to-buffer-same-window (buffer-base-buffer))))) (defun org-agenda-file-to-front (&optional to-end) |