emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 3c0da4897b: Revert "Introduce pure variant of a


From: ELPA Syncer
Subject: [elpa] externals/consult 3c0da4897b: Revert "Introduce pure variant of abbreviate-file-name (Fix #766)"
Date: Tue, 14 Mar 2023 12:57:35 -0400 (EDT)

branch: externals/consult
commit 3c0da4897b95f07ae6d49adab43a1a27e4dbee1b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Revert "Introduce pure variant of abbreviate-file-name (Fix #766)"
    
    This reverts commit 95f65c56daadcfa0c4755c4fcd3c813b26706433.
---
 consult.el | 59 +++++++++++++++++++++--------------------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)

diff --git a/consult.el b/consult.el
index 0c93b3628e..856b6bde4d 100644
--- a/consult.el
+++ b/consult.el
@@ -721,22 +721,6 @@ The line beginning/ending BEG/END is bound in BODY."
                             (kill-local-variable ',(cdr x))))
                        local)))))))
 
-(defvar consult--abbreviate-file-name-pure nil)
-(defun consult--abbreviate-file-name-pure (name)
-  "Return abbreviate file NAME.
-This function is a pure variant of `abbreviate-file-name', which
-does access the file system.  This is important if we rely on the
-operation being fast, even for remote paths or paths on network
-file systems."
-  (save-match-data
-    (let (case-fold-search) ;; Assume that file system is case sensitive.
-      (setq name (directory-abbrev-apply name))
-      (let ((home (with-memoization consult--abbreviate-file-name-pure
-                    (directory-abbrev-make-regexp (expand-file-name "~")))))
-        (if (string-match home name)
-            (concat "~" (substring name (match-beginning 1)))
-          name)))))
-
 (defun consult--left-truncate-file (file)
   "Return abbreviated file name of FILE for use in `completing-read' prompt."
   (save-match-data
@@ -3687,7 +3671,8 @@ narrowing and the settings `consult-goto-line-numbers' and
   (find-file
    (consult--read
     (or
-     (mapcar #'consult--abbreviate-file-name-pure (bound-and-true-p 
recentf-list))
+     (let (file-name-handler-alist) ;; No Tramp slowdown please
+       (mapcar #'abbreviate-file-name (bound-and-true-p recentf-list)))
      (user-error "No recent files, `recentf-mode' is %s"
                  (if recentf-mode "enabled" "disabled")))
     :prompt "Find recent file: "
@@ -4459,22 +4444,21 @@ If NORECORD is non-nil, do not record the buffer switch 
in the buffer list."
             recentf-mode))
     :items
     ,(lambda ()
-       (when-let (root (consult--project-root))
-         (let ((len (length root))
-               (ht (consult--buffer-file-hash))
-               items)
-           (dolist (file (bound-and-true-p recentf-list) (nreverse items))
-             ;; Emacs 29 abbreviates file paths by default, see
-             ;; `recentf-filename-handlers'.  I recommend to set
-             ;; recentf-filename-handlers to nil to avoid any slow down.
-             (unless (eq (aref file 0) ?/)
-               (let (file-name-handler-alist) ;; No Tramp slowdown please.
-                 (setq file (expand-file-name file))))
-             (when (and (not (gethash file ht)) (string-prefix-p root file))
-               (let ((part (substring file len)))
-                 (when (equal part "") (setq part "./"))
-                 (put-text-property 0 1 'multi-category `(file . ,file) part)
-                 (push part items))))))))
+      (when-let (root (consult--project-root))
+        (let ((len (length root))
+              (ht (consult--buffer-file-hash))
+              file-name-handler-alist ;; No Tramp slowdown please.
+              items)
+          (dolist (file (bound-and-true-p recentf-list) (nreverse items))
+            ;; Emacs 29 abbreviates file paths by default, see
+            ;; `recentf-filename-handlers'.
+            (unless (eq (aref file 0) ?/)
+              (setq file (expand-file-name file)))
+            (when (and (not (gethash file ht)) (string-prefix-p root file))
+              (let ((part (substring file len)))
+                (when (equal part "") (setq part "./"))
+                (put-text-property 0 1 'multi-category `(file . ,file) part)
+                (push part items))))))))
   "Project file candidate source for `consult-buffer'.")
 
 (defvar consult--source-hidden-buffer
@@ -4547,16 +4531,15 @@ If NORECORD is non-nil, do not record the buffer switch 
in the buffer list."
     :items
     ,(lambda ()
        (let ((ht (consult--buffer-file-hash))
+             file-name-handler-alist ;; No Tramp slowdown please.
              items)
          (dolist (file (bound-and-true-p recentf-list) (nreverse items))
            ;; Emacs 29 abbreviates file paths by default, see
-           ;; `recentf-filename-handlers'.  I recommend to set
-           ;; `recentf-filename-handlers' to nil to avoid any slow down.
+           ;; `recentf-filename-handlers'.
            (unless (eq (aref file 0) ?/)
-             (let (file-name-handler-alist) ;; No Tramp slowdown please.
-               (setq file (expand-file-name file))))
+             (setq file (expand-file-name file)))
            (unless (gethash file ht)
-             (push (consult--abbreviate-file-name-pure file) items))))))
+             (push (abbreviate-file-name file) items))))))
   "Recent file candidate source for `consult-buffer'.")
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]