If you set
--classify in the
dired-actual-switches then it places a
/ at the end of directory names and
* at the end of executables. When you finish renaming the files, these characters are taken literally so every directory it will try to move it inside of itself if it was renamed.
Of note, I have recently switched to emacs 27 head, so I can't remember if this happened in Emacs 26.1 or not when switching.
I tried to use this hacky solution to remove
dired-actual-switches but it doesn't seem to work. Is there a better to do this? Maybe wrapping an advice around wdired instead of using the hooks might be better but not sure how to do that.
(defvar-local jj/dired-classify-enabled nil) (add-hook 'wdired-mode-hook (lambda () (if (string-match "--classify " dired-actual-switches) (setq jj/dired-classify-enabled t)) (setq dired-actual-switches (if (string-match "--classify " dired-actual-switches) (replace-match "" t t dired-actual-switches))))) (add-hook 'dired-mode-hook (lambda () (cond ((eq jj/dired-classify-enabled t) (setq jj/dired-classify-enabled nil) (setq dired-actual-switches (if (string-match "-a " dired-actual-switches) (replace-match "-a --classify" t t dired-actual-switches)))))))
Edit: I noticed the above works to remove the
--classify when entering wdired-mode but I have to call revert-buffer to get it to update properly. I tried putting revert-buffer in the wdired-mode-hook but then I got errors.
Edit2:I've figured out how to do this with defadvice. I'd greatly appreciate someones help with using emacs regex functions and syntax. If someone can modify my answer below for a version using regex instead of just removing
--classify and readding it that would be great and I will accept your answer.
Edit2: Root on my mac seems to not recognize
--classify but only
-F, so if using root for dired best to change the script to use
-F instead of
--classify. This could be due to an old version of gnutils
ls on the system that is possibly fixed in newer versions.