Subject: bug#11687: 24.1; (wrong-type-argument stringp nil) for `dired-do-chmod' (actually, `dired-do-uncache')

From: Juri Linkov <[email-masked]>
Date: Sun, 30 Sep 2012 20:56:10 +0300

> I did not see this with emacs -Q, but this is what I saw:
>
> I marked some files in Dired, then did `dired-do-chmod'.  At the prompt
> I entered "a-w".  This is the backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> * find-file-name-handler(nil dired-uncache)
> * (let ((handler (find-file-name-handler dir (quote dired-uncache)))) (if
> handler (funcall handler (quote dired-uncache) dir)))
> * dired-uncache(nil)
> * (if (and test-for-subdir (dired-get-subdir)) (let* ((dir (dired-get-subdir))
> (switches (cdr (assoc-string dir dired-switches-alist)))) (dired-insert-subdir
> dir (when arg (read-string "Switches for listing: " (or switches
> dired-subdir-switches dired-actual-switches))))) (message "Redisplaying...")
> (dired-uncache (if (consp dired-directory) (car dired-directory)
> dired-directory)) (dired-map-over-marks (let ((fname (dired-get-filename))
> (dired-after-readin-hook nil)) (message "Redisplaying... %s" fname)
> (dired-update-file-line fname)) arg) (run-hooks (quote dired-after-readin-hook))
> (dired-move-to-filename) (message "Redisplaying...done"))
> * dired-do-redisplay(nil)
> * (let* ((files (dired-get-marked-files t arg)) (modestr (and (stringp (car
> files)) (nth 8 (file-attributes (car files))))) (default (and (stringp modestr)
> (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
> (replace-regexp-in-string "-" "" (format "u=%s,g=%s,o=%s" (match-string 1
> modestr) (match-string 2 modestr) (match-string 3 modestr))))) (modes
> (dired-mark-read-string "Change mode of %s to: " nil (quote chmod) arg files
> default)) num-modes) (cond ((equal modes "") (error "No file mode specified"))
> ((string-match "^[0-7]+" modes) (setq num-modes (string-to-number modes 8))))
> (dolist (file files) (set-file-modes file (if num-modes num-modes
> (file-modes-symbolic-to-number modes (file-modes file))))) (dired-do-redisplay
> arg))
>   dired-do-chmod(nil)
> * call-interactively(dired-do-chmod nil nil)

This bug can happen when you do `dired-do-chmod' on a non-Dired buffer
(it calls `dired-do-redisplay' that fails when called not in Dired).
If you can't reproduce this bug, it should be closed as notabug.