wyuenho / all-the-icons-dired

Adds dired support to all-the-icons
GNU General Public License v3.0
23 stars 7 forks source link

Symbol’s value as variable is void: file #4

Closed jbsolomon-fw closed 3 years ago

jbsolomon-fw commented 3 years ago

This began happening today, not too sure why yet:

all-the-icons-dired--refresh-advice: Symbol’s value as variable is void: file
wyuenho commented 3 years ago

Do u have a reproduction?

wyuenho commented 3 years ago

Do you have a backtrace? You can get it by turning debug-on-error on.

apc commented 3 years ago

Similar issue here here, maybe? This is what I get when I run dired by turning debug-on-error on after setting up all-the-icons-dired:

Debugger entered--Lisp error: (void-variable file)
  all-the-icons-dired--refresh()
  all-the-icons-dired--refresh-advice(#f(compiled-function () #<bytecode 0x1fe08368ac35>))
  apply(all-the-icons-dired--refresh-advice #f(compiled-function () #<bytecode 0x1fe08368ac35>) nil)
  dired-readin()
  dired-internal-noselect("~/.dotfiles/emacs/.emacs.d/" nil)
  dired-noselect("/Users/apc/.dotfiles/emacs/.emacs.d/" nil)
  #f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x1fe08368aa6d>)("/Users/apc/.dotfiles/emacs/.emacs.d/" nil)
  ls-lisp--dired(#f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x1fe08368aa6d>) "/Users/apc/.dotfiles/emacs/.emacs.d/" nil)
  apply(ls-lisp--dired #f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x1fe08368aa6d>) ("/Users/apc/.dotfiles/emacs/.emacs.d/" nil))
  dired("/Users/apc/.dotfiles/emacs/.emacs.d/" nil)
  funcall-interactively(dired "/Users/apc/.dotfiles/emacs/.emacs.d/" nil)
  call-interactively(dired nil nil)
  command-execute(dired)
wyuenho commented 3 years ago

Can you edebug all-the-icons-dired--refresh and show me which line of that function causes that error? I can't reproduce it and that backtrace shows me nothing useful.

apc commented 3 years ago

Now I'm getting something different:

Debugger entered--Lisp error: (error "save-restriction is a built-in function")
  apply(debug error (error "save-restriction is a built-in function"))
  edebug(error (error "save-restriction is a built-in function"))
  signal(error ("save-restriction is a built-in function"))
  error("%s is a built-in function" save-restriction)
  find-function-library(save-restriction t t)
  find-function-noselect(save-restriction t)
  edebug-instrument-function(save-restriction)
  edebug-instrument-callee()
  edebug-step-in()
  funcall-interactively(edebug-step-in)
  call-interactively(edebug-step-in nil nil)
  command-execute(edebug-step-in)
  recursive-edit()
  #f(compiled-function (arg-mode) #<bytecode 0x1fe0829f5c4d>)(before)
  transient--edebug--recursive-edit(#f(compiled-function (arg-mode) #<bytecode 0x1fe0829f5c4d>) before)
  apply(transient--edebug--recursive-edit #f(compiled-function (arg-mode) #<bytecode 0x1fe0829f5c4d>) before)
  edebug--recursive-edit(before)
  edebug--display-1(nil 0 before)
  edebug--display(nil 0 before)
  edebug-debugger(0 before nil)
  edebug-before(0)
  (edebug-after (edebug-before 0) 13 (save-restriction (edebug-after (edebug-before 1) 2 (widen)) (edebug-after (edebug-before 3) 12 (mapc (edebug-after (edebug-before 4) 5 #'delete-overlay) (edebug-after (edebug-before 6) 11 (all-the-icons-dired--overlays-in (edebug-after (edebug-before 7) 8 (point-min)) (edebug-after (edebug-before 9) 10 (point-max))))))))
  (closure (t) nil (edebug-after (edebug-before 0) 13 (save-restriction (edebug-after (edebug-before 1) 2 (widen)) (edebug-after (edebug-before 3) 12 (mapc (edebug-after (edebug-before 4) 5 #'delete-overlay) (edebug-after (edebug-before 6) 11 (all-the-icons-dired--overlays-in (edebug-after ... 8 ...) (edebug-after ... 10 ...))))))))()
  edebug-default-enter(all-the-icons-dired--remove-all-overlays nil (closure (t) nil (edebug-after (edebug-before 0) 13 (save-restriction (edebug-after (edebug-before 1) 2 (widen)) (edebug-after (edebug-before 3) 12 (mapc (edebug-after (edebug-before 4) 5 #'delete-overlay) (edebug-after (edebug-before 6) 11 (all-the-icons-dired--overlays-in ... ...))))))))
  edebug-enter(all-the-icons-dired--remove-all-overlays nil (closure (t) nil (edebug-after (edebug-before 0) 13 (save-restriction (edebug-after (edebug-before 1) 2 (widen)) (edebug-after (edebug-before 3) 12 (mapc (edebug-after (edebug-before 4) 5 #'delete-overlay) (edebug-after (edebug-before 6) 11 (all-the-icons-dired--overlays-in ... ...))))))))
  all-the-icons-dired--remove-all-overlays()
  (edebug-after (edebug-before 0) 1 (all-the-icons-dired--remove-all-overlays))
  (closure (t) nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--remove-all-overlays)) (edebug-after (edebug-before 2) 65 (save-excursion (edebug-after (edebug-before 3) 6 (goto-char (edebug-after (edebug-before 4) 5 (point-min)))) (edebug-after (edebug-before 7) 64 (while (edebug-after (edebug-before 8) 11 (not (edebug-after ... 10 ...))) (edebug-after (edebug-before 12) 61 (if (edebug-after ... 14 ...) (progn ...))) (edebug-after (edebug-before 62) 63 (forward-line 1)))))))()
  edebug-default-enter(all-the-icons-dired--refresh nil (closure (t) nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--remove-all-overlays)) (edebug-after (edebug-before 2) 65 (save-excursion (edebug-after (edebug-before 3) 6 (goto-char (edebug-after (edebug-before 4) 5 (point-min)))) (edebug-after (edebug-before 7) 64 (while (edebug-after (edebug-before 8) 11 (not ...)) (edebug-after (edebug-before 12) 61 (if ... ...)) (edebug-after (edebug-before 62) 63 (forward-line 1))))))))
  edebug-enter(all-the-icons-dired--refresh nil (closure (t) nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--remove-all-overlays)) (edebug-after (edebug-before 2) 65 (save-excursion (edebug-after (edebug-before 3) 6 (goto-char (edebug-after (edebug-before 4) 5 (point-min)))) (edebug-after (edebug-before 7) 64 (while (edebug-after (edebug-before 8) 11 (not ...)) (edebug-after (edebug-before 12) 61 (if ... ...)) (edebug-after (edebug-before 62) 63 (forward-line 1))))))))
  all-the-icons-dired--refresh()
  (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh))
  (lambda nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh)))()
  edebug-default-enter(edebug-anon26 nil (lambda nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh))))
  edebug-default-enter(edebug-anon26 nil (lambda nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh))))
  edebug-enter(edebug-anon26 nil (lambda nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh))))
  eval((edebug-enter 'edebug-anon26 nil #'(lambda nil (edebug-after (edebug-before 0) 1 (all-the-icons-dired--refresh)))) nil)
  edebug-eval-defun((4))
  apply(edebug-eval-defun (4))
  eval-defun((4))
  funcall-interactively(eval-defun (4))
  call-interactively(eval-defun nil nil)
  command-execute(eval-defun)
wyuenho commented 3 years ago

Step out of all-the-icons-dired--remove-all-overlays ? There's nothing in there relevant anyway

apc commented 3 years ago

I'm afraid you've reached the limit of my knowledge here. If I try to step out (edebug-step-out) from there, how do I continue? Trying edebug-step-in again tells me You must be before a list form. Someday I will learn how to use this, but...

wyuenho commented 3 years ago

At the beginning when you've stopped at all-the-icons-dired--refresh, move your point into the save-excursion block, put it before an open paren, press h, and then keep pressing n until things blow up.

apc commented 3 years ago

Sorry, I think I'm not doing something right here. I first went to the definition of all-the-icons-dired--refresh. After enabling edebug-mode and making sure that edebug-trace is set to a non-nil value, I ran (edebug-Trace-fast-mode) and then edebug-defun with point right before the definition of all-the-icons-dired--refresh. But nothing happens. The buffer `edebug-trace is empty after all of that.

Here's my setup at the moment:

(use-package all-the-icons
  :defer nil)

(use-package all-the-icons-dired
  :after all-the-icons
  :hook (dired-mode . all-the-icons-dired-mode))

After going to a dired buffer I run all-the-icons-dired-mode (why isn't this running automatically? I cannot tell) and get this:

all-the-icons-dired--setup: Symbol’s value as variable is void: file

So I repeated the procedure above with all-the-icons-dired--setup. Now I get this in the *edebug-trace* buffer:

{ defun args: (all-the-icons-dired--setup nil Setup `all-the-icons-dired'. ((edebug-enter 'all-the-icons-dired--setup (list) #'(lambda nil (edebug-after (edebug-before 0) 1 (setq-local tab-width 1)) (edebug-after (edebug-before 2) 11 (pcase-dolist (`(,file ,sym ,fn) (edebug-after 0 3 all-the-icons-dired-advice-alist)) (edebug-after (edebug-before 4) 10 (with-eval-after-load (edebug-after 0 5 file) (edebug-after (edebug-before 6) 9 (advice-add (edebug-after 0 7 sym) :around (edebug-after 0 8 fn))))))) (edebug-after (edebug-before 12) 13 (all-the-icons-dired--refresh))))))
{ defun args: (all-the-icons-dired--setup nil Setup `all-the-icons-dired'. ((edebug-enter 'all-the-icons-dired--setup (list) #'(lambda nil (edebug-after (edebug-before 0) 1 (setq-local tab-width 1)) (edebug-after (edebug-before 2) 11 (pcase-dolist (`(,file ,sym ,fn) (edebug-after 0 3 all-the-icons-dired-advice-alist)) (edebug-after (edebug-before 4) 10 (with-eval-after-load (edebug-after 0 5 file) (edebug-after (edebug-before 6) 9 (advice-add (edebug-after 0 7 sym) :around (edebug-after 0 8 fn))))))) (edebug-after (edebug-before 12) 13 (all-the-icons-dired--refresh))))))
} defun result: (defalias 'all-the-icons-dired--setup #'(lambda nil Setup `all-the-icons-dired'. (edebug-enter 'all-the-icons-dired--setup (list) #'(lambda nil (edebug-after (edebug-before 0) 1 (setq-local tab-width 1)) (edebug-after (edebug-before 2) 11 (pcase-dolist (`(,file ,sym ,fn) (edebug-after 0 3 all-the-icons-dired-advice-alist)) (edebug-after (edebug-before 4) 10 (with-eval-after-load (edebug-after 0 5 file) (edebug-after (edebug-before 6) 9 (advice-add (edebug-after 0 7 sym) :around (edebug-after 0 8 fn))))))) (edebug-after (edebug-before 12) 13 (all-the-icons-dired--refresh))))))

Does this help?

wyuenho commented 3 years ago

edebug-trace traces function calls and prints out a function call order, as the the docstring suggests. I'm not trying to trace function calls, I'm trying step thru the lines of all-the-icons-dired--refresh and see which line inside threw an error.

Here's what you need to do:

  1. Place point any where within the body of all-the-icons-dired--refresh.
  2. C-u C-M-x, this instruments the all-the-icons-dired--refresh for edebug
  3. Turn on all-the-icons-dired-mode in a dired buffer
  4. Place point in front of save-excursion (i.e. |(save-excursion), this is what point must be in front of a list form means.
  5. Press h, so edebug will skip over all-the-icons-dired--remove-all-overlays. It simply continues execution until where you point is. The h you pressed just point a breakpoint in front of a list form.
  6. Keep pressing n until you see a stack trace and report which line blew up and show me the stack trace.
apc commented 3 years ago

Thanks for your patience. I followed all the steps and all that happens is I get this error message:

all-the-icons-dired--setup: Symbol’s value as variable is void: file

I went through all the steps above but within the body of all-the-icons-dired--setup too and I got the same error message.

Now, if I call all-the-icons-dired-mode in a dired buffer and after getting that error message (and having the mode listed among the minor modes enabled in that buffer) I first disable all-the-icons-dired-mode, and run the steps above on all-the-icons-dired--refresh, I see the edebug process kick in and end up seeing how the icons are added one by one to the list on the dired buffer, no errors.

I don't know if this will be helpful, but it sort of tells the story of what I've tried:

Followed link to /Users/apc/.dotfiles/emacs/.emacs.d/init.el
Type "q" to delete help window.
Mark saved where search started
God-Local mode disabled in current buffer
Edebug: all-the-icons-dired--setup
all-the-icons-dired--setup
Edebug mode enabled in current buffer
Quit
Edebug: all-the-icons-dired--setup
Loading /Users/apc/.emacs.d/recentf...done
Cleaning up the recentf list...done (0 removed)
Source file ‘/Users/apc/.emacs.d/elpa/all-the-icons-dired-20210411.1226/all-the-icons-dired.el’ newer than byte-compiled file; using older file
all-the-icons-dired--setup: Symbol’s value as variable is void: file
Quit
All-The-Icons-Dired mode disabled in current buffer
all-the-icons-dired--setup: Symbol’s value as variable is void: file
Quit
Type "q" to delete help window, SPC to scroll help.
Type "q" to delete help window.
Edebug: all-the-icons-dired--refresh
all-the-icons-dired--refresh
Breakpoint set in all-the-icons-dired--refresh
Go...
Break [2 times]

Result: 1 (#o1, #x1, ?\C-a)

Result: 1 (#o1, #x1, ?\C-a)

Result: nil

Result: t

Result: nil

Result: nil

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: nil

Result: nil

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 152 (#o230, #x98)

Result: "."

Result: "."

Result: t

Result: "."

Result: 0.01

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit all-the-icons-dired-dir-face) font-lock-face #1# display (raise 0.012) rear-nonsticky t))
Stop

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit all-the-icons-dired-dir-face) font-lock-face #1# display (raise 0.012) rear-nonsticky t))
Stop

Result: "."

Result: ("." "..")

Result: 152 (#o230, #x98)

Result: "   "

Result: "   "

Result: "   "

Result: "   "

Result: "   "

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 194 (#o302, #xc2)

Result: ".."

Result: ".."

Result: t

Result: ".."

Result: 0.01

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit all-the-icons-dired-dir-face) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit all-the-icons-dired-dir-face) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: ".."

Result: ("..")

Result: 194 (#o302, #xc2)

Result: "   "

Result: "   "

Result: "   "

Result: "   "

Result: "   "

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 237 (#o355, #xed)

Result: "all-the-icons-dired.el"

Result: "all-the-icons-dired.el"

Result: nil

Result: "all-the-icons-dired.el"

Result: 0.01

Result: (:v-adjust 0.01)

Result: t

Result: nil

Result: (:face nil)

Result: (:face nil)

Result: (:v-adjust 0.01 :face nil)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: "all-the-icons-dired.el"

Result: nil

Result: 237 (#o355, #xed)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 299 (#o453, #x12b)

Result: "all-the-icons-dired.elc"

Result: "all-the-icons-dired.elc"

Result: nil

Result: "all-the-icons-dired.elc"

Result: 0.01

Result: (:v-adjust 0.01)

Result: t

Result: dired-ignored

Result: (:face dired-ignored)

Result: (:face dired-ignored)

Result: (:v-adjust 0.01 :face dired-ignored)

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: "all-the-icons-dired.elc"

Result: nil

Result: 299 (#o453, #x12b)

Result: #("" 0 1 (face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "github-octicons" :height 1.2 :inherit dired-ignored) face #1#))

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 362 (#o552, #x16a)

Result: "all-the-icons-dired-autoloads.el"

Result: "all-the-icons-dired-autoloads.el"

Result: nil

Result: "all-the-icons-dired-autoloads.el"

Result: 0.01

Result: (:v-adjust 0.01)

Result: t

Result: nil

Result: (:face nil)

Result: (:face nil)

Result: (:v-adjust 0.01 :face nil)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: "all-the-icons-dired-autoloads.el"

Result: nil

Result: 362 (#o552, #x16a)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: 0 (#o0, #x0, ?\C-@)

Result: nil

Result: t

Result: 434 (#o662, #x1b2)

Result: "all-the-icons-dired-pkg.el"

Result: "all-the-icons-dired-pkg.el"

Result: nil

Result: "all-the-icons-dired-pkg.el"

Result: 0.01

Result: (:v-adjust 0.01)

Result: t

Result: nil

Result: (:face nil)

Result: (:face nil)

Result: (:v-adjust 0.01 :face nil)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: "all-the-icons-dired-pkg.el"

Result: nil

Result: 434 (#o662, #x1b2)

Result: #("" 0 1 (face #1=(:family "file-icons" :height 1.2) font-lock-face #1# display (raise 0.012) rear-nonsticky t))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: #("    " 0 1 (rear-nonsticky t display (raise 0.012) font-lock-face #1=(:family "file-icons" :height 1.2) face #1#))

Result: 0 (#o0, #x0, ?\C-@)

Result: t

Result: nil

Result: nil

Result: nil

All-The-Icons-Dired mode enabled in current buffer
Mark set
wyuenho commented 3 years ago

So the first call to all-the-icons-dired-mode, which was triggered by dired-mode gives you an error, but after dired-mode was loaded in a dired buffer, calling all-the-icons-dired-mode results in no error? Or did it just result in no error when you were debugging it with edebug?

apc commented 3 years ago

The latter. That said: I just upgraded a bunch of packages and the issue seems to have disappeared.

I still cannot get the hook to work and have to manually call all-the-icons-dired-mode, but that's another issue altogether!

Thanks for your help.

apc commented 3 years ago

PS: removing ":after all-the-icons" from my use-package declaration for all-the-icons-dired is sufficient for all-the-icons-dired-mode to be added to dired-mode-hook. Posting this here in case it's helpful to anyone else.

wyuenho commented 3 years ago

okay, feel free to reopen when this issue comes up again

richerve commented 3 years ago

I'm also having the exact same issue and I'm using use-package too. I tried @apc option but that doesn't work, I get the same error as discribed on the title. If I remove the hook and call the mode manually, I still get variable is void: file error but this time in all-the-icons-dired--setup

all-the-icons-dired--setup: Symbol’s value as variable is void: file

apc commented 3 years ago

FWIW, I'm using all-the-icons-20210412.1908 and all-the-icons-dired-20210411.1226. Updating things magically solved the problem.

richerve commented 3 years ago

I use straight as package manager so versions are not directly defined by a date. For the record I'm using the latest commit dd7dd2777e6501b078d2a1a395b4458e5564b606

wyuenho commented 3 years ago

@richerve Can you try to bisect the lines in all-the-icons-dired-advice-alist and see which line may have caused the issue?

richerve commented 3 years ago

@wyuenho I can confirm that the bug was introduced in 07f035d2f6df4f1e840572784a96f5b407a74680 as I checked out 0b929d2b339058289d9239cc965d791ade21318c and on that commit it works. So it should be one the changes done in all-the-icons-dired--refresh

wyuenho commented 3 years ago

That makes no sense to me lol. Does when-let* work differently between you and me?

richerve commented 3 years ago

that was the only "different" thing that I saw. Sorry but I'm not well versed in elisp to understand why. I'm on emacs 27.1

richerve commented 3 years ago

@wyuenho I think I found the issue in all-the-icons-dired--refresh and it's of course not related to how when-let* behaves but on how the logic slightly changed when introducing that.

Originally the code checked if a file was not nil before assigning the icon and continuing the loop:

....
(let ((file (dired-get-filename 'relative 'noerror)))
    (when file
       (let ((icon (if (file-directory-p file)
....

In the new code using when-let*, the assignment to file happens within that statement and according to when-let's emacs docs:

Evaluate each binding in turn, stopping if a binding value is nil.

So I noticed that there's a case when file can be nil and that's at the end of a dired buffer that a new line is added when displayed:

dired_new_line

So when-let* fails immediately after finding that line, therefore making refresh almost useless. But when using when file that doesn't happen because the icon assignment is simply skipped.

In conclusion, it looks like it's probably better to go back to the previous form.

Extra Note: (dired-move-to-filename nil) returns nil on the empty line too.

wyuenho commented 3 years ago

This is what the when-let* macro expands to:

          (let*
              ((file
                (and t
                     (dired-get-filename 'relative 'noerror)))
               (icon
                (and file
                     (if
                         (file-directory-p file)
                         (all-the-icons-icon-for-dir file :face 'all-the-icons-dired-dir-face :v-adjust all-the-icons-dired-v-adjust)
                       (apply 'all-the-icons-icon-for-file file
                              (append
                               `(:v-adjust ,all-the-icons-dired-v-adjust)
                               (when all-the-icons-dired-monochrome
                                 `(:face ,(face-at-point)))))))))
            (if icon
                (if
                    (member file
                            '("." ".."))
                    (all-the-icons-dired--add-overlay
                     (point)
                     "      ")
                  (all-the-icons-dired--add-overlay
                   (point)
                   (concat icon "   ")))))

and is a short-circuiting op, so if file is nil, nothing else gets evaluated. When (dired-move-to-filename nil) returns nil, the while loop just continues to the end of the buffer. Functionally the code before and after the change are exactly the same.

Now, since you are using straight, and I've forced push a commit, can you actually look into the repo straight checked out and see if it was able to update to the latest commit? Also, can you please disassemble all-the-icons-dired--refresh and post the bytecode here?

richerve commented 3 years ago

The previous information I provided about the commits was by checking my copy of straight's repo dir, so yes, I confirmed was the last commit first. Then checking out the commit prior to the change, building and trying.

I'm not familiar in what's the process to disassemble a function, If you give me a hint I can give it a try.

wyuenho commented 3 years ago

M-x disassemble RET all-the-icons-dired--refresh

richerve commented 3 years ago
byte code for all-the-icons-dired--refresh:
  doc:  Display the icons of files in a dired buffer.
  args: nil
0       constant  all-the-icons-dired--remove-all-overlays
1       call      0
2       discard   
3       save-excursion 
4       point-min 
5       goto-char 
6       discard   
7:1     eobp      
8       not       
9       goto-if-nil-else-pop 8
12      constant  dired-move-to-filename
13      constant  nil
14      call      1
15      goto-if-nil 7
18      constant  t
19      varbind   case-fold-search
20      constant  when-let*
21      constant  (file (dired-get-filename 'relative 'noerror))
22      constant  icon
23      constant  file-directory-p
24      varref    file
25      call      1
26      goto-if-nil 2
29      constant  all-the-icons-icon-for-dir
30      varref    file
31      constant  :face
32      constant  all-the-icons-dired-dir-face
33      constant  :v-adjust
34      varref    all-the-icons-dired-v-adjust
35      call      5
36      goto      4
39:2    constant  apply
40      constant  all-the-icons-icon-for-file
41      varref    file
42      constant  append
43      constant  :v-adjust
44      varref    all-the-icons-dired-v-adjust
45      list2     
46      varref    all-the-icons-dired-monochrome
47      goto-if-nil-else-pop 3
50      constant  :face
51      constant  face-at-point
52      call      0
53      list2     
54:3    call      2
55      call      3
56:4    call      1
57      call      1
58      varref    file
59      constant  ("." "..")
60      member    
61      goto-if-nil 5
64      constant  all-the-icons-dired--add-overlay
65      point     
66      constant  "     "
67      call      2
68      goto      6
71:5    constant  all-the-icons-dired--add-overlay
72      point     
73      varref    icon
74      constant  " "
75      concat2   
76      call      2
77:6    call      2
78      discard   
79      unbind    1
80:7    constant  1
81      forward-line 
82      discard   
83      goto      1
86:8    unbind    1
87      return    
wyuenho commented 3 years ago

when-let* did not get expanded and (file (dired-get-filename 'relative 'noerror)) was pasted in as a constant. I don't even know how this got compiled in like this. Did you get a compilation error when you install this?

Regardless, please try adding (require 'subr-x) to the top of the file and recompile and see if it helps.

richerve commented 3 years ago

Adding (require 'subr-x) made it work, now the macro is expanded and there's no failure:

byte code for all-the-icons-dired--refresh:
  doc:  Display the icons of files in a dired buffer.
  args: nil
0       constant  all-the-icons-dired--remove-all-overlays
1       call      0
2       discard   
3       save-excursion 
4       point-min 
5       goto-char 
6       discard   
7:1     eobp      
8       not       
9       goto-if-nil-else-pop 8
12      constant  dired-move-to-filename
13      constant  nil
14      call      1
15      goto-if-nil 7
18      constant  t
19      varbind   case-fold-search
20      constant  dired-get-filename
21      constant  relative
22      constant  noerror
23      call      2
24      dup       
25      goto-if-nil-else-pop 4
28      constant  file-directory-p
29      stack-ref 1
30      call      1
31      goto-if-nil 2
34      constant  all-the-icons-icon-for-dir
35      stack-ref 1
36      constant  :face
37      constant  all-the-icons-dired-dir-face
38      constant  :v-adjust
39      varref    all-the-icons-dired-v-adjust
40      call      5
41      goto      4
44:2    constant  apply
45      constant  all-the-icons-icon-for-file
46      stack-ref 2
47      constant  append
48      constant  :v-adjust
49      varref    all-the-icons-dired-v-adjust
50      list2     
51      varref    all-the-icons-dired-monochrome
52      goto-if-nil-else-pop 3
55      constant  :face
56      constant  face-at-point
57      call      0
58      list2     
59:3    call      2
60      call      3
61:4    dup       
62      goto-if-nil 6
65      stack-ref 1
66      constant  ("." "..")
67      member    
68      goto-if-nil 5
71      constant  all-the-icons-dired--add-overlay
72      point     
73      constant  "     "
74      call      2
75      discard   
76      goto      6
79:5    constant  all-the-icons-dired--add-overlay
80      point     
81      stack-ref 2
82      constant  " "
83      concat2   
84      call      2
85      discard   
86:6    discardN  2
88      unbind    1
89:7    constant  1
90      forward-line 
91      discard   
92      goto      1
95:8    unbind    1
96      return    
wyuenho commented 3 years ago

Thanks for debugging! Should be fixed in 82d09a3

richerve commented 3 years ago

I just noticed that when-let* comes from subr-x. Thanks for helping out, I learned a little bit more of emacs ;)

wyuenho commented 3 years ago

Didn't you get any compilation errors without subr-x?