alexluigit / dirvish

A polished Dired with batteries included.
GNU General Public License v3.0
820 stars 46 forks source link

[Feature Request] dirvish-dired-noselect-a supports list as first argument #179

Open dvzubarev opened 1 year ago

dvzubarev commented 1 year ago

Is your feature request related to a problem? Please describe. I was trying to use embark-export with results of consult-find command. It resulted in an error:

Debugger entered--Lisp error: (wrong-type-argument stringp ("/home/denin/.emacs.d/.local/straight/repos/dirvish..." "EXTENSIONS.org"))
  dirvish-dired-noselect-a(#f(compiled-function (dir-or-list &optional switches) "Like `dired' but return the Dired buffer as value, do not select it." #<bytecode 0x15e7e8ce443ced1a>) ("/home/denin/.emacs.d/.local/straight/repos/dirvish..." "EXTENSIONS.org"))
  apply(dirvish-dired-noselect-a #f(compiled-function (dir-or-list &optional switches) "Like `dired' but return the Dired buffer as value, do not select it." #<bytecode 0x15e7e8ce443ced1a>) ("/home/denin/.emacs.d/.local/straight/repos/dirvish..." "EXTENSIONS.org"))
  dired-noselect(("/home/denin/.emacs.d/.local/straight/repos/dirvish..." "EXTENSIONS.org"))
  embark-export-dired(("~/.emacs.d/.local/straight/repos/dirvish/docs/EXTE..."))
  embark-export()

Describe the solution you'd like In the documentation for dired-noselect the first argument is named DIR-OR-LIST. And in the documentation of dired is stated that the first argument may be a list:

If DIRNAME is a cons, its first element is taken as the directory name
and the rest as an explicit list of files to make directory entries for.

It would be good if dirvish supports dired API, so it can work with thirdparty packages

Describe alternatives you've considered

Additional context

andersjohansson commented 1 year ago

Yes, I'd rather consider this a bug, since it breaks the expected functionality of in-build and other packages.

karthink commented 1 year ago

Until there's a better solution, here's a dirty hack to keep using embark-export with dirvish:

(advice-add 'dirvish-dired-noselect-a
            :before-until
            (defun my/dirvish-dired-noselect-on-lists (&rest args)
              (and (listp (cadr args))
                  (apply (car args) (cdr args)))))

Dirty since we're advising an advice function to unadvise the original function (dired-noselect) under certain conditions. :)