[Helm] Expand ‘db/important-documents-path’ before removing it

This commit is contained in:
Daniel - 2017-10-27 21:57:02 +02:00
parent 9b8c2ca7a7
commit 0803cd9abb
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 22 additions and 21 deletions

View File

@ -301,27 +301,28 @@ The result will be a list of cons cells, where the car is the
path relative to `db/important-documents and the cdr is the full path relative to `db/important-documents and the cdr is the full
path." path."
;; code adapted from `directory-files-recursively ;; code adapted from `directory-files-recursively
(cl-labels ((all-files-in-dir (dir) (let ((db/important-documents-path (expand-file-name db/important-documents-path)))
(let ((result nil) (cl-labels ((all-files-in-dir (dir)
(files nil)) (let ((result nil)
(dolist (file (sort (file-name-all-completions "" dir) (files nil))
'string<)) (dolist (file (sort (file-name-all-completions "" dir)
(unless (eq ?. (aref file 0)) ; omit hidden files 'string<))
(if (directory-name-p file) (unless (eq ?. (aref file 0)) ; omit hidden files
(let* ((leaf (substring file 0 (1- (length file)))) (if (directory-name-p file)
(full-file (expand-file-name leaf dir))) (let* ((leaf (substring file 0 (1- (length file))))
;; Don't follow symlinks to other directories. (full-file (expand-file-name leaf dir)))
(unless (file-symlink-p full-file) ;; Don't follow symlinks to other directories.
(setq result (unless (file-symlink-p full-file)
(nconc result (all-files-in-dir full-file))))) (setq result
(push (cons (nconc result (all-files-in-dir full-file)))))
(string-remove-prefix db/important-documents-path (push (cons
(expand-file-name file dir)) (string-remove-prefix db/important-documents-path
(expand-file-name file dir)) (expand-file-name file dir))
files)))) (expand-file-name file dir))
(nconc result (nreverse files))))) files))))
(when (file-directory-p db/important-documents-path) (nconc result (nreverse files)))))
(all-files-in-dir db/important-documents-path)))) (when (file-directory-p db/important-documents-path)
(all-files-in-dir db/important-documents-path)))))
(defun db/system-open (path) (defun db/system-open (path)
"Open PATH with default program as defined by the underlying system." "Open PATH with default program as defined by the underlying system."