unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: 10624@debbugs.gnu.org
Subject: bug#10624: 24.0.92; default value of `dired-do-ch*'
Date: Mon, 17 Sep 2012 02:48:09 +0300	[thread overview]
Message-ID: <871ui1h6e2.fsf@mail.jurta.org> (raw)
In-Reply-To: <567949A5085246DD87365C10B6DF80FA@us.oracle.com> (Drew Adams's message of "Sat, 15 Sep 2012 21:47:00 -0700")

> `T c' or `T M-w' copies the tags from the current-line file.
>
> `T p' or `T C-y' pastes those tags to another current-line file,
> adding them to any existing tags for that file.
>
> `T q' pastes similarly, but replaces any existing tags for the target file.
>
> `T > p' (`T > C-y') and `T > q' do the same pasting thing, but for the marked
> files.

Oh no, a whole prefix map for such an auxiliary feature.

But I like the simplicity of your suggestion #2 - use the attributes of the
file on the current line.  It's implemented in a small patch below:

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2012-09-13 23:42:39 +0000
+++ lisp/dired-aux.el	2012-09-16 23:47:32 +0000
@@ -223,10 +247,17 @@ (defun dired-do-chxxx (attribute-name pr
   ;; OP-SYMBOL is the type of operation (for use in `dired-mark-pop-up').
   ;; ARG describes which files to use, as in `dired-get-marked-files'.
   (let* ((files (dired-get-marked-files t arg))
-	 (default (and (eq op-symbol 'touch)
-		       (stringp (car files))
-		       (format-time-string "%Y%m%d%H%M.%S"
-					   (nth 5 (file-attributes (car files))))))
+	 ;; The source of default file attributes is the file at point.
+	 (default-file (dired-get-filename t))
+	 (default (when default-file
+		    (cond ((eq op-symbol 'touch)
+			   (format-time-string
+			    "%Y%m%d%H%M.%S"
+			    (nth 5 (file-attributes default-file))))
+			  ((eq op-symbol 'chown)
+			   (nth 2 (file-attributes default-file 'string)))
+			  ((eq op-symbol 'chgrp)
+			   (nth 3 (file-attributes default-file 'string))))))
 	 (prompt (concat "Change " attribute-name " of %s to"
 			 (if (eq op-symbol 'touch)
 			     " (default now): "
@@ -263,11 +294,15 @@ (defun dired-do-chxxx (attribute-name pr
 ;;;###autoload
 (defun dired-do-chmod (&optional arg)
   "Change the mode of the marked (or next ARG) files.
-Symbolic modes like `g+w' are allowed."
+Symbolic modes like `g+w' are allowed.
+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))
-	 (modestr (and (stringp (car files))
-		       (nth 8 (file-attributes (car files)))))
+	 ;; The source of default file attributes is the file at point.
+	 (default-file (dired-get-filename t))
+	 (modestr (when default-file
+		    (nth 8 (file-attributes default-file))))
 	 (default
 	   (and (stringp modestr)
 		(string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
@@ -297,7 +335,9 @@ (defun dired-do-chmod (&optional arg)
 
 ;;;###autoload
 (defun dired-do-chgrp (&optional arg)
-  "Change the group of the marked (or next ARG) files."
+  "Change the group of the marked (or next ARG) files.
+Type M-n to pull the file attributes of the file at point
+into the minibuffer."
   (interactive "P")
   (if (memq system-type '(ms-dos windows-nt))
       (error "chgrp not supported on this system"))
@@ -305,7 +345,9 @@ (defun dired-do-chgrp (&optional arg)
 
 ;;;###autoload
 (defun dired-do-chown (&optional arg)
-  "Change the owner of the marked (or next ARG) files."
+  "Change the owner of the marked (or next ARG) files.
+Type M-n to pull the file attributes of the file at point
+into the minibuffer."
   (interactive "P")
   (if (memq system-type '(ms-dos windows-nt))
       (error "chown not supported on this system"))
@@ -314,7 +356,9 @@ (defun dired-do-chown (&optional arg)
 ;;;###autoload
 (defun dired-do-touch (&optional arg)
   "Change the timestamp of the marked (or next ARG) files.
-This calls touch."
+This calls touch.
+Type M-n to pull the file attributes of the file at point
+into the minibuffer."
   (interactive "P")
   (dired-do-chxxx "Timestamp" dired-touch-program 'touch arg))
 





  reply	other threads:[~2012-09-16 23:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 15:35 bug#10624: 24.0.92; default value of `dired-do-ch*' Drew Adams
2012-01-27 16:23 ` Drew Adams
2012-09-14 23:47   ` Juri Linkov
2012-09-15  0:37     ` Drew Adams
2012-09-15 22:50       ` Juri Linkov
2012-09-16  4:47         ` Drew Adams
2012-09-16 23:48           ` Juri Linkov [this message]
2012-09-17  0:39             ` Drew Adams
2012-09-18 23:22             ` Juri Linkov
2012-09-15 22:54       ` Juri Linkov
2012-09-16  4:47         ` Drew Adams
2012-09-16 23:45           ` bug#10624: Dired-marking all files in the region Juri Linkov
2012-11-22  9:49             ` Juri Linkov
2012-11-22 15:27               ` Drew Adams
2012-11-23  7:51                 ` Juri Linkov
2012-11-23 17:12                   ` Drew Adams
2012-11-25  9:16                     ` Juri Linkov
2012-11-25 15:49                       ` Drew Adams
2012-11-25 16:12                         ` Juri Linkov
2012-11-25 17:02                           ` Drew Adams
2012-11-22 15:40               ` Stefan Monnier
2012-11-23  7:59                 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871ui1h6e2.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=10624@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).