fix(spacemacs-buffer): fix retrieval org-agenda-files (#15871)
In particular, we only need to call (org-agenda-files) (and hence load org) if the variable org-agenda-files is a single file name. Otherwise we can safely use the value of the said variable directly. This was not handled correctly before this commit.
This commit is contained in:
parent
948fb1389a
commit
d1c42338a7
|
@ -1279,27 +1279,40 @@ SEQ, START and END are the same arguments as for `cl-subseq'"
|
||||||
(insert spacemacs-buffer-list-separator)))
|
(insert spacemacs-buffer-list-separator)))
|
||||||
|
|
||||||
(defun spacemacs-buffer//insert-recent-files (list-size)
|
(defun spacemacs-buffer//insert-recent-files (list-size)
|
||||||
|
"Insert recent file entries to spacemacs-buffer.
|
||||||
|
|
||||||
|
LIST-SIZE is specified in `dotspacemacs-startup-lists' for recent entries."
|
||||||
(unless recentf-mode (recentf-mode))
|
(unless recentf-mode (recentf-mode))
|
||||||
(let ((agenda-files
|
(let (;; we need to remove `org-agenda-files' entries from recent files
|
||||||
(let ((default-directory
|
(agenda-files
|
||||||
(or (bound-and-true-p org-directory) default-directory))
|
(when-let ((default-directory
|
||||||
(files
|
(or (bound-and-true-p org-directory) "~/org"))
|
||||||
(if (or (not (fboundp 'org-agenda-files))
|
(files
|
||||||
(autoloadp (symbol-function 'org-agenda-files)))
|
(when (bound-and-true-p org-agenda-files)
|
||||||
(bound-and-true-p org-agenda-files)
|
(if (listp org-agenda-files)
|
||||||
(org-agenda-files))))
|
;; if it's a list, we take that value directly
|
||||||
|
org-agenda-files
|
||||||
|
;; but if it's a string, it must be file where the list
|
||||||
|
;; of agenda files are stored in that file and we have
|
||||||
|
;;to load `org-agenda' to process the list.
|
||||||
|
(when (y-or-n-p "`org-agenda-files' is a string and \
|
||||||
|
not a list. Load `org' and continue?")
|
||||||
|
(require 'org)
|
||||||
|
(org-agenda-files))))))
|
||||||
(mapcar #'expand-file-name files)))
|
(mapcar #'expand-file-name files)))
|
||||||
(ignore-directory (or (and (boundp 'org-directory)
|
;; we also need to skip sub-directories of `org-directory'
|
||||||
(expand-file-name org-directory))
|
(ignore-directory (or (when (bound-and-true-p org-directory)
|
||||||
|
(expand-file-name org-directory))
|
||||||
""))
|
""))
|
||||||
(recent-files-list))
|
(recent-files-list))
|
||||||
(cl-loop for rfile in recentf-list
|
(cl-loop for rfile in recentf-list
|
||||||
while (length< recent-files-list list-size)
|
while (> list-size 0)
|
||||||
collect (let ((full-path (expand-file-name rfile)))
|
do (let ((full-path (expand-file-name rfile)))
|
||||||
(unless (or (string-prefix-p ignore-directory full-path)
|
(unless (or (string-prefix-p ignore-directory full-path)
|
||||||
(member full-path agenda-files))
|
(member full-path agenda-files))
|
||||||
(add-to-list 'recent-files-list rfile t))))
|
(cl-pushnew rfile recent-files-list)
|
||||||
|
(setq list-size (1- list-size))))
|
||||||
|
finally do (setq recent-files-list (nreverse recent-files-list)))
|
||||||
(when (spacemacs-buffer//insert-file-list
|
(when (spacemacs-buffer//insert-file-list
|
||||||
(spacemacs-buffer||propertize-heading
|
(spacemacs-buffer||propertize-heading
|
||||||
(when dotspacemacs-startup-buffer-show-icons
|
(when dotspacemacs-startup-buffer-show-icons
|
||||||
|
|
Loading…
Reference in New Issue