[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30285: dired-do-chmod vs. top line of dired
From: |
Tino Calancha |
Subject: |
bug#30285: dired-do-chmod vs. top line of dired |
Date: |
Tue, 30 Jan 2018 00:14:00 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:
Thank you for your report.
> M runs the command dired-do-chmod.
> If used on the very top line of dired
> (the directory name,) it says:
> "Change mode of * [0 files] to: "
> which doesn't make a lot of sense.
Agreed.
> emacs-version "25.2.2"
>
> Same problem if used on the second line, (total...).
>
> (Why doesn't it just complain "can't operate on" like it does for the
> third line, ".".)
Following patch just do nothing in these cases. That's OK for me.
Do you prefer to inform the user in this case that there is no file
to change the mode?
--8<-----------------------------cut here---------------start------------->8---
commit 9b10f6ef6fbb3e6c50ffb04b97fc5b0b86d3e559
Author: tino calancha <tino.calancha@gmail.com>
Date: Tue Jan 30 00:02:00 2018 +0900
dired-do-chmod: Avoid unecessary prompt
* lisp/dired-aux.el (dired-do-chmod): Offer to change mode just if
there are any marked files or there is a file at point (Bug#30285).
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 55b68a372e..3868efe0c1 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -361,40 +361,42 @@ dired-do-chmod
Type M-n to pull the file attributes of the file at point
into the minibuffer."
(interactive "P")
- (let* ((files (dired-get-marked-files t arg))
- ;; The source of default file attributes is the file at point.
- (default-file (dired-get-filename t t))
- (modestr (when default-file
- (nth 8 (file-attributes default-file))))
- (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 'chmod arg files default))
- num-modes)
- (cond ((or (equal modes "")
- ;; Use `eq' instead of `equal'
- ;; to detect empty input (bug#12399).
- (eq modes default))
- ;; We used to treat empty input as DEFAULT, but that is not
- ;; such a good idea (Bug#9361).
- (error "No file mode specified"))
- ((string-match-p "^[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)))
+ (when (or (cdr (dired-get-marked-files nil nil nil 'distinguish-1-marked))
+ (dired-get-filename t t))
+ (let* ((files (dired-get-marked-files t arg))
+ ;; The source of default file attributes is the file at point.
+ (default-file (dired-get-filename t t))
+ (modestr (when default-file
+ (nth 8 (file-attributes default-file))))
+ (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 'chmod arg files default))
+ num-modes)
+ (cond ((or (equal modes "")
+ ;; Use `eq' instead of `equal'
+ ;; to detect empty input (bug#12399).
+ (eq modes default))
+ ;; We used to treat empty input as DEFAULT, but that is not
+ ;; such a good idea (Bug#9361).
+ (error "No file mode specified"))
+ ((string-match-p "^[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))))
;;;###autoload
(defun dired-do-chgrp (&optional arg)
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 27.0.50 (build 7, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
Repository revision: ea8c0e1b9eaa6651919fb4e039e3fcb5a1fa73db
- bug#30285: dired-do-chmod vs. top line of dired, 積丹尼 Dan Jacobson, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired,
Tino Calancha <=
- bug#30285: dired-do-chmod vs. top line of dired, Eli Zaretskii, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired, Tino Calancha, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired, Drew Adams, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired, Tino Calancha, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired, Drew Adams, 2018/01/29
- bug#30285: dired-do-chmod vs. top line of dired, Drew Adams, 2018/01/30
- bug#30285: dired-do-chmod vs. top line of dired, Tino Calancha, 2018/01/31
- bug#30285: dired-do-chmod vs. top line of dired, Drew Adams, 2018/01/31
- bug#30285: dired-do-chmod vs. top line of dired, Juri Linkov, 2018/01/31
- bug#30285: dired-do-chmod vs. top line of dired, Drew Adams, 2018/01/31