Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] dirvish interferese with functionality of find-dired #261

Open
3 tasks done
timcharper opened this issue Mar 11, 2024 · 0 comments
Open
3 tasks done

[Bug] dirvish interferese with functionality of find-dired #261

timcharper opened this issue Mar 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@timcharper
Copy link

Thank you for the bug report

  • I am using the latest version of dirvish related packages.
  • I checked CUSTOMIZING|EXTENSIONS.
  • 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 119f9f5), 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 timcharper added the bug Something isn't working label Mar 11, 2024
Thaodan added a commit to Thaodan/dirvish that referenced this issue Jun 15, 2024
Credit goes to @timcharper

Signed-off-by: Björn Bidar <[email protected]>
Thaodan added a commit to Thaodan/dirvish that referenced this issue Dec 15, 2024
Credit goes to @timcharper

Signed-off-by: Björn Bidar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant