wyuenho / all-the-icons-dired

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

setq: Wrong type argument: number-or-marker-p, nil #9

Closed alexei-28 closed 3 years ago

alexei-28 commented 3 years ago

Linux Mint 20

Emacs 27.2

packages: all-the-icons-dired all-the-icons-icons

In my init.el


(require 'all-the-icons-dired)
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)

But when I try to open folder in dired mode I get error:

setq: Wrong type argument: number-or-marker-p, nil

wyuenho commented 3 years ago

Can you turn on debug-on-error in your init file and send me the stack trace? I can't reproduce your error.

alexei-28 commented 3 years ago

Can you turn on debug-on-error in your init file and send me the stack trace? I can't reproduce your error.

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  +(0 nil)
  (setq count (+ count (dired-do-kill-lines nil (if dired-omit-verbose "Omitted %d line%s" "") init-count)))
  (if (not (if linep (let ((inhibit-read-only t) count) (save-excursion (setq count 0) (if nil (progn (message "%s %ss%s..." ... nil ...))) (goto-char (point-min)) (while (not (eobp)) (if (and ... ...) (progn ...)) (forward-line 1)) (if nil (progn (message "%s %s%s %s%s" count nil ... ... ...)))) (and (> count 0) count)) (dired-mark-unmarked-files omit-re nil nil dired-omit-localp (dired-omit-case-fold-p (if (stringp dired-directory) dired-directory (car dired-directory)))))) (if dired-omit-verbose (progn (message "(Nothing to omit)"))) (setq count (+ count (dired-do-kill-lines nil (if dired-omit-verbose "Omitted %d line%s" "") init-count))) (force-mode-line-update))
  (let ((dired-marker-char dired-omit-marker-char)) (if dired-omit-verbose (progn (message "Omitting..."))) (if (not (if linep (let ((inhibit-read-only t) count) (save-excursion (setq count 0) (if nil (progn ...)) (goto-char (point-min)) (while (not ...) (if ... ...) (forward-line 1)) (if nil (progn ...))) (and (> count 0) count)) (dired-mark-unmarked-files omit-re nil nil dired-omit-localp (dired-omit-case-fold-p (if (stringp dired-directory) dired-directory (car dired-directory)))))) (if dired-omit-verbose (progn (message "(Nothing to omit)"))) (setq count (+ count (dired-do-kill-lines nil (if dired-omit-verbose "Omitted %d line%s" "") init-count))) (force-mode-line-update)))
  (if (string= omit-re "") nil (let ((dired-marker-char dired-omit-marker-char)) (if dired-omit-verbose (progn (message "Omitting..."))) (if (not (if linep (let ((inhibit-read-only t) count) (save-excursion (setq count 0) (if nil ...) (goto-char ...) (while ... ... ...) (if nil ...)) (and (> count 0) count)) (dired-mark-unmarked-files omit-re nil nil dired-omit-localp (dired-omit-case-fold-p (if ... dired-directory ...))))) (if dired-omit-verbose (progn (message "(Nothing to omit)"))) (setq count (+ count (dired-do-kill-lines nil (if dired-omit-verbose "Omitted %d line%s" "") init-count))) (force-mode-line-update))))
  (let ((omit-re (or regexp (dired-omit-regexp))) (old-modified-p (buffer-modified-p)) (count (or init-count 0))) (if (string= omit-re "") nil (let ((dired-marker-char dired-omit-marker-char)) (if dired-omit-verbose (progn (message "Omitting..."))) (if (not (if linep (let (... count) (save-excursion ... ... ... ... ...) (and ... count)) (dired-mark-unmarked-files omit-re nil nil dired-omit-localp (dired-omit-case-fold-p ...)))) (if dired-omit-verbose (progn (message "(Nothing to omit)"))) (setq count (+ count (dired-do-kill-lines nil (if dired-omit-verbose "Omitted %d line%s" "") init-count))) (force-mode-line-update)))) (set-buffer-modified-p (and old-modified-p (save-excursion (goto-char (point-min)) (re-search-forward dired-re-mark nil t)))) count)
  (if (and dired-omit-mode (or (called-interactively-p 'interactive) (not dired-omit-size-limit) (< (buffer-size) dired-omit-size-limit) (progn (if dired-omit-verbose (progn (message "Not omitting: directory larger than %d characters." dired-omit-size-limit))) (setq dired-omit-mode nil) nil))) (let ((omit-re (or regexp (dired-omit-regexp))) (old-modified-p (buffer-modified-p)) (count (or init-count 0))) (if (string= omit-re "") nil (let ((dired-marker-char dired-omit-marker-char)) (if dired-omit-verbose (progn (message "Omitting..."))) (if (not (if linep (let ... ... ...) (dired-mark-unmarked-files omit-re nil nil dired-omit-localp ...))) (if dired-omit-verbose (progn (message "(Nothing to omit)"))) (setq count (+ count (dired-do-kill-lines nil ... init-count))) (force-mode-line-update)))) (set-buffer-modified-p (and old-modified-p (save-excursion (goto-char (point-min)) (re-search-forward dired-re-mark nil t)))) count))
  dired-omit-expunge()
  run-hooks(dired-after-readin-hook)
  #f(compiled-function () #<bytecode 0xc215fd>)()
  apply(#f(compiled-function () #<bytecode 0xc215fd>) nil)
  all-the-icons-dired--refresh-advice(#f(compiled-function () #<bytecode 0xc215fd>))
  apply(all-the-icons-dired--refresh-advice #f(compiled-function () #<bytecode 0xc215fd>) nil)
  dired-readin()
  dired-internal-noselect("~/dev/TODO/" nil)
  dired-noselect("~/dev/TODO/")
  run-hook-with-args-until-success(dired-noselect "~/dev/TODO/")
  find-file-noselect("~/dev/TODO/")
  bookmark-default-handler((#("TODO" 0 4 (face nil)) (filename . "~/dev/TODO/") (front-context-string . ".git\n  -rw-r--r-") (rear-context-string . "0K Aug 18 15:21 ") (position . 233)))
  bookmark-handle-bookmark("TODO")
  bookmark--jump-via("TODO" pop-to-buffer-same-window)
  bookmark-jump("TODO")
  funcall-interactively(bookmark-jump "TODO")
  #<subr call-interactively>(bookmark-jump nil nil)
  apply(#<subr call-interactively> bookmark-jump (nil nil))
  (let ((ido-cr+-current-command command)) (apply orig-fun command args))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> bookmark-jump nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (bookmark-jump nil nil))
  call-interactively(bookmark-jump nil nil)
  command-execute(bookmark-jump)
wyuenho commented 3 years ago

This appears to be a dired-omit-mode issue. Can you turn off the mode and see if you can still reproduce it?

wyuenho commented 3 years ago

Actually, this appears to be an issue because you've modified dired-x.el. The line where the error threw is different from https://github.com/emacs-mirror/emacs/blob/emacs-27/lisp/dired-x.el#L595

alexei-28 commented 3 years ago

This appears to be a dired-omit-mode issue. Can you turn off the mode and see if you can still reproduce it?

yes, you are right. After I turn off the dired-omit-mode the problem is gone. And now success show icons in dired mode.

1

Nice. But... I need dired-omit-mode. The reason why I use dired-omit-mode because I hide one dot in the top of buffer in dired mode. Show only two dots.

2

I use pattern (dired-omit-files "^.$")

So the question is: Is it possible to use dired-omit-files AND show icons in dired mode?

wyuenho commented 3 years ago

If you replace the current implementation of all-the-icons-dired--refresh-advice with

(defun all-the-icons-dired--refresh-advice (fn &rest args)
  "Advice function for FN with ARGS."
  (let ((return-value (apply fn args)))
    (when all-the-icons-dired-mode
      (all-the-icons-dired--refresh))
    return-value))

Will it work for you?

alexei-28 commented 3 years ago

If you replace the current implementation of all-the-icons-dired--refresh-advice with

(defun all-the-icons-dired--refresh-advice (fn &rest args)
  "Advice function for FN with ARGS."
  (let ((return-value (apply fn args)))
    (when all-the-icons-dired-mode
      (all-the-icons-dired--refresh))
    return-value))

Will it work for you?

In my init.el

(all-the-icons-dired-mode t)
(add-hook 'dired-mode-hook 'dired-omit-mode)
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)

(defun all-the-icons-dired--refresh-advice (fn &rest args)
  "Advice function for FN with ARGS."
  (let ((return-value (apply fn args)))
    (when all-the-icons-dired-mode
      (all-the-icons-dired--refresh))
    return-value))

And now it's work fine.

1

Moreover it's also work with package dired-subtree. When I press TAB the folder is expand

(global-set-key (kbd "TAB") 'dired-subtree-toggle)

2

wyuenho commented 3 years ago

thanks, I've push it to master, you should see it show up on melpa soon