branch: externals/consult
commit dea4eaf621b6477cca514bfa32c950004fb9cc99
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
File preview: Disable file-name-handler-alist
See https://github.com/minad/consult/discussions/969
---
consult.el | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/consult.el b/consult.el
index eb80eac0a7..e0c82d8337 100644
--- a/consult.el
+++ b/consult.el
@@ -1344,10 +1344,8 @@ ORIG is the original function, HOOKS the arguments."
(defun consult--find-file-temporarily-1 (name)
"Open file NAME, helper function for `consult--find-file-temporarily'."
- (when-let (((not (seq-find (lambda (x) (string-match-p x name))
- consult-preview-excluded-files)))
- ;; file-attributes may throw permission denied error
- (attrs (ignore-errors (file-attributes name)))
+ ;; file-attributes may throw permission denied error
+ (when-let ((attrs (ignore-errors (file-attributes name)))
(size (file-attribute-size attrs)))
(let* ((partial (>= size consult-preview-partial-size))
(buffer (if partial
@@ -1443,7 +1441,8 @@ ORIG is the original function, HOOKS the arguments."
(lambda (&optional name)
(if name
(let ((default-directory dir))
- (setq name (abbreviate-file-name (expand-file-name name)))
+ (setq name (let (file-name-handler-alist)
+ (abbreviate-file-name (expand-file-name name))))
(or
;; Find existing fully initialized buffer (non-previewed). We
have
;; to check for fully initialized buffer before accessing the
@@ -1453,15 +1452,17 @@ ORIG is the original function, HOOKS the arguments."
;; one fully initialized. In this case we prefer the fully
;; initialized buffer. For directories `get-file-buffer' returns
nil,
;; therefore we have to special case Dired.
- (if (and (fboundp 'dired-find-buffer-nocreate) (file-directory-p
name))
- (dired-find-buffer-nocreate name)
- (get-file-buffer name))
+ (let (file-name-handler-alist)
+ (if (and (fboundp 'dired-find-buffer-nocreate)
(file-directory-p name))
+ (dired-find-buffer-nocreate name)
+ (get-file-buffer name)))
;; Find existing previewed buffer. Previewed buffers are not
fully
;; initialized (hooks are delayed) in order to ensure fast
preview.
(cdr (assoc name temporary-buffers))
- ;; Finally, if no existing buffer has been found, open the file
for
- ;; preview.
- (when-let (buf (consult--find-file-temporarily name))
+ ;; If no existing buffer has been found, open the file for
preview.
+ (when-let (((not (seq-find (lambda (x) (string-match-p x name))
+ consult-preview-excluded-files)))
+ (buf (consult--find-file-temporarily name)))
;; Only add new buffer if not already in the list
(unless (or (rassq buf temporary-buffers) (memq buf
orig-buffers))
(add-hook 'window-selection-change-functions hook)