From 0803cd9abbc4ae8f86ea155385489f706c7c1660 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 27 Oct 2017 21:57:02 +0200 Subject: [PATCH] =?UTF-8?q?[Helm]=20Expand=20=E2=80=98db/important-documen?= =?UTF-8?q?ts-path=E2=80=99=20before=20removing=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site-lisp/db-utils.el | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 0a43a0f..0e59634 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -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." ;; code adapted from `directory-files-recursively’ - (cl-labels ((all-files-in-dir (dir) - (let ((result nil) - (files nil)) - (dolist (file (sort (file-name-all-completions "" dir) - 'string<)) - (unless (eq ?. (aref file 0)) ; omit hidden files - (if (directory-name-p file) - (let* ((leaf (substring file 0 (1- (length file)))) - (full-file (expand-file-name leaf dir))) - ;; Don't follow symlinks to other directories. - (unless (file-symlink-p full-file) - (setq result - (nconc result (all-files-in-dir full-file))))) - (push (cons - (string-remove-prefix db/important-documents-path - (expand-file-name file dir)) - (expand-file-name file dir)) - files)))) - (nconc result (nreverse files))))) - (when (file-directory-p db/important-documents-path) - (all-files-in-dir db/important-documents-path)))) + (let ((db/important-documents-path (expand-file-name db/important-documents-path))) + (cl-labels ((all-files-in-dir (dir) + (let ((result nil) + (files nil)) + (dolist (file (sort (file-name-all-completions "" dir) + 'string<)) + (unless (eq ?. (aref file 0)) ; omit hidden files + (if (directory-name-p file) + (let* ((leaf (substring file 0 (1- (length file)))) + (full-file (expand-file-name leaf dir))) + ;; Don't follow symlinks to other directories. + (unless (file-symlink-p full-file) + (setq result + (nconc result (all-files-in-dir full-file))))) + (push (cons + (string-remove-prefix db/important-documents-path + (expand-file-name file dir)) + (expand-file-name file dir)) + files)))) + (nconc result (nreverse files))))) + (when (file-directory-p db/important-documents-path) + (all-files-in-dir db/important-documents-path))))) (defun db/system-open (path) "Open PATH with default program as defined by the underlying system."