dirvish icon indicating copy to clipboard operation
dirvish copied to clipboard

[Bug] dirvish interferese with functionality of `find-dired`

Open timcharper opened this issue 1 year ago • 0 comments

Thank you for the bug report

  • [X] I am using the latest version of dirvish related packages.
  • [X] I checked CUSTOMIZING|EXTENSIONS.
  • [X] You may also try reproduce the issue using clean environment and minimal configurations with the command emacs -Q.

Bug description

I have a minimal environment configured, loading vanilla dirvish from master (HEAD is 119f9f59a618bb7b476c93e9ab1d7542c5c1df41), and can reproduce the issue.

When using find-dired, and selecting a file (using enter), I get the error:

signal: Wrong type argument: dirvish, nil

The error is in the function dirvish-find-entry-a. Basically, (dirvish-curr) returns nil.

The following patch works around the issue, but is probably not ideal (I believe dirvish is not properly initialized in find-dired buffers?):

diff --git a/dirvish.el b/dirvish.el
index 07c50b8..ad89626 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -644,8 +644,11 @@ buffer, it defaults to filename under the cursor when it is nil."
                                (append (list cmd) args)))))
          (if ex (apply #'start-process "" nil "nohup"
                        (cl-substitute file "%f" ex :test 'string=))
-          (let* ((dv (dirvish-curr)) (fn (nth 4 (dv-type dv))))
-            (if fn (funcall fn) (dirvish-kill dv)))
+          (let* ((dv (dirvish-curr))
+                 (fn (and dv (nth 4 (dv-type dv)))))
+            (if fn
+                (funcall fn)
+              (and dv (dirvish-kill dv))))
            (find-file file))))))

  (defun dirvish-insert-subdir-a (dirname &rest _)

Steps to reproduce

M-x find-dired

(with some args)

try to open a listed file

Expected behavior

Pressing enter should open the file at point

OS

Linux

Emacs Version

29

Emacs Configurations

Vanilla

Error callstack

Debugger entered--Lisp error: (wrong-type-argument dirvish nil)
  signal(wrong-type-argument (dirvish nil))
  (or (progn (and (memq (type-of dv) cl-struct-dirvish-tags) t)) (signal 'wrong-type-argument (list 'dirvish dv)))
  (progn (or (progn (and (memq (type-of dv) cl-struct-dirvish-tags) t)) (signal 'wrong-type-argument (list 'dirvish dv))) (aref dv 1))
  (nth 4 (progn (or (progn (and (memq (type-of dv) cl-struct-dirvish-tags) t)) (signal 'wrong-type-argument (list 'dirvish dv))) (aref dv 1)))
  (let* ((dv (dirvish-curr)) (fn (nth 4 (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... dv))) (aref dv 1))))) (if fn (funcall fn) (dirvish-kill dv)))
  (if ex (apply #'start-process "" nil "nohup" (cl-substitute file "%f" ex :test 'string=)) (let* ((dv (dirvish-curr)) (fn (nth 4 (progn (or (progn ...) (signal ... ...)) (aref dv 1))))) (if fn (funcall fn) (dirvish-kill dv))) (find-file file))
  (let* ((ext (downcase (or (file-name-extension entry) ""))) (file (expand-file-name entry)) (process-connection-type nil) (ex (let* ((--cl-var-- dirvish-open-with-programs) (args nil) (exts nil) (cmd nil) (--cl-flag-- t) --cl-var--) (while (and (consp --cl-var--) (progn (progn ... ... ...) (setq --cl-flag-- ...))) (setq --cl-var-- (cdr --cl-var--))) --cl-var--))) (if ex (apply #'start-process "" nil "nohup" (cl-substitute file "%f" ex :test 'string=)) (let* ((dv (dirvish-curr)) (fn (nth 4 (progn (or ... ...) (aref dv 1))))) (if fn (funcall fn) (dirvish-kill dv))) (find-file file)))
  (if buffer (switch-to-buffer buffer) (let* ((ext (downcase (or (file-name-extension entry) ""))) (file (expand-file-name entry)) (process-connection-type nil) (ex (let* ((--cl-var-- dirvish-open-with-programs) (args nil) (exts nil) (cmd nil) (--cl-flag-- t) --cl-var--) (while (and (consp --cl-var--) (progn ... ...)) (setq --cl-var-- (cdr --cl-var--))) --cl-var--))) (if ex (apply #'start-process "" nil "nohup" (cl-substitute file "%f" ex :test 'string=)) (let* ((dv (dirvish-curr)) (fn (nth 4 (progn ... ...)))) (if fn (funcall fn) (dirvish-kill dv))) (find-file file))))
  (let* ((entry (or entry (dired-get-filename nil t))) (buffer (cond ((string-prefix-p "🔍" entry) (dirvish-fd-find entry)) ((file-directory-p entry) (dired-noselect entry)) ((string-suffix-p "/" entry) (user-error (concat entry " is not a valid directory")))))) (if buffer (switch-to-buffer buffer) (let* ((ext (downcase (or (file-name-extension entry) ""))) (file (expand-file-name entry)) (process-connection-type nil) (ex (let* ((--cl-var-- dirvish-open-with-programs) (args nil) (exts nil) (cmd nil) (--cl-flag-- t) --cl-var--) (while (and ... ...) (setq --cl-var-- ...)) --cl-var--))) (if ex (apply #'start-process "" nil "nohup" (cl-substitute file "%f" ex :test 'string=)) (let* ((dv (dirvish-curr)) (fn (nth 4 ...))) (if fn (funcall fn) (dirvish-kill dv))) (find-file file)))))
  dirvish-find-entry-a()
  apply(dirvish-find-entry-a nil)
  dired-find-file()
  funcall-interactively(dired-find-file)
  command-execute(dired-find-file)

Anything else

Demo of issue

asciicast

dirvish-issue.org

timcharper avatar Mar 11 '24 20:03 timcharper