all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dired-do-touch
@ 2004-03-20 19:05 Matthew Mundell
  2004-03-21 13:31 ` dired-do-touch Ehud Karni
                   ` (3 more replies)
  0 siblings, 4 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-20 19:05 UTC (permalink / raw)


In Dired "T" could touch the current file with the touch shell
command.


2004-02-08  Matthew Mundell  <matt@mundell.ukfsn.org>

	* dired-aux.el (dired-do-touch): New defun.

	* dired.el: Bind dired-do-touch to T.


===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
retrieving revision 1.272
diff -u -r1.272 dired.el
--- lisp/dired.el	3 Feb 2004 16:55:30 -0000	1.272
+++ lisp/dired.el	20 Mar 2004 14:04:27 -0000
@@ -895,6 +895,7 @@
     (define-key map "Q" 'dired-do-query-replace-regexp)
     (define-key map "R" 'dired-do-rename)
     (define-key map "S" 'dired-do-symlink)
+    (define-key map "T" 'dired-do-touch)
     (define-key map "X" 'dired-do-shell-command)
     (define-key map "Z" 'dired-do-compress)
     (define-key map "!" 'dired-do-shell-command)


===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.114
diff -u -r1.114 dired-aux.el
--- lisp/dired-aux.el	8 Feb 2004 22:38:51 -0000	1.114
+++ lisp/dired-aux.el	20 Mar 2004 15:15:26 -0000
@@ -2135,6 +2135,17 @@
       (backward-delete-char 1))
     (message "%s" (buffer-string))))

+;;;###autoload
+(defun dired-do-touch (file)
+  "Touch the current file with the `touch' program."
+  (interactive (list (dired-get-filename t)))
+  (with-temp-buffer
+    (call-process "touch" nil t t "--" file)
+    (unless (bobp)
+      (when (bolp)
+	(backward-delete-char 1))
+      (message "%s" (buffer-string)))))
+
 (provide 'dired-aux)

 ;;; arch-tag: 4b508de9-a153-423d-8d3f-a1bbd86f4f60

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-20 19:05 dired-do-touch Matthew Mundell
@ 2004-03-21 13:31 ` Ehud Karni
  2004-03-21 18:27   ` dired-do-touch Eli Zaretskii
  2004-03-21 16:50 ` dired-do-touch Eli Zaretskii
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 62+ messages in thread
From: Ehud Karni @ 2004-03-21 13:31 UTC (permalink / raw)
  Cc: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 20 Mar 2004 19:05:40 +0000, Matthew Mundell <matt@mundell.ukfsn.org> wrote:
>
> In Dired "T" could touch the current file with the touch shell
> command.
>
> +(defun dired-do-touch (file)
> +  "Touch the current file with the `touch' program."
> +  (interactive (list (dired-get-filename t)))
> +  (with-temp-buffer
> +    (call-process "touch" nil t t "--" file)
> +    (unless (bobp)
> +      (when (bolp)
> +	(backward-delete-char 1))
> +      (message "%s" (buffer-string)))))

I think it is better to define `dired-do-touch' like the other file
modifying functions in dired-aux (a'la `dired-do-chown/grp/mod').'

Here is my version:

(defun dired-do-touch (&optional arg)
  "touch the marked (or next ARG) files."
  (interactive "P")
  (dired-do-chxxx (concat
                   "date & TIME ("
                   (if (eq 'w32 window-system)
                       "MMDDhhmm[[CC][YY][.ss])"   ;; Windows NT/95 system (20.x)
                       "[[CC][YY]MMDDhhmm.[ss])")) ;; UNIX
                  dired-touch-program 'touch arg))

(defvar dired-touch-program
           (cond
               ((eq system-type 'ms-dos) nil)              ; nil for dos!
               ((eq system-type 'windows-nt) "touch")      ; use Cygwin32 touch
               (t      "touch-t"))                         ; UNIX - script
               "Name of touch command (usually `touch').")

The "touch-t" script is simply "touch -t" .

Ehud.


- --
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQFAXZkiLFvTvpjqOY0RAqTjAJ9ovu0d85vdMLF6cFvCJOI2LT4SLQCghrLr
j6lYQyTTTxi1qS3t66aKTjM=
=LOq+
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-20 19:05 dired-do-touch Matthew Mundell
  2004-03-21 13:31 ` dired-do-touch Ehud Karni
@ 2004-03-21 16:50 ` Eli Zaretskii
  2004-03-21 19:21 ` dired-do-touch Richard Stallman
  2004-03-25 14:54 ` dired-do-touch Juri Linkov
  3 siblings, 0 replies; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-21 16:50 UTC (permalink / raw)
  Cc: emacs-devel

> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Date: 20 Mar 2004 19:05:40 +0000
> 
> In Dired "T" could touch the current file with the touch shell
> command.

Thanks.

I wonder: wouldn't it be better to have an Emacs primitive to do
this, instead of invoking an external program?  For starters, it will
then work on any platform, including those where `touch' is not a
standard part of the OS.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
       [not found] <20040321165848.0DB3C662F8@imf.math.ku.dk>
@ 2004-03-21 18:12 ` Lars Hansen
  2004-03-22 23:45   ` dired-do-touch Matthew Mundell
  0 siblings, 1 reply; 62+ messages in thread
From: Lars Hansen @ 2004-03-21 18:12 UTC (permalink / raw)
  Cc: matt, Kai Grossjohann, Eli Zaretskii

>
>
>I wonder: wouldn't it be better to have an Emacs primitive to do
>this, instead of invoking an external program?  For starters, it will
>then work on any platform, including those where `touch' is not a
>standard part of the OS.
>
A week ago, in the thread "Re: Set modtime of a local file?", I 
suggested to make the existing function set_file_times (in sysdep.c) 
into a lisp primitive because such a primitive is needed in Tramp. This 
primitive could be used by dired-do-touch to obtain independence of 
external programs.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-21 13:31 ` dired-do-touch Ehud Karni
@ 2004-03-21 18:27   ` Eli Zaretskii
  0 siblings, 0 replies; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-21 18:27 UTC (permalink / raw)
  Cc: matt, emacs-devel

> Date: Sun, 21 Mar 2004 15:31:14 +0200
> From: "Ehud Karni" <ehud@unix.mvs.co.il>
> 
>   (dired-do-chxxx (concat
>                    "date & TIME ("
>                    (if (eq 'w32 window-system)

It is IMHO fundamentally wrong to test window-system here, since the
same behavior would be expected from "emacs -nw" running on Windows.
I think you want to look at system-type.

>                        "MMDDhhmm[[CC][YY][.ss])"   ;; Windows NT/95 system (20.x)
>                        "[[CC][YY]MMDDhhmm.[ss])")) ;; UNIX

Why the difference between Windows and Unix?  Doesn't the ported
`touch' accept on Windows the same format as on Unix and GNU systems?

> (defvar dired-touch-program
>            (cond
>                ((eq system-type 'ms-dos) nil)              ; nil for dos!

Why?  A ported `touch' (as part of GNU Fileutils) is available on
MS-DOS.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-20 19:05 dired-do-touch Matthew Mundell
  2004-03-21 13:31 ` dired-do-touch Ehud Karni
  2004-03-21 16:50 ` dired-do-touch Eli Zaretskii
@ 2004-03-21 19:21 ` Richard Stallman
  2004-03-25 14:54 ` dired-do-touch Juri Linkov
  3 siblings, 0 replies; 62+ messages in thread
From: Richard Stallman @ 2004-03-21 19:21 UTC (permalink / raw)
  Cc: emacs-devel

Capital letter Dired commands are supposed to operate
on all the marked files.  It would be a bad idea
to introduce a command which doesn't follow that convention.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-21 18:12 ` dired-do-touch Lars Hansen
@ 2004-03-22 23:45   ` Matthew Mundell
  2004-03-23  6:31     ` dired-do-touch Eli Zaretskii
  0 siblings, 1 reply; 62+ messages in thread
From: Matthew Mundell @ 2004-03-22 23:45 UTC (permalink / raw)


Here's a version of dired-do-touch which operates on the selected
files in the same manner as the other Dired uppercase operations.
This version uses set-file-times, a primitive interface to
set_file_times, to touch the files.

The set-file-times primitive uses lisp_time_argument to get or parse
the time.  This requires the change to editfns.c to provide
lisp_time_argument externally.

Making this change will require the set-file-times file name handler
to be added to the list of handlers in the Elisp reference.

===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
diff -u -r1.114 dired-aux.el
--- lisp/dired-aux.el	8 Feb 2004 22:38:51 -0000	1.114
+++ lisp/dired-aux.el	22 Mar 2004 21:53:58 -0000
@@ -2135,6 +2135,29 @@
       (backward-delete-char 1))
     (message "%s" (buffer-string))))
 
+(defun dired-touch ()
+  "Touch current file.  Return file name on failure, else nil."
+  (let ((file (dired-get-filename))
+	fail)
+    (condition-case err
+	(set-file-times file (current-time))
+      (error (setq fail err)))
+    (if fail
+	(progn
+	  (dired-log "Setting time on `%s' failed:\n%s\n"
+		     file fail)
+	  (dired-make-relative file)))))
+
+;;;###autoload
+(defun dired-do-touch (&optional arg)
+  "Set the selected files' access and mod times to the current time.
+
+With non-zero prefix argument ARG, the command operates on the
+next ARG files.  Otherwise, it operates on all the marked files,
+or the current file if none are marked."
+  (interactive "P")
+  (dired-map-over-marks-check (function dired-touch) arg 'touch nil))
+
 (provide 'dired-aux)
 
 ;;; arch-tag: 4b508de9-a153-423d-8d3f-a1bbd86f4f60

===================================================================
RCS file: /cvsroot/emacs/emacs/src/editfns.c,v
diff -u -r1.368 editfns.c
--- src/editfns.c	2 Mar 2004 21:42:03 -0000	1.368
+++ src/editfns.c	22 Mar 2004 22:01:45 -0000
@@ -73,7 +73,7 @@
 static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *));
 static void update_buffer_properties P_ ((int, int));
 static Lisp_Object region_limit P_ ((int));
-static int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
+int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
 static size_t emacs_memftimeu P_ ((char *, size_t, const char *,
 				   size_t, const struct tm *, int));
 static void general_insert_function P_ ((void (*) (const unsigned char *, int),
@@ -1377,7 +1377,7 @@
 }
 \f
 
-static int
+int
 lisp_time_argument (specified_time, result, usec)
      Lisp_Object specified_time;
      time_t *result;

===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
diff -u -r1.499 fileio.c
--- src/fileio.c	18 Mar 2004 02:58:45 -0000	1.499
+++ src/fileio.c	22 Mar 2004 21:53:23 -0000
@@ -323,6 +323,7 @@
 Lisp_Object Qfile_accessible_directory_p;
 Lisp_Object Qfile_modes;
 Lisp_Object Qset_file_modes;
+Lisp_Object Qset_file_times;
 Lisp_Object Qfile_newer_than_file_p;
 Lisp_Object Qinsert_file_contents;
 Lisp_Object Qwrite_region;
@@ -3438,7 +3439,45 @@
   XSETINT (value, (~ realmask) & 0777);
   return value;
 }
+\f
+DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
+       doc: /* Set access and modification times of file FILENAME.
+If optional second argument TIME is supplied then it is used instead
+of the current time.  TIME must be in the format of
+`current-time'.  */)
+  (filename, time)
+     Lisp_Object filename, time;
+{
+  Lisp_Object absname, encoded_absname;
+  Lisp_Object handler;
+  time_t sec;
+  int usec;
+
+  if (! lisp_time_argument (time, &sec, &usec))
+    error ("Invalid time specification");
+
+  absname = Fexpand_file_name (filename, current_buffer->directory);
+
+  /* If the file name has special constructs in it,
+     call the corresponding file handler.  */
+  handler = Ffind_file_name_handler (absname, Qset_file_times);
+  if (!NILP (handler))
+    return call3 (handler, Qset_file_times, absname, time);
+
+  encoded_absname = ENCODE_FILE (absname);
+
+  {
+    EMACS_TIME t;

+    EMACS_SET_SECS (t, sec);
+    EMACS_SET_USECS (t, usec);
+
+    if (set_file_times (SDATA (encoded_absname), t, t) < 0)
+      report_file_error ("Setting file times", Fcons (absname, Qnil));
+  }
+
+  return Qnil;
+}
 \f
 #ifdef __NetBSD__
 #define unix 42
@@ -6339,6 +6378,7 @@
   Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
   Qfile_modes = intern ("file-modes");
   Qset_file_modes = intern ("set-file-modes");
+  Qset_file_times = intern ("set-file-times");
   Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
   Qinsert_file_contents = intern ("insert-file-contents");
   Qwrite_region = intern ("write-region");
@@ -6372,6 +6412,7 @@
   staticpro (&Qfile_accessible_directory_p);
   staticpro (&Qfile_modes);
   staticpro (&Qset_file_modes);
+  staticpro (&Qset_file_times);
   staticpro (&Qfile_newer_than_file_p);
   staticpro (&Qinsert_file_contents);
   staticpro (&Qwrite_region);
@@ -6595,6 +6636,7 @@
   defsubr (&Sfile_regular_p);
   defsubr (&Sfile_modes);
   defsubr (&Sset_file_modes);
+  defsubr (&Sset_file_times);
   defsubr (&Sset_default_file_modes);
   defsubr (&Sdefault_file_modes);
   defsubr (&Sfile_newer_than_file_p);

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-22 23:45   ` dired-do-touch Matthew Mundell
@ 2004-03-23  6:31     ` Eli Zaretskii
  2004-03-23 21:48       ` dired-do-touch Matthew Mundell
  0 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-23  6:31 UTC (permalink / raw)
  Cc: emacs-devel

> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Date: 22 Mar 2004 23:45:14 +0000
> 
> +    if (set_file_times (SDATA (encoded_absname), t, t) < 0)
> +      report_file_error ("Setting file times", Fcons (absname, Qnil));

I think this will throw an error on Windows if the file is a
directory.  So it would be good to single out that case on DOS_NT
systems.

Otherwise, thanks a lot!

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-23  6:31     ` dired-do-touch Eli Zaretskii
@ 2004-03-23 21:48       ` Matthew Mundell
  2004-03-24  7:11         ` dired-do-touch Eli Zaretskii
  2004-03-25  2:00         ` dired-do-touch Richard Stallman
  0 siblings, 2 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-23 21:48 UTC (permalink / raw)
  Cc: emacs-devel

> Eli Zaretskii <eliz@elta.co.il> writes:
>
> > > From: Matthew Mundell <matt@mundell.ukfsn.org>
> > > Date: 22 Mar 2004 23:45:14 +0000
> > >
> > > +    if (set_file_times (SDATA (encoded_absname), t, t) < 0)
> > > +      report_file_error ("Setting file times", Fcons (absname, Qnil));
> >
> > I think this will throw an error on Windows if the file is a
> > directory.  So it would be good to single out that case on DOS_NT
> > systems.

Does the version below correctly handle the case?

> > Otherwise, thanks a lot!

Thanks.  Here are change logs and the Dired "T" key binding, to go with
yesterday's patches.

2004-03-23  Matthew Mundell  <matt@mundell.ukfsn.org>

	* dired-aux.el (dired-touch, dired-do-touch): New defuns.

    * dired.el: Bind dired-do-touch to T.

===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
diff -u -r1.273 dired.el
--- lisp/dired.el	23 Mar 2004 05:20:11 -0000	1.273
+++ lisp/dired.el	23 Mar 2004 12:17:57 -0000
@@ -909,6 +909,7 @@
     (define-key map "Q" 'dired-do-query-replace-regexp)
     (define-key map "R" 'dired-do-rename)
     (define-key map "S" 'dired-do-symlink)
+    (define-key map "T" 'dired-do-touch)
     (define-key map "X" 'dired-do-shell-command)
     (define-key map "Z" 'dired-do-compress)
     (define-key map "!" 'dired-do-shell-command)


2004-03-23  Matthew Mundell  <matt@mundell.ukfsn.org>

	* fileio.c (Qset_file_times): New variable.
	(Fset_file_times): New function.
    (lisp_time_argument): New declaration.
	(syms_of_fileio): staticpro and intern new variable, defsubr new
	function.

	* editfns.c (lisp_time_argument): Provide externally.


===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
diff -u -r1.499 fileio.c
--- src/fileio.c	18 Mar 2004 02:58:45 -0000	1.499
+++ src/fileio.c	23 Mar 2004 12:56:40 -0000
@@ -323,6 +323,7 @@
 Lisp_Object Qfile_accessible_directory_p;
 Lisp_Object Qfile_modes;
 Lisp_Object Qset_file_modes;
+Lisp_Object Qset_file_times;
 Lisp_Object Qfile_newer_than_file_p;
 Lisp_Object Qinsert_file_contents;
 Lisp_Object Qwrite_region;
@@ -3438,7 +3439,66 @@
   XSETINT (value, (~ realmask) & 0777);
   return value;
 }
+\f
+extern int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
+
+DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
+       doc: /* Set access and modification times of file FILENAME.
+If optional second argument TIME is supplied then it is used instead
+of the current time.  TIME must be in the format of
+`current-time'.  */)
+  (filename, time)
+     Lisp_Object filename, time;
+{
+  Lisp_Object absname, encoded_absname;
+  Lisp_Object handler;
+  time_t sec;
+  int usec;
+
+  if (! lisp_time_argument (time, &sec, &usec))
+    error ("Invalid time specification");
+
+  absname = Fexpand_file_name (filename, current_buffer->directory);
+
+  /* If the file name has special constructs in it,
+     call the corresponding file handler.  */
+  handler = Ffind_file_name_handler (absname, Qset_file_times);
+  if (!NILP (handler))
+    return call3 (handler, Qset_file_times, absname, time);
+
+  encoded_absname = ENCODE_FILE (absname);
+
+  {
+    EMACS_TIME t;
+
+    EMACS_SET_SECS (t, sec);
+    EMACS_SET_USECS (t, usec);
+
+#ifdef WINDOWSNT
+    {
+      DWORD attributes;
+      Lisp_Object filename;
+      /* Ensure file is writable while its modified time is set.  */
+      filename = SDATA (encoded_absname);
+      attributes = GetFileAttributes (filename);
+      SetFileAttributes (filename, attributes & ~FILE_ATTRIBUTE_READONLY);
+      if (set_file_times (filename, t, t))
+	{
+	  /* Restore original attributes.  */
+	  SetFileAttributes (filename, attributes);
+	  report_file_error ("Setting file times", Fcons (absname, Qnil));
+	}
+      /* Restore original attributes.  */
+      SetFileAttributes (filename, attributes);
+    }
+#else
+    if (set_file_times (SDATA (encoded_absname), t, t))
+      report_file_error ("Setting file times", Fcons (absname, Qnil));
+#endif
+  }

+  return Qnil;
+}
 \f
 #ifdef __NetBSD__
 #define unix 42
@@ -6339,6 +6399,7 @@
   Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
   Qfile_modes = intern ("file-modes");
   Qset_file_modes = intern ("set-file-modes");
+  Qset_file_times = intern ("set-file-times");
   Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
   Qinsert_file_contents = intern ("insert-file-contents");
   Qwrite_region = intern ("write-region");
@@ -6372,6 +6433,7 @@
   staticpro (&Qfile_accessible_directory_p);
   staticpro (&Qfile_modes);
   staticpro (&Qset_file_modes);
+  staticpro (&Qset_file_times);
   staticpro (&Qfile_newer_than_file_p);
   staticpro (&Qinsert_file_contents);
   staticpro (&Qwrite_region);
@@ -6595,6 +6657,7 @@
   defsubr (&Sfile_regular_p);
   defsubr (&Sfile_modes);
   defsubr (&Sset_file_modes);
+  defsubr (&Sset_file_times);
   defsubr (&Sset_default_file_modes);
   defsubr (&Sdefault_file_modes);
   defsubr (&Sfile_newer_than_file_p);

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-23 21:48       ` dired-do-touch Matthew Mundell
@ 2004-03-24  7:11         ` Eli Zaretskii
  2004-03-24 10:57           ` dired-do-touch Kim F. Storm
  2004-03-24 20:57           ` dired-do-touch Matthew Mundell
  2004-03-25  2:00         ` dired-do-touch Richard Stallman
  1 sibling, 2 replies; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-24  7:11 UTC (permalink / raw)
  Cc: emacs-devel

> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Date: 23 Mar 2004 21:48:19 +0000
> 
> > > > +    if (set_file_times (SDATA (encoded_absname), t, t) < 0)
> > > > +      report_file_error ("Setting file times", Fcons (absname, Qnil));
> > >
> > > I think this will throw an error on Windows if the file is a
> > > directory.  So it would be good to single out that case on DOS_NT
> > > systems.
> 
> Does the version below correctly handle the case?

I don't know, but that was not what I had in mind.  Whether a
directory is or isn't writable is not an issue, to the best of my
knowledge (IIRC, Windows ignores the read-only attribute when it
handles directories, so, e.g., you can delete such a directory
regardless).

The issue is that Windows doesn't let you modify the directory's time
stamp at all.  So on DOS_NT systems we should either refrain from
trying to change the time stamp of directories at all and print
something like "Cannot set time stamp of directories on this system",
or else more-or-less silently ignore errors in this function for
directories on such systems.  The second alternative is probably
slightly better, since this is a primitive function that can be called
from deep inside some complex command, where signalling an error might
disrupt the rest of processing.

FWIW, the DOS/Windows port of the `touch' utility doesn't print any
error message if invoked on a directory, it silently fails.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24  7:11         ` dired-do-touch Eli Zaretskii
@ 2004-03-24 10:57           ` Kim F. Storm
  2004-03-24 11:10             ` dired-do-touch Eli Zaretskii
  2004-03-24 20:57           ` dired-do-touch Matthew Mundell
  1 sibling, 1 reply; 62+ messages in thread
From: Kim F. Storm @ 2004-03-24 10:57 UTC (permalink / raw)
  Cc: Matthew Mundell, emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:

>    else more-or-less silently ignore errors in this function for
> directories on such systems.  The second alternative is probably
> slightly better, since this is a primitive function that can be called
> from deep inside some complex command, where signalling an error might
> disrupt the rest of processing.

I think that this is acceptable behaviour on such systems.

Maybe the function could simply return t if time was modified, nil
otherwise.  Then it would be easier for a programmer to change his
code to deal with systems where the call fails.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24 10:57           ` dired-do-touch Kim F. Storm
@ 2004-03-24 11:10             ` Eli Zaretskii
  2004-03-24 12:22               ` dired-do-touch Kim F. Storm
  0 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-24 11:10 UTC (permalink / raw)
  Cc: matt, emacs-devel

> From: storm@cua.dk (Kim F. Storm)
> Date: 24 Mar 2004 11:57:48 +0100
> 
> >    else more-or-less silently ignore errors in this function for
> > directories on such systems.  The second alternative is probably
> > slightly better, since this is a primitive function that can be called
> > from deep inside some complex command, where signalling an error might
> > disrupt the rest of processing.
> 
> I think that this is acceptable behaviour on such systems.

What is? to signal an error?

> Maybe the function could simply return t if time was modified, nil
> otherwise.  Then it would be easier for a programmer to change his
> code to deal with systems where the call fails.

Yes, a good idea, IMHO.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24 11:10             ` dired-do-touch Eli Zaretskii
@ 2004-03-24 12:22               ` Kim F. Storm
  2004-03-24 21:59                 ` dired-do-touch Matthew Mundell
  0 siblings, 1 reply; 62+ messages in thread
From: Kim F. Storm @ 2004-03-24 12:22 UTC (permalink / raw)
  Cc: matt, emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:

> > I think that this is acceptable behaviour on such systems.
> 
> What is? to signal an error?

Ups -- no, that's not what I meant.  

Let me try again:

>    else more-or-less silently ignore errors in this function for
> directories on such systems.

I think that this is acceptable behaviour on such systems.


> > Maybe the function could simply return t if time was modified, nil
> > otherwise.  Then it would be easier for a programmer to change his
> > code to deal with systems where the call fails.
> 
> Yes, a good idea, IMHO.

So let's do it that way.  Matt?

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24  7:11         ` dired-do-touch Eli Zaretskii
  2004-03-24 10:57           ` dired-do-touch Kim F. Storm
@ 2004-03-24 20:57           ` Matthew Mundell
  1 sibling, 0 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-24 20:57 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:

> > From: Matthew Mundell <matt@mundell.ukfsn.org>
> > Date: 23 Mar 2004 21:48:19 +0000
> >
> > > > > +    if (set_file_times (SDATA (encoded_absname), t, t) < 0)
> > > > > +      report_file_error ("Setting file times", Fcons (absname, Qnil));
> > > >
> > > > I think this will throw an error on Windows if the file is a
> > > > directory.  So it would be good to single out that case on DOS_NT
> > > > systems.
> >
> > Does the version below correctly handle the case?
>
> I don't know, but that was not what I had in mind.  Whether a
> directory is or isn't writable is not an issue, to the best of my
> knowledge (IIRC, Windows ignores the read-only attribute when it
> handles directories, so, e.g., you can delete such a directory
> regardless).
>
> The issue is that Windows doesn't let you modify the directory's time
> stamp at all.  So on DOS_NT systems we should either refrain from
> trying to change the time stamp of directories at all and print
> something like "Cannot set time stamp of directories on this system",
> or else more-or-less silently ignore errors in this function for
> directories on such systems.  The second alternative is probably
> slightly better, since this is a primitive function that can be called
> from deep inside some complex command, where signalling an error might
> disrupt the rest of processing.
>
> FWIW, the DOS/Windows port of the `touch' utility doesn't print any
> error message if invoked on a directory, it silently fails.

I had copied the use of set_file_times in the WINDOWS_NT portion of
copy-file, which is also in fileio.c.  I see now that copy-file only
sets the time when given a prefix argument, and that the doc notes
that this will only work on some systems.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24 12:22               ` dired-do-touch Kim F. Storm
@ 2004-03-24 21:59                 ` Matthew Mundell
  2004-03-25  7:10                   ` dired-do-touch Eli Zaretskii
  0 siblings, 1 reply; 62+ messages in thread
From: Matthew Mundell @ 2004-03-24 21:59 UTC (permalink / raw)
  Cc: emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> Eli Zaretskii <eliz@elta.co.il> writes:
>
> > > I think that this is acceptable behaviour on such systems.
> >
> > What is? to signal an error?
>
> Ups -- no, that's not what I meant.
>
> Let me try again:
>
> >    else more-or-less silently ignore errors in this function for
> > directories on such systems.
>
> I think that this is acceptable behaviour on such systems.
>
>
> > > Maybe the function could simply return t if time was modified, nil
> > > otherwise.  Then it would be easier for a programmer to change his
> > > code to deal with systems where the call fails.
> >
> > Yes, a good idea, IMHO.
>
> So let's do it that way.  Matt?

Silently ignoring the error for directories on those systems sounds
like the right approach.  Here is the primitive.  Does the change look
OK?  It needs to be tried on those systems.

===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
diff -u -r1.499 fileio.c
-- src/fileio.c	18 Mar 2004 02:58:45 -0000	1.499
++ src/fileio.c	24 Mar 2004 14:51:31 -0000
@@ -323,6 +323,7 @@
Lisp_Object Qfile_accessible_directory_p;
Lisp_Object Qfile_modes;
Lisp_Object Qset_file_modes;
Lisp_Object Qset_file_times;
Lisp_Object Qfile_newer_than_file_p;
Lisp_Object Qinsert_file_contents;
Lisp_Object Qwrite_region;
@@ -3438,7 +3439,59 @@
  XSETINT (value, (~ realmask) & 0777);
  return value;
}
\f
extern int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));

DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
       doc: /* Set times of file FILENAME to TIME.
Set both access and modification times.
Return t on success, else nil.
Use the current time if TIME is nil.  TIME is in the format of
`current-time'. */)
  (filename, time)
     Lisp_Object filename, time;
{
  Lisp_Object absname, encoded_absname;
  Lisp_Object handler;
  time_t sec;
  int usec;

  if (! lisp_time_argument (time, &sec, &usec))
    error ("Invalid time specification");

  absname = Fexpand_file_name (filename, current_buffer->directory);

  /* If the file name has special constructs in it,
     call the corresponding file handler.  */
  handler = Ffind_file_name_handler (absname, Qset_file_times);
  if (!NILP (handler))
    return call3 (handler, Qset_file_times, absname, time);

  encoded_absname = ENCODE_FILE (absname);

  {
    EMACS_TIME t;

    EMACS_SET_SECS (t, sec);
    EMACS_SET_USECS (t, usec);

    if (set_file_times (SDATA (encoded_absname), t, t))
      {
#ifdef DOS_NT
        struct stat st;

        /* Setting times on a directory always fails.  */
        if (stat (SDATA (encoded_absname), &st) == 0
            && (st.st_mode & S_IFMT) == S_IFDIR)
          return Qnil;
#endif
        report_file_error ("Setting file times", Fcons (absname, Qnil));
        return Qnil;
      }
  }

  return Qt;
}
\f
#ifdef __NetBSD__
#define unix 42
@@ -6339,6 +6392,7 @@
  Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
  Qfile_modes = intern ("file-modes");
  Qset_file_modes = intern ("set-file-modes");
  Qset_file_times = intern ("set-file-times");
  Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
  Qinsert_file_contents = intern ("insert-file-contents");
  Qwrite_region = intern ("write-region");
@@ -6372,6 +6426,7 @@
  staticpro (&Qfile_accessible_directory_p);
  staticpro (&Qfile_modes);
  staticpro (&Qset_file_modes);
  staticpro (&Qset_file_times);
  staticpro (&Qfile_newer_than_file_p);
  staticpro (&Qinsert_file_contents);
  staticpro (&Qwrite_region);
@@ -6595,6 +6650,7 @@
  defsubr (&Sfile_regular_p);
  defsubr (&Sfile_modes);
  defsubr (&Sset_file_modes);
  defsubr (&Sset_file_times);
  defsubr (&Sset_default_file_modes);
  defsubr (&Sdefault_file_modes);
  defsubr (&Sfile_newer_than_file_p);

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-23 21:48       ` dired-do-touch Matthew Mundell
  2004-03-24  7:11         ` dired-do-touch Eli Zaretskii
@ 2004-03-25  2:00         ` Richard Stallman
  2004-03-26 18:31           ` dired-do-touch Matthew Mundell
  1 sibling, 1 reply; 62+ messages in thread
From: Richard Stallman @ 2004-03-25  2:00 UTC (permalink / raw)
  Cc: eliz, emacs-devel

The changes in dired.el and fileio.c look ok to me.
The changes in dired-aux.el were omitted.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-24 21:59                 ` dired-do-touch Matthew Mundell
@ 2004-03-25  7:10                   ` Eli Zaretskii
  0 siblings, 0 replies; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-25  7:10 UTC (permalink / raw)
  Cc: emacs-devel, storm

> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Date: 24 Mar 2004 21:59:50 +0000
> 
> Silently ignoring the error for directories on those systems sounds
> like the right approach.  Here is the primitive.  Does the change look
> OK?  It needs to be tried on those systems.

The change looks okay, although I didn't have an opportunity to test
it yet.

I think it can go in; later, if there are problems on non-Posix
platforms, someone will fix them.

Thanks!

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-20 19:05 dired-do-touch Matthew Mundell
                   ` (2 preceding siblings ...)
  2004-03-21 19:21 ` dired-do-touch Richard Stallman
@ 2004-03-25 14:54 ` Juri Linkov
  2004-03-25 21:07   ` dired-do-touch Juri Linkov
  2004-03-27  5:52   ` dired-do-touch Richard Stallman
  3 siblings, 2 replies; 62+ messages in thread
From: Juri Linkov @ 2004-03-25 14:54 UTC (permalink / raw)
  Cc: emacs-devel

I am very happy with the following patch.  So if you want to use
primitive functions instead of external programs, please make them
possible to co-exist with useful features I implemented below: the
default input string guessing for chmod, chown, chgrp and touch.

And if you want to achieve independence of external programs
then other commands should be changed to use primitives too:
dired-do-chmod, dired-do-chown, dired-do-chgrp.

Index: emacs/lisp/dired.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
retrieving revision 1.276
diff -c -r1.276 dired.el
*** emacs/lisp/dired.el	25 Mar 2004 10:40:59 -0000	1.276
--- emacs/lisp/dired.el	25 Mar 2004 14:30:37 -0000
***************
*** 79,84 ****
--- 79,87 ----
  (defvar dired-chmod-program "chmod"
    "Name of chmod command (usually `chmod').")
  
+ (defvar dired-touch-program "touch"
+   "Name of touch command (usually `touch').")
+ 
  ;;;###autoload
  (defcustom dired-ls-F-marks-symlinks nil
    "*Informs dired about how `ls -lF' marks symbolic links.
***************
*** 919,924 ****
--- 922,928 ----
      (define-key map "Q" 'dired-do-query-replace-regexp)
      (define-key map "R" 'dired-do-rename)
      (define-key map "S" 'dired-do-symlink)
+     (define-key map "T" 'dired-do-touch)
      (define-key map "X" 'dired-do-shell-command)
      (define-key map "Z" 'dired-do-compress)
      (define-key map "!" 'dired-do-shell-command)
***************
*** 1189,1194 ****
--- 1193,1201 ----
      (define-key map [menu-bar operate chmod]
        '(menu-item "Change Mode..." dired-do-chmod
  		  :help "Change mode (attributes) of marked files"))
+     (define-key map [menu-bar operate touch]
+       '(menu-item "Change Timestamp..." dired-do-touch
+ 		  :help "Change timestamp of marked files"))
      (define-key map [menu-bar operate load]
        '(menu-item "Load" dired-do-load
  		  :help "Load marked Emacs Lisp files"))
***************
*** 2338,2345 ****
  (defvar dired-no-confirm nil
    "A list of symbols for commands dired should not confirm.
  Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress',
! `copy', `delete', `hardlink', `load', `move', `print', `shell', `symlink' and
! `uncompress'.")
  
  (defun dired-mark-pop-up (bufname op-symbol files function &rest args)
    "Return FUNCTION's result on ARGS after showing which files are marked.
--- 2345,2352 ----
  (defvar dired-no-confirm nil
    "A list of symbols for commands dired should not confirm.
  Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress',
! `copy', `delete', `hardlink', `load', `move', `print', `shell', `symlink',
! `touch' and `uncompress'.")
  
  (defun dired-mark-pop-up (bufname op-symbol files function &rest args)
    "Return FUNCTION's result on ARGS after showing which files are marked.
***************
*** 2980,2985 ****
--- 2987,2996 ----
  
  (autoload 'dired-do-chown "dired-aux"
    "Change the owner of the marked (or next ARG) files."
+   t)
+ 
+ (autoload 'dired-do-touch "dired-aux"
+   "Change the timestamp of the marked (or next ARG) files."
    t)
  
  (autoload 'dired-do-print "dired-aux"
Index: emacs/lisp/dired-aux.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.115
diff -c -r1.115 dired-aux.el
*** emacs/lisp/dired-aux.el	23 Mar 2004 07:39:35 -0000	1.115
--- emacs/lisp/dired-aux.el	25 Mar 2004 14:30:38 -0000
***************
*** 185,209 ****
               (file-attributes full-file-name))))
     (directory-files dir)))
  \f
  (defun dired-do-chxxx (attribute-name program op-symbol arg)
!   ;; Change file attributes (mode, group, owner) of marked files and
    ;; refresh their file lines.
    ;; ATTRIBUTE-NAME is a string describing the attribute to the user.
    ;; PROGRAM is the program used to change the attribute.
    ;; 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))
  	 (new-attribute
  	  (dired-mark-read-string
  	   (concat "Change " attribute-name " of %s to: ")
! 	   nil op-symbol arg files))
  	 (operation (concat program " " new-attribute))
  	 failures)
      (setq failures
  	  (dired-bunch-files 10000
  			     (function dired-check-process)
  			     (append
! 			      (list operation program new-attribute)
  			      (if (string-match "gnu" system-configuration)
  				  '("--") nil))
  			     files))
--- 185,270 ----
               (file-attributes full-file-name))))
     (directory-files dir)))
  \f
+ (defvar dired-show-initial t
+   "Show initial value for chmod, chown, chgrp, touch.")
+ 
+ (defun dired-create-initial (op-symbol files)
+   (cond ((eq op-symbol 'chmod)
+          (dired-create-initial-chmod files))
+         ((eq op-symbol 'chown)
+          (dired-create-initial-chown files))
+         ((eq op-symbol 'chgrp)
+          (dired-create-initial-chgrp files))
+         ((eq op-symbol 'touch)
+          (dired-create-initial-touch files))))
+ 
+ (defun dired-create-initial-chmod (files)
+   "Create initial input value for `chmod' command."
+   (let (initial)
+     (while files
+       (let ((current (file-modes (car files))))
+         (if (and initial (not (equal initial current)))
+             (setq initial (default-file-modes) files nil)
+           (setq initial current))
+         (setq files (cdr files))))
+     (format "%o" initial)))
+ 
+ (defun dired-create-initial-chown (files)
+   "Create initial input value for `chown' command."
+   (let (initial)
+     (while files
+       (let ((current (nth 2 (file-attributes (car files) 'string))))
+         (if (and initial (not (equal initial current)))
+             (setq initial user-login-name files nil)
+           (setq initial current))
+         (setq files (cdr files))))
+     initial))
+ 
+ (defun dired-create-initial-chgrp (files)
+   "Create initial input value for `chgrp' command."
+   (let (initial)
+     (while files
+       (let ((current (nth 3 (file-attributes (car files) 'string))))
+         (if (and initial (not (equal initial current)))
+             (setq initial user-login-name files nil)
+           (setq initial current))
+         (setq files (cdr files))))
+     initial))
+ 
+ (defun dired-create-initial-touch (files)
+   "Create initial input value for `touch' command."
+   (let (initial)
+     (while files
+       (let ((current (nth 5 (file-attributes (car files)))))
+         (if (and initial (not (equal initial current)))
+             (setq initial (current-time) files nil)
+           (setq initial current))
+         (setq files (cdr files))))
+     (format-time-string "%Y%m%d%H%M.%S" initial)))
+ 
  (defun dired-do-chxxx (attribute-name program op-symbol arg)
!   ;; Change file attributes (mode, group, owner, timestamp) of marked files and
    ;; refresh their file lines.
    ;; ATTRIBUTE-NAME is a string describing the attribute to the user.
    ;; PROGRAM is the program used to change the attribute.
    ;; 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))
+          (initial (if dired-show-initial (dired-create-initial op-symbol files)))
  	 (new-attribute
  	  (dired-mark-read-string
  	   (concat "Change " attribute-name " of %s to: ")
! 	   initial op-symbol arg files))
  	 (operation (concat program " " new-attribute))
  	 failures)
      (setq failures
  	  (dired-bunch-files 10000
  			     (function dired-check-process)
  			     (append
! 			      (list operation program)
! 			      (if (eq op-symbol 'touch)
! 				  '("-t") nil)
! 			      (list new-attribute)
  			      (if (string-match "gnu" system-configuration)
  				  '("--") nil))
  			     files))
***************
*** 235,240 ****
--- 296,307 ----
    (if (memq system-type '(ms-dos windows-nt))
        (error "chown not supported on this system"))
    (dired-do-chxxx "Owner" dired-chown-program 'chown arg))
+ 
+ (defun dired-do-touch (&optional arg)
+   "Change the timestamp of the marked (or next ARG) files.
+ This calls touch."
+   (interactive "P")
+   (dired-do-chxxx "Timestamp" dired-touch-program 'touch arg))
  
  ;; Process all the files in FILES in batches of a convenient size,
  ;; by means of (FUNCALL FUNCTION ARGS... SOME-FILES...).

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-25 14:54 ` dired-do-touch Juri Linkov
@ 2004-03-25 21:07   ` Juri Linkov
  2004-03-27  5:52   ` dired-do-touch Richard Stallman
  1 sibling, 0 replies; 62+ messages in thread
From: Juri Linkov @ 2004-03-25 21:07 UTC (permalink / raw)


Juri Linkov <juri@jurta.org> writes:
> I am very happy with the following patch.

And I am happy with the following patch as well (it should be applied
with the patch I posted in the previous mail).

This patch adds guessing the default target directory for dired-diff.
If there is no mark in the current dired buffer, then it takes the target
directory name from the next window using `dired-dwim-target-directory'.

Another feature is that if no files are marked in the current dired
buffer (i.e. dired operates on the file under point) then when reading
the target file name it uses the current file name as the initial
input string for C, R and some other dired commands.  This is
especially useful when renaming files: the prompt places the name of
the current file as the basis for file name editing.

Index: emacs/lisp/dired-aux.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.115
diff -c -r1.115 dired-aux.el
*** emacs/lisp/dired-aux.el	23 Mar 2004 07:39:35 -0000	1.115
--- emacs/lisp/dired-aux.el	25 Mar 2004 17:10:33 -0000
***************
*** 64,70 ****
  				   (if default
  				       (concat "(default " default ") ")
  				     ""))
! 			   (dired-current-directory) default t)
  	   (if current-prefix-arg
  	       (read-string "Options for diff: "
  			    (if (stringp diff-switches)
--- 64,72 ----
  				   (if default
  				       (concat "(default " default ") ")
  				     ""))
! 			   (if default
!                                (dired-current-directory)
!                              (dired-dwim-target-directory)) default t)
  	   (if current-prefix-arg
  	       (read-string "Options for diff: "
  			    (if (stringp diff-switches)
***************
*** 1402,1408 ****
    (dired-mark-pop-up
     nil op-symbol files
     (function read-file-name)
!    (format prompt (dired-mark-prompt arg files)) dir default))
  
  (defun dired-dwim-target-directory ()
    ;; Try to guess which target directory the user may want.
--- 1472,1483 ----
    (dired-mark-pop-up
     nil op-symbol files
     (function read-file-name)
!    (format prompt (dired-mark-prompt arg files)) dir default nil
!    (if (and dired-show-initial
!             (and (consp files) (null (cdr files)) (car files))
!             (equal (dired-dwim-target-directory)
!                    (dired-current-directory)))
!        (car files))))
  
  (defun dired-dwim-target-directory ()
    ;; Try to guess which target directory the user may want.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-25  2:00         ` dired-do-touch Richard Stallman
@ 2004-03-26 18:31           ` Matthew Mundell
  2004-03-28  1:36             ` dired-do-touch Richard Stallman
  2004-03-28  1:36             ` dired-do-touch Richard Stallman
  0 siblings, 2 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-26 18:31 UTC (permalink / raw)
  Cc: eliz, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> The changes in dired.el and fileio.c look ok to me.
> The changes in dired-aux.el were omitted.

The changes to dired-aux.el were the same as in the original post.
Here are all the changes, with change logs.  Fset_file_times in
fileio.c now silently ignores failures on DOS_NT systems, at Eli's
suggestion, and returns t or nil, at Kim's suggestion.


2004-03-23  Matthew Mundell  <matt@mundell.ukfsn.org>

	* fileio.c (Fset_file_times): New function.
    Suggested by Lars Hansen <larsh@math.ku.dk>.
    (Qset_file_times): New variable.
    (lisp_time_argument): New declaration.
	(syms_of_fileio): staticpro and intern new variable, defsubr new
	function.

	* editfns.c (lisp_time_argument): Provide externally.


2004-03-23  Matthew Mundell  <matt@mundell.ukfsn.org>

	* dired-aux.el (dired-touch, dired-do-touch): New defuns.

    * dired.el: Bind dired-do-touch to T.


===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
diff -u -r1.115 dired-aux.el
--- lisp/dired-aux.el	23 Mar 2004 07:39:35 -0000	1.115
+++ lisp/dired-aux.el	26 Mar 2004 16:32:37 -0000
@@ -2139,6 +2139,29 @@
       (backward-delete-char 1))
     (message "%s" (buffer-string))))

+(defun dired-touch ()
+  "Touch current file.  Return file name on failure, else nil."
+  (let ((file (dired-get-filename))
+	fail)
+    (condition-case err
+	(set-file-times file (current-time))
+      (error (setq fail err)))
+    (if fail
+	(progn
+	  (dired-log "Setting time on `%s' failed:\n%s\n"
+		     file fail)
+	  (dired-make-relative file)))))
+
+;;;###autoload
+(defun dired-do-touch (&optional arg)
+  "Set the selected files' access and mod times to the current time.
+
+With non-zero prefix argument ARG, the command operates on the
+next ARG files.  Otherwise, it operates on all the marked files,
+or the current file if none are marked."
+  (interactive "P")
+  (dired-map-over-marks-check (function dired-touch) arg 'touch nil))
+
 (provide 'dired-aux)

 ;;; arch-tag: 4b508de9-a153-423d-8d3f-a1bbd86f4f60


===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
diff -u -r1.276 dired.el
--- lisp/dired.el	25 Mar 2004 10:40:59 -0000	1.276
+++ lisp/dired.el	26 Mar 2004 16:31:59 -0000
@@ -919,6 +919,7 @@
     (define-key map "Q" 'dired-do-query-replace-regexp)
     (define-key map "R" 'dired-do-rename)
     (define-key map "S" 'dired-do-symlink)
+    (define-key map "T" 'dired-do-touch)
     (define-key map "X" 'dired-do-shell-command)
     (define-key map "Z" 'dired-do-compress)
     (define-key map "!" 'dired-do-shell-command)


===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
diff -u -r1.499 fileio.c
--- src/fileio.c	18 Mar 2004 02:58:45 -0000	1.499
+++ src/fileio.c	26 Mar 2004 16:34:06 -0000
@@ -323,6 +323,7 @@
 Lisp_Object Qfile_accessible_directory_p;
 Lisp_Object Qfile_modes;
 Lisp_Object Qset_file_modes;
+Lisp_Object Qset_file_times;
 Lisp_Object Qfile_newer_than_file_p;
 Lisp_Object Qinsert_file_contents;
 Lisp_Object Qwrite_region;
@@ -3438,7 +3439,59 @@
   XSETINT (value, (~ realmask) & 0777);
   return value;
 }
+\f
+extern int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
+
+DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
+       doc: /* Set times of file FILENAME to TIME.
+Set both access and modification times.
+Return t on success, else nil.
+Use the current time if TIME is nil.  TIME is in the format of
+`current-time'. */)
+  (filename, time)
+     Lisp_Object filename, time;
+{
+  Lisp_Object absname, encoded_absname;
+  Lisp_Object handler;
+  time_t sec;
+  int usec;
+
+  if (! lisp_time_argument (time, &sec, &usec))
+    error ("Invalid time specification");
+
+  absname = Fexpand_file_name (filename, current_buffer->directory);
+
+  /* If the file name has special constructs in it,
+     call the corresponding file handler.  */
+  handler = Ffind_file_name_handler (absname, Qset_file_times);
+  if (!NILP (handler))
+    return call3 (handler, Qset_file_times, absname, time);
+
+  encoded_absname = ENCODE_FILE (absname);
+
+  {
+    EMACS_TIME t;
+
+    EMACS_SET_SECS (t, sec);
+    EMACS_SET_USECS (t, usec);
+
+    if (set_file_times (SDATA (encoded_absname), t, t))
+      {
+#ifdef DOS_NT
+        struct stat st;

+        /* Setting times on a directory always fails.  */
+        if (stat (SDATA (encoded_absname), &st) == 0
+            && (st.st_mode & S_IFMT) == S_IFDIR)
+          return Qnil;
+#endif
+        report_file_error ("Setting file times", Fcons (absname, Qnil));
+        return Qnil;
+      }
+  }
+
+  return Qt;
+}
 \f
 #ifdef __NetBSD__
 #define unix 42
@@ -6339,6 +6392,7 @@
   Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
   Qfile_modes = intern ("file-modes");
   Qset_file_modes = intern ("set-file-modes");
+  Qset_file_times = intern ("set-file-times");
   Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
   Qinsert_file_contents = intern ("insert-file-contents");
   Qwrite_region = intern ("write-region");
@@ -6372,6 +6426,7 @@
   staticpro (&Qfile_accessible_directory_p);
   staticpro (&Qfile_modes);
   staticpro (&Qset_file_modes);
+  staticpro (&Qset_file_times);
   staticpro (&Qfile_newer_than_file_p);
   staticpro (&Qinsert_file_contents);
   staticpro (&Qwrite_region);
@@ -6595,6 +6650,7 @@
   defsubr (&Sfile_regular_p);
   defsubr (&Sfile_modes);
   defsubr (&Sset_file_modes);
+  defsubr (&Sset_file_times);
   defsubr (&Sset_default_file_modes);
   defsubr (&Sdefault_file_modes);
   defsubr (&Sfile_newer_than_file_p);

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-25 14:54 ` dired-do-touch Juri Linkov
  2004-03-25 21:07   ` dired-do-touch Juri Linkov
@ 2004-03-27  5:52   ` Richard Stallman
  2004-03-27 10:59     ` dired-do-touch Juri Linkov
  1 sibling, 1 reply; 62+ messages in thread
From: Richard Stallman @ 2004-03-27  5:52 UTC (permalink / raw)
  Cc: matt, emacs-devel

When we are discussing one new feature, please do not add a second
feature into the same patch.  That is an obstacle to considering it.

Would you please send *only* the new T command, with nothing else?
Then maybe we can install it.  Please include the ChangeLog entries
and an entry for etc/NEWS.

After that we could consider the other change.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27  5:52   ` dired-do-touch Richard Stallman
@ 2004-03-27 10:59     ` Juri Linkov
  2004-03-27 12:17       ` dired-do-touch Eli Zaretskii
  2004-03-28  4:25       ` dired-do-touch Richard Stallman
  0 siblings, 2 replies; 62+ messages in thread
From: Juri Linkov @ 2004-03-27 10:59 UTC (permalink / raw)
  Cc: matt, emacs-devel

Richard Stallman <rms@gnu.org> writes:
> When we are discussing one new feature, please do not add a second
> feature into the same patch.  That is an obstacle to considering it.
>
> Would you please send *only* the new T command, with nothing else?
> Then maybe we can install it.  Please include the ChangeLog entries
> and an entry for etc/NEWS.
>
> After that we could consider the other change.

Below is the patch for the new T command.  It uses the external touch
program and behaves like other dired commands `chmod', `chgrp' and `chown'.

I suggest to install this patch first.  Then I suggest to consider and
install the patch that allows the initial default values for
dired-do-touch, dired-do-chmod, dired-do-chgrp, dired-do-chown and
some other dired commands.

And after this I suggest to install the patch posted by Matthew Mundell
that uses the new function `set-file-times', with small modifications
which will allow to use it instead of the external program in cases
when there is no touch program installed or depending on a new user option.

lisp/ChangeLog:

	* dired.el (dired-touch-program): New var.
	(dired-mode-map): Bind `dired-do-touch' to `T' and add menu-item.
	(dired-no-confirm): Add `touch' to docstring.
	(dired-do-touch): Add autoload for `dired-do-touch'.

	* dired-aux.el (dired-do-touch): New fun.
	(dired-do-chxxx): Add argument `-t' for touch operation.

An entry for etc/NEWS could be written later to describe all the
related changes.

Index: emacs/lisp/dired.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
retrieving revision 1.278
diff -c -r1.278 dired.el
*** emacs/lisp/dired.el	27 Mar 2004 01:16:58 -0000	1.278
--- emacs/lisp/dired.el	27 Mar 2004 10:10:01 -0000
***************
*** 79,84 ****
--- 79,87 ----
  (defvar dired-chmod-program "chmod"
    "Name of chmod command (usually `chmod').")
  
+ (defvar dired-touch-program "touch"
+   "Name of touch command (usually `touch').")
+ 
  ;;;###autoload
  (defcustom dired-ls-F-marks-symlinks nil
    "*Informs dired about how `ls -lF' marks symbolic links.
***************
*** 919,924 ****
--- 922,928 ----
      (define-key map "Q" 'dired-do-query-replace-regexp)
      (define-key map "R" 'dired-do-rename)
      (define-key map "S" 'dired-do-symlink)
+     (define-key map "T" 'dired-do-touch)
      (define-key map "X" 'dired-do-shell-command)
      (define-key map "Z" 'dired-do-compress)
      (define-key map "!" 'dired-do-shell-command)
***************
*** 1189,1194 ****
--- 1193,1201 ----
      (define-key map [menu-bar operate chmod]
        '(menu-item "Change Mode..." dired-do-chmod
  		  :help "Change mode (attributes) of marked files"))
+     (define-key map [menu-bar operate touch]
+       '(menu-item "Change Timestamp..." dired-do-touch
+ 		  :help "Change timestamp of marked files"))
      (define-key map [menu-bar operate load]
        '(menu-item "Load" dired-do-load
  		  :help "Load marked Emacs Lisp files"))
***************
*** 2333,2340 ****
  (defvar dired-no-confirm nil
    "A list of symbols for commands dired should not confirm.
  Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress',
! `copy', `delete', `hardlink', `load', `move', `print', `shell', `symlink' and
! `uncompress'.")
  
  (defun dired-mark-pop-up (bufname op-symbol files function &rest args)
    "Return FUNCTION's result on ARGS after showing which files are marked.
--- 2340,2347 ----
  (defvar dired-no-confirm nil
    "A list of symbols for commands dired should not confirm.
  Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress',
! `copy', `delete', `hardlink', `load', `move', `print', `shell', `symlink',
! `touch' and `uncompress'.")
  
  (defun dired-mark-pop-up (bufname op-symbol files function &rest args)
    "Return FUNCTION's result on ARGS after showing which files are marked.
***************
*** 2975,2980 ****
--- 2982,2991 ----
  
  (autoload 'dired-do-chown "dired-aux"
    "Change the owner of the marked (or next ARG) files."
+   t)
+ 
+ (autoload 'dired-do-touch "dired-aux"
+   "Change the timestamp of the marked (or next ARG) files."
    t)
  
  (autoload 'dired-do-print "dired-aux"
Index: emacs/lisp/dired-aux.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.115
diff -c -r1.115 dired-aux.el
*** emacs/lisp/dired-aux.el	23 Mar 2004 07:39:35 -0000	1.115
--- emacs/lisp/dired-aux.el	27 Mar 2004 10:10:02 -0000
***************
*** 186,192 ****
     (directory-files dir)))
  \f
  (defun dired-do-chxxx (attribute-name program op-symbol arg)
!   ;; Change file attributes (mode, group, owner) of marked files and
    ;; refresh their file lines.
    ;; ATTRIBUTE-NAME is a string describing the attribute to the user.
    ;; PROGRAM is the program used to change the attribute.
--- 186,192 ----
     (directory-files dir)))
  \f
  (defun dired-do-chxxx (attribute-name program op-symbol arg)
!   ;; Change file attributes (mode, group, owner, timestamp) of marked files and
    ;; refresh their file lines.
    ;; ATTRIBUTE-NAME is a string describing the attribute to the user.
    ;; PROGRAM is the program used to change the attribute.
***************
*** 203,209 ****
  	  (dired-bunch-files 10000
  			     (function dired-check-process)
  			     (append
! 			      (list operation program new-attribute)
  			      (if (string-match "gnu" system-configuration)
  				  '("--") nil))
  			     files))
--- 203,212 ----
  	  (dired-bunch-files 10000
  			     (function dired-check-process)
  			     (append
! 			      (list operation program)
! 			      (if (eq op-symbol 'touch)
! 				  '("-t") nil)
! 			      (list new-attribute)
  			      (if (string-match "gnu" system-configuration)
  				  '("--") nil))
  			     files))
***************
*** 235,240 ****
--- 238,249 ----
    (if (memq system-type '(ms-dos windows-nt))
        (error "chown not supported on this system"))
    (dired-do-chxxx "Owner" dired-chown-program 'chown arg))
+ 
+ (defun dired-do-touch (&optional arg)
+   "Change the timestamp of the marked (or next ARG) files.
+ This calls touch."
+   (interactive "P")
+   (dired-do-chxxx "Timestamp" dired-touch-program 'touch arg))
  
  ;; Process all the files in FILES in batches of a convenient size,
  ;; by means of (FUNCALL FUNCTION ARGS... SOME-FILES...).

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 10:59     ` dired-do-touch Juri Linkov
@ 2004-03-27 12:17       ` Eli Zaretskii
  2004-03-27 13:06         ` dired-do-touch Juri Linkov
  2004-03-27 16:09         ` dired-do-touch Matthew Mundell
  2004-03-28  4:25       ` dired-do-touch Richard Stallman
  1 sibling, 2 replies; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-27 12:17 UTC (permalink / raw)
  Cc: matt, rms, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Sat, 27 Mar 2004 12:59:21 +0200
> 
> Below is the patch for the new T command.  It uses the external touch
> program and behaves like other dired commands `chmod', `chgrp' and `chown'.
> 
> I suggest to install this patch first.  Then I suggest to consider and
> install the patch that allows the initial default values for
> dired-do-touch, dired-do-chmod, dired-do-chgrp, dired-do-chown and
> some other dired commands.
> 
> And after this I suggest to install the patch posted by Matthew Mundell
> that uses the new function `set-file-times', with small modifications
> which will allow to use it instead of the external program in cases
> when there is no touch program installed or depending on a new user option.

I don't understand why you insist on using an external program if
Emacs could easily have a primitive to do the same.  I think using an
Emacs primitive is faster, in addition to being more portable.

The patch to add set-file-times is already reviewed by at least 2
Emacs maintainers, and is IMHO ready for being checked in.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 12:17       ` dired-do-touch Eli Zaretskii
@ 2004-03-27 13:06         ` Juri Linkov
  2004-03-27 16:13           ` dired-do-touch Matthew Mundell
  2004-03-27 16:09         ` dired-do-touch Matthew Mundell
  1 sibling, 1 reply; 62+ messages in thread
From: Juri Linkov @ 2004-03-27 13:06 UTC (permalink / raw)
  Cc: matt, rms, emacs-devel

"Eli Zaretskii" <eliz@gnu.org> writes:
> I don't understand why you insist on using an external program if
> Emacs could easily have a primitive to do the same.  I think using an
> Emacs primitive is faster, in addition to being more portable.

I don't see a reason why changing file time should differ from
operations changing other file attributes like mode, owner and group.

I don't insist on using external programs.  If Emacs primitives are
faster, then other dired commands for changing other file attributes
should be modified to use Emacs primitives too.

> The patch to add set-file-times is already reviewed by at least 2
> Emacs maintainers, and is IMHO ready for being checked in.

It don't allow to change file times to values other than current time.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 12:17       ` dired-do-touch Eli Zaretskii
  2004-03-27 13:06         ` dired-do-touch Juri Linkov
@ 2004-03-27 16:09         ` Matthew Mundell
  1 sibling, 0 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-27 16:09 UTC (permalink / raw)
  Cc: Juri Linkov, rms, emacs-devel

"Eli Zaretskii" <eliz@gnu.org> writes:

> > From: Juri Linkov <juri@jurta.org>
> > Date: Sat, 27 Mar 2004 12:59:21 +0200
> >
> > Below is the patch for the new T command.  It uses the external touch
> > program and behaves like other dired commands `chmod', `chgrp' and `chown'.
> >
> > I suggest to install this patch first.  Then I suggest to consider and
> > install the patch that allows the initial default values for
> > dired-do-touch, dired-do-chmod, dired-do-chgrp, dired-do-chown and
> > some other dired commands.
> >
> > And after this I suggest to install the patch posted by Matthew Mundell
> > that uses the new function `set-file-times', with small modifications
> > which will allow to use it instead of the external program in cases
> > when there is no touch program installed or depending on a new user option.
>
> I don't understand why you insist on using an external program if
> Emacs could easily have a primitive to do the same.  I think using an
> Emacs primitive is faster, in addition to being more portable.

I also think an available primitive should take preference over an
external program.  For now, using the set-file-times primitive
prevents the Dired interface from taking an arbitrary time.

> The patch to add set-file-times is already reviewed by at least 2
> Emacs maintainers, and is IMHO ready for being checked in.

He's challenging only the Dired changes, I think.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 13:06         ` dired-do-touch Juri Linkov
@ 2004-03-27 16:13           ` Matthew Mundell
  2004-03-27 17:52             ` dired-do-touch Juri Linkov
  0 siblings, 1 reply; 62+ messages in thread
From: Matthew Mundell @ 2004-03-27 16:13 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> "Eli Zaretskii" <eliz@gnu.org> writes:
> > I don't understand why you insist on using an external program if
> > Emacs could easily have a primitive to do the same.  I think using an
> > Emacs primitive is faster, in addition to being more portable.
>
> I don't see a reason why changing file time should differ from
> operations changing other file attributes like mode, owner and
> group.

So you're suggesting to use an external program until a date can be
entered with the version of dired-do-touch which uses a primitive?  It
sounds like a good idea.

The set-file-times primitive can still be installed.

> I don't insist on using external programs.  If Emacs primitives are
> faster, then other dired commands for changing other file attributes
> should be modified to use Emacs primitives too.
>
> > The patch to add set-file-times is already reviewed by at least 2
> > Emacs maintainers, and is IMHO ready for being checked in.
>
> It don't allow to change file times to values other than current time.

The primitive allows any time to be set.  However, the dired-do-time
patch which uses the primitive always uses the current time.  For this
to accept an arbitrary time it needs to parse the time from a
user-supplied string.  Is there a Lisp function which does this?

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 16:13           ` dired-do-touch Matthew Mundell
@ 2004-03-27 17:52             ` Juri Linkov
  2004-03-28 19:59               ` dired-do-touch Matthew Mundell
  0 siblings, 1 reply; 62+ messages in thread
From: Juri Linkov @ 2004-03-27 17:52 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Matthew Mundell <matt@mundell.ukfsn.org> writes:
> Juri Linkov <juri@jurta.org> writes:
>> I don't see a reason why changing file time should differ from
>> operations changing other file attributes like mode, owner and
>> group.
>
> So you're suggesting to use an external program until a date can be
> entered with the version of dired-do-touch which uses a primitive?  It
> sounds like a good idea.

Yes.  Since Richard asked to consider one feature at a time,
I think the most natural order would be the following:

1. Add the touch dired command that works like other dired commands
   which change file attributes: chmod, chown, chgrp;
2a. Add a feature that guesses the initial input for these
   dired commands;
2b. Rewrite these dired commands to use Emacs primitives.

(2a and 2b are in no particular order)

> The set-file-times primitive can still be installed.

I agree that the set-file-times primitive can be installed now,
and later it can be used in the dired touch command.  And generally
this primitive may become necessary for other Lisp programs too.

>> It don't allow to change file times to values other than current time.
>
> The primitive allows any time to be set.  However, the dired-do-time
> patch which uses the primitive always uses the current time.  For this
> to accept an arbitrary time it needs to parse the time from a
> user-supplied string.  Is there a Lisp function which does this?

There is the function `date-to-time' which parses a time string.
But it should be improved to accept the format of the touch program.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-26 18:31           ` dired-do-touch Matthew Mundell
@ 2004-03-28  1:36             ` Richard Stallman
  2004-03-28  1:36             ` dired-do-touch Richard Stallman
  1 sibling, 0 replies; 62+ messages in thread
From: Richard Stallman @ 2004-03-28  1:36 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    The changes to dired-aux.el were the same as in the original post.

Because I am so terribly busy, I'd appreciate it if you would spare me
the need to do things like search for a previous post.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-26 18:31           ` dired-do-touch Matthew Mundell
  2004-03-28  1:36             ` dired-do-touch Richard Stallman
@ 2004-03-28  1:36             ` Richard Stallman
  1 sibling, 0 replies; 62+ messages in thread
From: Richard Stallman @ 2004-03-28  1:36 UTC (permalink / raw)
  Cc: eliz, emacs-devel

This change looks ok.  We have to wait for your legal papers to be
filed.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 10:59     ` dired-do-touch Juri Linkov
  2004-03-27 12:17       ` dired-do-touch Eli Zaretskii
@ 2004-03-28  4:25       ` Richard Stallman
  1 sibling, 0 replies; 62+ messages in thread
From: Richard Stallman @ 2004-03-28  4:25 UTC (permalink / raw)
  Cc: matt, emacs-devel

Please install your patch.
We can install Matt's further change when his papers come.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-27 17:52             ` dired-do-touch Juri Linkov
@ 2004-03-28 19:59               ` Matthew Mundell
  2004-03-29  6:59                 ` dired-do-touch Eli Zaretskii
  2004-03-29 19:27                 ` dired-do-touch Juri Linkov
  0 siblings, 2 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-28 19:59 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> Matthew Mundell <matt@mundell.ukfsn.org> writes:
> > Juri Linkov <juri@jurta.org> writes:
> >> I don't see a reason why changing file time should differ from
> >> operations changing other file attributes like mode, owner and
> >> group.
> >
> > So you're suggesting to use an external program until a date can be
> > entered with the version of dired-do-touch which uses a primitive?  It
> > sounds like a good idea.
>
> Yes.  Since Richard asked to consider one feature at a time,
> I think the most natural order would be the following:
>
> 1. Add the touch dired command that works like other dired commands
>    which change file attributes: chmod, chown, chgrp;
> 2a. Add a feature that guesses the initial input for these
>    dired commands;
> 2b. Rewrite these dired commands to use Emacs primitives.

There's the set-file-modes primitive for changing modes.  Are there
equivalent primitives for changing owner and group?

If the commands are going to be rewritten soon to use primitives then
perhaps step 1 can be skipped.

>
> (2a and 2b are in no particular order)
>
> > The set-file-times primitive can still be installed.
>
> I agree that the set-file-times primitive can be installed now,
> and later it can be used in the dired touch command.  And generally
> this primitive may become necessary for other Lisp programs too.

Earlier in the thread Lars Hansen suggested adding such a primitive,
for use in Tramp.

> >> It don't allow to change file times to values other than current time.
> >
> > The primitive allows any time to be set.  However, the dired-do-time
> > patch which uses the primitive always uses the current time.  For this
> > to accept an arbitrary time it needs to parse the time from a
> > user-supplied string.  Is there a Lisp function which does this?
>
> There is the function `date-to-time' which parses a time string.
> But it should be improved to accept the format of the touch program.

Thanks, I missed it.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-28 19:59               ` dired-do-touch Matthew Mundell
@ 2004-03-29  6:59                 ` Eli Zaretskii
  2004-03-29 19:15                   ` dired-do-touch Juri Linkov
  2004-03-29 19:27                 ` dired-do-touch Juri Linkov
  1 sibling, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-29  6:59 UTC (permalink / raw)
  Cc: juri, rms, emacs-devel

> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Date: 28 Mar 2004 20:59:13 +0100
> 
> There's the set-file-modes primitive for changing modes.  Are there
> equivalent primitives for changing owner and group?

I don't think so.  FWIW, I think we should add them.

> > There is the function `date-to-time' which parses a time string.
> > But it should be improved to accept the format of the touch program.
> 
> Thanks, I missed it.

IMHO, we don't _have_ to emulate the `touch' program's date/time
format.  The format of the arguments that `touch' accepts is a result
of a certain user-interface design that is appropriate for a
command-line utility.  Emacs could in principle present an entirely
different UI, since it is not a command-line app.  We just need to
support the same _functionality_, but not necessarily the same
_format_.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-29  6:59                 ` dired-do-touch Eli Zaretskii
@ 2004-03-29 19:15                   ` Juri Linkov
  2004-03-29 22:24                     ` dired-do-touch Andreas Schwab
                                       ` (2 more replies)
  0 siblings, 3 replies; 62+ messages in thread
From: Juri Linkov @ 2004-03-29 19:15 UTC (permalink / raw)
  Cc: Matthew Mundell, rms, emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:
>> There's the set-file-modes primitive for changing modes.  Are there
>> equivalent primitives for changing owner and group?
>
> I don't think so.  FWIW, I think we should add them.

I completely agree that we should add primitives for changing
owner and group and use them in dired.

Actually, I never understood why dired needs separate commands for
external programs that can be easily run by `dired-do-shell-command',
like e.g. by typing `! chown owner RET' on marked files.  The main
reason I wanted to add the touch dired command is that with an initial
value for the time at its prompt (I posted a patch for this earlier)
the user can edit an initial value.  And of course, since dired commands
for changing file attributes already exist it makes sense to use Emacs
primitives for them for achieve independence from external programs.

>> > There is the function `date-to-time' which parses a time string.
>> > But it should be improved to accept the format of the touch program.
>> 
>> Thanks, I missed it.
>
> IMHO, we don't _have_ to emulate the `touch' program's date/time
> format.  The format of the arguments that `touch' accepts is a result
> of a certain user-interface design that is appropriate for a
> command-line utility.  Emacs could in principle present an entirely
> different UI, since it is not a command-line app.  We just need to
> support the same _functionality_, but not necessarily the same
> _format_.

While I agree that we don't have to emulate the `touch' program
format, I think that we ought to add it as one of the possible time
formats accepted by the `date-to-time' and other Emacs time-parsing
functions, because this format is very compact which makes it
convenient for the user to enter.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-28 19:59               ` dired-do-touch Matthew Mundell
  2004-03-29  6:59                 ` dired-do-touch Eli Zaretskii
@ 2004-03-29 19:27                 ` Juri Linkov
  1 sibling, 0 replies; 62+ messages in thread
From: Juri Linkov @ 2004-03-29 19:27 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Matthew Mundell <matt@mundell.ukfsn.org> writes:
> Juri Linkov <juri@jurta.org> writes:
>> 1. Add the touch dired command that works like other dired commands
>>    which change file attributes: chmod, chown, chgrp;
>> 2a. Add a feature that guesses the initial input for these
>>    dired commands;
>> 2b. Rewrite these dired commands to use Emacs primitives.
>
> If the commands are going to be rewritten soon to use primitives then
> perhaps step 1 can be skipped.

It's only for the sake of adding one feature at a time.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-29 19:15                   ` dired-do-touch Juri Linkov
@ 2004-03-29 22:24                     ` Andreas Schwab
  2004-03-30  6:50                     ` dired-do-touch Eli Zaretskii
  2004-03-30 16:18                     ` dired-do-touch Matthew Mundell
  2 siblings, 0 replies; 62+ messages in thread
From: Andreas Schwab @ 2004-03-29 22:24 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel, Matthew Mundell, rms

Juri Linkov <juri@jurta.org> writes:

> Actually, I never understood why dired needs separate commands for
> external programs that can be easily run by `dired-do-shell-command',
> like e.g. by typing `! chown owner RET' on marked files.

Probably two reasons: convenience and automatic redisplay.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-29 19:15                   ` dired-do-touch Juri Linkov
  2004-03-29 22:24                     ` dired-do-touch Andreas Schwab
@ 2004-03-30  6:50                     ` Eli Zaretskii
  2004-03-30  9:59                       ` dired-do-touch Juri Linkov
  2004-03-30 16:18                     ` dired-do-touch Matthew Mundell
  2 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2004-03-30  6:50 UTC (permalink / raw)
  Cc: matt, rms, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Mon, 29 Mar 2004 22:15:19 +0300
> >
> > IMHO, we don't _have_ to emulate the `touch' program's date/time
> > format.  The format of the arguments that `touch' accepts is a result
> > of a certain user-interface design that is appropriate for a
> > command-line utility.  Emacs could in principle present an entirely
> > different UI, since it is not a command-line app.  We just need to
> > support the same _functionality_, but not necessarily the same
> > _format_.
> 
> While I agree that we don't have to emulate the `touch' program
> format, I think that we ought to add it as one of the possible time
> formats accepted by the `date-to-time' and other Emacs time-parsing
> functions, because this format is very compact which makes it
> convenient for the user to enter.

``Convenient''?  IMHO, you need to be a CS graduate just to understand
it.  Take a look at the Yacc parser summoned for the implementation of
the "--date" option, or at the node in fileutils.info that documents
it.

Even the simpler "-t TIME" option's format is not easy to get right: I
always confuse the traditional (and insane) MMDDhhmm[YY] format with
the newer [[CC]YY]MMDDhhmm[.ss] format and need to consult the docs to
be sure I don't screw up my time stamps.

I wish Emacs had something more human-friendly, perhaps accessible via
mouse clicks on the date/time fields of the Dired display or some such.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-30  6:50                     ` dired-do-touch Eli Zaretskii
@ 2004-03-30  9:59                       ` Juri Linkov
  2004-03-30 12:35                         ` dired-do-touch Matthew Mundell
  0 siblings, 1 reply; 62+ messages in thread
From: Juri Linkov @ 2004-03-30  9:59 UTC (permalink / raw)
  Cc: matt, rms, emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:
>> From: Juri Linkov <juri@jurta.org>
>> Date: Mon, 29 Mar 2004 22:15:19 +0300
>> While I agree that we don't have to emulate the `touch' program
>> format, I think that we ought to add it as one of the possible time
>> formats accepted by the `date-to-time' and other Emacs time-parsing
>> functions, because this format is very compact which makes it
>> convenient for the user to enter.
>
> ``Convenient''?  IMHO, you need to be a CS graduate just to understand
> it.  Take a look at the Yacc parser summoned for the implementation of
> the "--date" option, or at the node in fileutils.info that documents
> it.

AFAIU, it's what the parse-time.el tries to do.  We could just add
the "-t TIME" format to it.

> Even the simpler "-t TIME" option's format is not easy to get right: I
> always confuse the traditional (and insane) MMDDhhmm[YY] format with

The older format is purely "ill-logical".

> the newer [[CC]YY]MMDDhhmm[.ss] format and need to consult the docs to
> be sure I don't screw up my time stamps.

The newer format makes more sense because it's like the ISO 8601 format.

> I wish Emacs had something more human-friendly, perhaps accessible via
> mouse clicks on the date/time fields of the Dired display or some such.

It's a good idea to change file attributes diredctly (I mistyped this word
instead of "directly", but the new word makes sense :-) on a dired buffer.

There also was a suggestion to make dired permission fields editable.

BTW, I think that since we will modify the file mode changing command
to use the primitive, we could add a `rwxrwxrwx'-like format to formats
acceptable by the `set-file-modes' (or perhaps to a new mode-parsing
wrapper around it).

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-30  9:59                       ` dired-do-touch Juri Linkov
@ 2004-03-30 12:35                         ` Matthew Mundell
  2004-03-30 19:43                           ` dired-do-touch Stefan Monnier
                                             ` (2 more replies)
  0 siblings, 3 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-30 12:35 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> Eli Zaretskii <eliz@elta.co.il> writes:
[...]
> > I wish Emacs had something more human-friendly, perhaps accessible via
> > mouse clicks on the date/time fields of the Dired display or some such.
>
> It's a good idea to change file attributes diredctly (I mistyped this word
> instead of "directly", but the new word makes sense :-) on a dired buffer.
>
> There also was a suggestion to make dired permission fields
> editable.

Editing permission fields and names directly can be done with
wdired-mode.

It's wdired.el in the Debian emacs-goodies-el package.  The source
suggests finding it via
http://groups.google.com/groups?as_ugroup=gnu.emacs.sources&as_q=wdired.

> BTW, I think that since we will modify the file mode changing command
> to use the primitive, we could add a `rwxrwxrwx'-like format to formats
> acceptable by the `set-file-modes' (or perhaps to a new mode-parsing
> wrapper around it).

This seems worse than the a+rwx format.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-29 19:15                   ` dired-do-touch Juri Linkov
  2004-03-29 22:24                     ` dired-do-touch Andreas Schwab
  2004-03-30  6:50                     ` dired-do-touch Eli Zaretskii
@ 2004-03-30 16:18                     ` Matthew Mundell
  2 siblings, 0 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-30 16:18 UTC (permalink / raw)
  Cc: Eli Zaretskii, rms, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> Eli Zaretskii <eliz@elta.co.il> writes:
> >> There's the set-file-modes primitive for changing modes.  Are there
> >> equivalent primitives for changing owner and group?
> >
> > I don't think so.  FWIW, I think we should add them.
>
> I completely agree that we should add primitives for changing
> owner and group and use them in dired.

With some modification the coreutils change_file_owner and
change_dir_owner functions (in src/chown-core.c) could be the core of
such a primitive.  Is this a good idea, perhaps with an interface as
below?


DEFUN ("set-file-owners", Fset_file_owners, Sset_file_owners, 2, 3, 0,
       doc: /* Set OWNER and/or or GROUP of file FILENAME.
If OWNER or GROUP is nil then skip setting that attribute.
Return t on success, else nil.  */)
  (filename, owner, group)
     Lisp_Object filename, owner, group;
{
    ...

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-30 12:35                         ` dired-do-touch Matthew Mundell
@ 2004-03-30 19:43                           ` Stefan Monnier
  2004-03-31  3:14                           ` dired-do-touch Juri Linkov
  2004-03-31 15:04                           ` dired-do-touch Richard Stallman
  2 siblings, 0 replies; 62+ messages in thread
From: Stefan Monnier @ 2004-03-30 19:43 UTC (permalink / raw)
  Cc: Juri Linkov, Eli Zaretskii, Juan Leon Lahoz Garcia, rms,
	emacs-devel

> Editing permission fields and names directly can be done with
> wdired-mode.

BTW, what happened with it?
I thought we wanted to include it (and/or dired-efap) and yet it seems like
it got lost along the way.


        Stefan

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-30 12:35                         ` dired-do-touch Matthew Mundell
  2004-03-30 19:43                           ` dired-do-touch Stefan Monnier
@ 2004-03-31  3:14                           ` Juri Linkov
  2004-03-31 15:53                             ` dired-do-touch Matthew Mundell
  2004-03-31 15:04                           ` dired-do-touch Richard Stallman
  2 siblings, 1 reply; 62+ messages in thread
From: Juri Linkov @ 2004-03-31  3:14 UTC (permalink / raw)
  Cc: emacs-devel

Matthew Mundell <matt@mundell.ukfsn.org> writes:
> Juri Linkov <juri@jurta.org> writes:
>> BTW, I think that since we will modify the file mode changing command
>> to use the primitive, we could add a `rwxrwxrwx'-like format to formats
>> acceptable by the `set-file-modes' (or perhaps to a new mode-parsing
>> wrapper around it).
>
> This seems worse than the a+rwx format.

rwxrwxrwx is simpler because it is WYSIWYG.
And it's easier for the user to change
when s?he is presented with the initial value to edit.
And it's what (nth 8 (file-attributes file)) returns,
so the reverse operation will be logical.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-30 12:35                         ` dired-do-touch Matthew Mundell
  2004-03-30 19:43                           ` dired-do-touch Stefan Monnier
  2004-03-31  3:14                           ` dired-do-touch Juri Linkov
@ 2004-03-31 15:04                           ` Richard Stallman
  2004-03-31 19:42                             ` dired-do-touch Stefan Monnier
  2 siblings, 1 reply; 62+ messages in thread
From: Richard Stallman @ 2004-03-31 15:04 UTC (permalink / raw)
  Cc: juri, eliz, emacs-devel

    Editing permission fields and names directly can be done with
    wdired-mode.

If this code is clean so we would like to add to Emacs, and if the
authors will sign papers for it, we can use this code.  Otherwise, it
would be useful for someone else to start from scratch and implement
the same feature in a different way, someone who will indeed sign
papers so we can use his code.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-31  3:14                           ` dired-do-touch Juri Linkov
@ 2004-03-31 15:53                             ` Matthew Mundell
  0 siblings, 0 replies; 62+ messages in thread
From: Matthew Mundell @ 2004-03-31 15:53 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> Matthew Mundell <matt@mundell.ukfsn.org> writes:
> > Juri Linkov <juri@jurta.org> writes:
> >> BTW, I think that since we will modify the file mode changing command
> >> to use the primitive, we could add a `rwxrwxrwx'-like format to formats
> >> acceptable by the `set-file-modes' (or perhaps to a new mode-parsing
> >> wrapper around it).
> >
> > This seems worse than the a+rwx format.
>
> rwxrwxrwx is simpler because it is WYSIWYG.
> And it's easier for the user to change
> when s?he is presented with the initial value to edit.

Yes, right, there is a step to learning the a+rwx format after
understanding the rwxrwxrwx format.

> And it's what (nth 8 (file-attributes file)) returns,
> so the reverse operation will be logical.

Makes sense.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-31 15:04                           ` dired-do-touch Richard Stallman
@ 2004-03-31 19:42                             ` Stefan Monnier
  2004-04-02  6:01                               ` dired-do-touch Richard Stallman
  0 siblings, 1 reply; 62+ messages in thread
From: Stefan Monnier @ 2004-03-31 19:42 UTC (permalink / raw)
  Cc: juri, Matthew Mundell, Juan Leon Lahoz Garcia, eliz, emacs-devel

>     Editing permission fields and names directly can be done with
>     wdired-mode.

> If this code is clean so we would like to add to Emacs, and if the
> authors will sign papers for it, we can use this code.

IIRC, Juan León Lahoz García <juan-leon.lahoz@tecsidel.es> signed the
papers and all.  But I can't check it myself.


        Stefan

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-03-31 19:42                             ` dired-do-touch Stefan Monnier
@ 2004-04-02  6:01                               ` Richard Stallman
  2004-04-23 20:57                                 ` dired-do-touch Stefan Monnier
  0 siblings, 1 reply; 62+ messages in thread
From: Richard Stallman @ 2004-04-02  6:01 UTC (permalink / raw)
  Cc: juri, matt, emacs-devel, eliz, juan-leon.lahoz

Yes, Lahoz did sign papers for wdired.el.  So we could install it now.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-04-02  6:01                               ` dired-do-touch Richard Stallman
@ 2004-04-23 20:57                                 ` Stefan Monnier
  0 siblings, 0 replies; 62+ messages in thread
From: Stefan Monnier @ 2004-04-23 20:57 UTC (permalink / raw)
  Cc: juri, matt, emacs-devel, eliz, juan-leon.lahoz

> Yes, Lahoz did sign papers for wdired.el.  So we could install it now.

Done,


        Stefan

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
@ 2004-04-24 15:28 Lars Hansen
  2004-04-24 17:01 ` dired-do-touch Eli Zaretskii
  0 siblings, 1 reply; 62+ messages in thread
From: Lars Hansen @ 2004-04-24 15:28 UTC (permalink / raw)


On  27 Mar 2004  Eli Zaretskii wrote:

>The patch to add set-file-times is already reviewed by at least 2
>Emacs maintainers, and is IMHO ready for being checked in.
>
What happened to this?

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-04-24 15:28 dired-do-touch Lars Hansen
@ 2004-04-24 17:01 ` Eli Zaretskii
  2004-04-24 17:04   ` dired-do-touch Lars Hansen
  0 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2004-04-24 17:01 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 24 Apr 2004 17:28:29 +0200
> From: Lars Hansen <larsh@math.ku.dk>
> 
> On  27 Mar 2004  Eli Zaretskii wrote:
> 
> >The patch to add set-file-times is already reviewed by at least 2
> >Emacs maintainers, and is IMHO ready for being checked in.
> >
> What happened to this?

I thought it was committed.  Wasn't it?

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2004-04-24 17:01 ` dired-do-touch Eli Zaretskii
@ 2004-04-24 17:04   ` Lars Hansen
  0 siblings, 0 replies; 62+ messages in thread
From: Lars Hansen @ 2004-04-24 17:04 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii wrote:

>I thought it was committed.  Wasn't it?
>  
>
I don't think so, I can't find it when I look with grep in src.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* dired-do-touch
@ 2007-08-23 15:07 Sean Sieger
  2007-08-23 15:36 ` dired-do-touch Peter Dyballa
  2007-08-23 17:39 ` dired-do-touch Sean Sieger
  0 siblings, 2 replies; 62+ messages in thread
From: Sean Sieger @ 2007-08-23 15:07 UTC (permalink / raw)
  To: help-gnu-emacs

In GNU Emacs 23.0.0.5 (i686-pc-linux-gnu, GTK+ Version 2.10.11) of
2007-07-31, when I do

T

in a dired buffer, dired prompts to change timestamp.  Is something
wrong with my build or configuration of GNU Emacs?

Thank you.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
       [not found] <mailman.5195.1187881677.32220.help-gnu-emacs@gnu.org>
@ 2007-08-23 15:23 ` Sven Joachim
  2007-08-23 17:43   ` dired-do-touch Sean Sieger
  0 siblings, 1 reply; 62+ messages in thread
From: Sven Joachim @ 2007-08-23 15:23 UTC (permalink / raw)
  To: help-gnu-emacs

Sean Sieger <sean.sieger@gmail.com> writes:

> In GNU Emacs 23.0.0.5 (i686-pc-linux-gnu, GTK+ Version 2.10.11) of
> 2007-07-31, when I do
>
> T
>
> in a dired buffer, dired prompts to change timestamp.

Yes.

>  Is something
> wrong with my build or configuration of GNU Emacs?

I don't think so.  What did you expect 'T' to do?

Sven

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2007-08-23 15:07 dired-do-touch Sean Sieger
@ 2007-08-23 15:36 ` Peter Dyballa
       [not found]   ` <4135e3e50708231035pbc95223m8988de9677ec3c4c@mail.gmail.com>
  2007-08-23 17:39 ` dired-do-touch Sean Sieger
  1 sibling, 1 reply; 62+ messages in thread
From: Peter Dyballa @ 2007-08-23 15:36 UTC (permalink / raw)
  To: Sean Sieger; +Cc: help-gnu-emacs


Am 23.08.2007 um 17:07 schrieb Sean Sieger:

> when I do
>
> T
>
> in a dired buffer, dired prompts to change timestamp.  Is something
> wrong with my build or configuration of GNU Emacs?

No. What do you expect?

--
Greetings

   Pete

Mac OS X is like a wigwam: no fences, no gates, but an apache inside.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2007-08-23 15:07 dired-do-touch Sean Sieger
  2007-08-23 15:36 ` dired-do-touch Peter Dyballa
@ 2007-08-23 17:39 ` Sean Sieger
  1 sibling, 0 replies; 62+ messages in thread
From: Sean Sieger @ 2007-08-23 17:39 UTC (permalink / raw)
  To: help-gnu-emacs

Sean Sieger <sean.sieger@gmail.com> writes:

   In GNU Emacs 23.0.0.5 (i686-pc-linux-gnu, GTK+ Version 2.10.11) of
   2007-07-31, when I do

   T

   in a dired buffer, dired prompts to change timestamp.

Um, I see this is expected.  Sorry.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2007-08-23 15:23 ` dired-do-touch Sven Joachim
@ 2007-08-23 17:43   ` Sean Sieger
  0 siblings, 0 replies; 62+ messages in thread
From: Sean Sieger @ 2007-08-23 17:43 UTC (permalink / raw)
  To: help-gnu-emacs

Sven Joachim <svenjoac@gmx.de> writes:

   What did you expect 'T' to do?

Thank you for asking.  I was looking for a one-key key-binding in dired
to create a file in the current directory.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
       [not found]   ` <4135e3e50708231035pbc95223m8988de9677ec3c4c@mail.gmail.com>
@ 2007-08-23 18:06     ` Peter Dyballa
       [not found]     ` <mailman.5210.1187892398.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 62+ messages in thread
From: Peter Dyballa @ 2007-08-23 18:06 UTC (permalink / raw)
  To: Sean Sieger; +Cc: GNU Emacs List


Am 23.08.2007 um 19:35 schrieb Sean Sieger:

> I expected that
>
> T <RET> filename <RET>
>
> would create a file.

Dired works only on existing files. And directories. Although there  
is an exception ... see below!

> Is C-x C-f the only way to create a new file in dired or is there a  
> one-key key-binding?

No. You can use *shell* or such buffers to create new files, you can  
copy or rename, or in dired-mode:

	! t o u c h SPC <file name>

>
> On a different note, do you use bookmarks extensively?

No. And neither intensively. Not at all, for short.

--
Greetings

   Pete

Math illiteracy affects 7 out of every 5 Americans.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
@ 2007-08-23 20:06 martin rudalics
  2007-08-23 22:35 ` dired-do-touch Sean Sieger
  0 siblings, 1 reply; 62+ messages in thread
From: martin rudalics @ 2007-08-23 20:06 UTC (permalink / raw)
  To: sean.sieger; +Cc: help-gnu-emacs

 > I was looking for a one-key key-binding in dired
 > to create a file in the current directory.

If you don't like the binding for T try

(define-key dired-mode-map "T" 'find-file)

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2007-08-23 20:06 dired-do-touch martin rudalics
@ 2007-08-23 22:35 ` Sean Sieger
  0 siblings, 0 replies; 62+ messages in thread
From: Sean Sieger @ 2007-08-23 22:35 UTC (permalink / raw)
  To: help-gnu-emacs

martin rudalics <rudalics@gmx.at> writes:

   If you don't like the binding for T try

   (define-key dired-mode-map "T" 'find-file)

Perfect, in fact, I used `t'.

Thank you, you guys, for your patience with me, I like living in GNU
Emacs.  `Self-documenting' is becoming a practical feature for me, even
though it may not show from my initial question.  I don't split my
frames much but that is changing with a lot more C-h m.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
       [not found]     ` <mailman.5210.1187892398.32220.help-gnu-emacs@gnu.org>
@ 2007-08-24  6:32       ` Fabian Braennstroem
  2007-08-24 16:44         ` dired-do-touch Sean Sieger
       [not found]         ` <mailman.5260.1187973928.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 62+ messages in thread
From: Fabian Braennstroem @ 2007-08-24  6:32 UTC (permalink / raw)
  To: help-gnu-emacs



Peter Dyballa schrieb am 08/23/2007 06:06 PM:
> Am 23.08.2007 um 19:35 schrieb Sean Sieger:
> 
>> I expected that
>>
>> T <RET> filename <RET>
>>
>> would create a file.
> 
> Dired works only on existing files. And directories. Although there  
> is an exception ... see below!
> 
>> Is C-x C-f the only way to create a new file in dired or is there a  
>> one-key key-binding?
> 
> No. You can use *shell* or such buffers to create new files, you can  
> copy or rename, or in dired-mode:
> 
> 	! t o u c h SPC <file name>
> 
>> On a different note, do you use bookmarks extensively?
> 
> No. And neither intensively. Not at all, for short.

I use it a lot and it is great; first I used a small macro
to jump to the directories and since yesterday
evening:

     (define-key dired-mode-map "1"
       (lambda ()
         (interactive)
         (bookmark-jump "bookmark name")))

which is a lot faster :-)

Regards!
Fabian

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2007-08-24  6:32       ` dired-do-touch Fabian Braennstroem
@ 2007-08-24 16:44         ` Sean Sieger
       [not found]         ` <mailman.5260.1187973928.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 62+ messages in thread
From: Sean Sieger @ 2007-08-24 16:44 UTC (permalink / raw)
  To: help-gnu-emacs

Fabian Braennstroem <f.braennstroem@gmx.de> writes:

   I use it a lot and it is great; first I used a small macro
   to jump to the directories and since yesterday
   evening:

        (define-key dired-mode-map "1"
          (lambda ()
            (interactive)
            (bookmark-jump "bookmark name")))

   which is a lot faster :-)

I watched that thread as well as looked at explicit `bookmark' threads
back to 2002.  A question that I formulated regarding the above binding
is, why not `j', does the function dired-goto-file serve you well?  C-x
C-f is so reflexive, after a day in GNU Emacs, I do C-x C-f to get to
the shower.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
       [not found]         ` <mailman.5260.1187973928.32220.help-gnu-emacs@gnu.org>
@ 2007-08-24 21:15           ` Fabian Braennstroem
  0 siblings, 0 replies; 62+ messages in thread
From: Fabian Braennstroem @ 2007-08-24 21:15 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Sean,

Sean Sieger schrieb am 08/24/2007 04:44 PM:
> Fabian Braennstroem <f.braennstroem@gmx.de> writes:
> 
>    I use it a lot and it is great; first I used a small macro
>    to jump to the directories and since yesterday
>    evening:
> 
>         (define-key dired-mode-map "1"
>           (lambda ()
>             (interactive)
>             (bookmark-jump "bookmark name")))
> 
>    which is a lot faster :-)
> 
> I watched that thread as well as looked at explicit `bookmark' threads
> back to 2002.  A question that I formulated regarding the above binding
> is, why not `j', does the function dired-goto-file serve you well?  C-x
> C-f is so reflexive, after a day in GNU Emacs, I do C-x C-f to get to
> the shower.

I am not really getting it, but I have around 15 dired
bookmarks using 1-9 and a combination with Control; j, h, l
, k I, g, G , H I use for navigation ( I was a vim user :-) )
Greetings!
Fabian

> 
> 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2011-07-30  9:17           ` dired-do-touch (was: [PATCH] fix goto-line) Juri Linkov
@ 2011-07-30  9:50             ` Juri Linkov
  2011-07-30  9:54             ` dired-do-touch (was: [PATCH] fix goto-line) Andreas Schwab
  1 sibling, 0 replies; 62+ messages in thread
From: Juri Linkov @ 2011-07-30  9:50 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> BTW, I noticed that the docstring of `format-time-string' refers
> to the argument `TIME' whereas the real argument name is `TIMEVAL'.
> Adding something like "\n\(fn FORMAT-STRING &optional TIME UNIVERSAL)"
> to the last line of the docstring would help.

The "\(fn" syntax is used only for the docstrings of Lisp functions.
So it should be
"usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL)"



^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: dired-do-touch
  2011-07-30  9:54             ` dired-do-touch (was: [PATCH] fix goto-line) Andreas Schwab
@ 2011-07-30 11:01               ` Juri Linkov
  0 siblings, 0 replies; 62+ messages in thread
From: Juri Linkov @ 2011-07-30 11:01 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Paul Eggert, emacs-devel

> An empty timestamp should mean running touch without time argument.

Good idea.

But unfortunately `dired-do-chxxx' reads arguments using `read-string'
that can't return an empty string when there are values for M-n.



^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2011-07-30 11:01 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-20 19:05 dired-do-touch Matthew Mundell
2004-03-21 13:31 ` dired-do-touch Ehud Karni
2004-03-21 18:27   ` dired-do-touch Eli Zaretskii
2004-03-21 16:50 ` dired-do-touch Eli Zaretskii
2004-03-21 19:21 ` dired-do-touch Richard Stallman
2004-03-25 14:54 ` dired-do-touch Juri Linkov
2004-03-25 21:07   ` dired-do-touch Juri Linkov
2004-03-27  5:52   ` dired-do-touch Richard Stallman
2004-03-27 10:59     ` dired-do-touch Juri Linkov
2004-03-27 12:17       ` dired-do-touch Eli Zaretskii
2004-03-27 13:06         ` dired-do-touch Juri Linkov
2004-03-27 16:13           ` dired-do-touch Matthew Mundell
2004-03-27 17:52             ` dired-do-touch Juri Linkov
2004-03-28 19:59               ` dired-do-touch Matthew Mundell
2004-03-29  6:59                 ` dired-do-touch Eli Zaretskii
2004-03-29 19:15                   ` dired-do-touch Juri Linkov
2004-03-29 22:24                     ` dired-do-touch Andreas Schwab
2004-03-30  6:50                     ` dired-do-touch Eli Zaretskii
2004-03-30  9:59                       ` dired-do-touch Juri Linkov
2004-03-30 12:35                         ` dired-do-touch Matthew Mundell
2004-03-30 19:43                           ` dired-do-touch Stefan Monnier
2004-03-31  3:14                           ` dired-do-touch Juri Linkov
2004-03-31 15:53                             ` dired-do-touch Matthew Mundell
2004-03-31 15:04                           ` dired-do-touch Richard Stallman
2004-03-31 19:42                             ` dired-do-touch Stefan Monnier
2004-04-02  6:01                               ` dired-do-touch Richard Stallman
2004-04-23 20:57                                 ` dired-do-touch Stefan Monnier
2004-03-30 16:18                     ` dired-do-touch Matthew Mundell
2004-03-29 19:27                 ` dired-do-touch Juri Linkov
2004-03-27 16:09         ` dired-do-touch Matthew Mundell
2004-03-28  4:25       ` dired-do-touch Richard Stallman
     [not found] <20040321165848.0DB3C662F8@imf.math.ku.dk>
2004-03-21 18:12 ` dired-do-touch Lars Hansen
2004-03-22 23:45   ` dired-do-touch Matthew Mundell
2004-03-23  6:31     ` dired-do-touch Eli Zaretskii
2004-03-23 21:48       ` dired-do-touch Matthew Mundell
2004-03-24  7:11         ` dired-do-touch Eli Zaretskii
2004-03-24 10:57           ` dired-do-touch Kim F. Storm
2004-03-24 11:10             ` dired-do-touch Eli Zaretskii
2004-03-24 12:22               ` dired-do-touch Kim F. Storm
2004-03-24 21:59                 ` dired-do-touch Matthew Mundell
2004-03-25  7:10                   ` dired-do-touch Eli Zaretskii
2004-03-24 20:57           ` dired-do-touch Matthew Mundell
2004-03-25  2:00         ` dired-do-touch Richard Stallman
2004-03-26 18:31           ` dired-do-touch Matthew Mundell
2004-03-28  1:36             ` dired-do-touch Richard Stallman
2004-03-28  1:36             ` dired-do-touch Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2004-04-24 15:28 dired-do-touch Lars Hansen
2004-04-24 17:01 ` dired-do-touch Eli Zaretskii
2004-04-24 17:04   ` dired-do-touch Lars Hansen
2007-08-23 15:07 dired-do-touch Sean Sieger
2007-08-23 15:36 ` dired-do-touch Peter Dyballa
     [not found]   ` <4135e3e50708231035pbc95223m8988de9677ec3c4c@mail.gmail.com>
2007-08-23 18:06     ` dired-do-touch Peter Dyballa
     [not found]     ` <mailman.5210.1187892398.32220.help-gnu-emacs@gnu.org>
2007-08-24  6:32       ` dired-do-touch Fabian Braennstroem
2007-08-24 16:44         ` dired-do-touch Sean Sieger
     [not found]         ` <mailman.5260.1187973928.32220.help-gnu-emacs@gnu.org>
2007-08-24 21:15           ` dired-do-touch Fabian Braennstroem
2007-08-23 17:39 ` dired-do-touch Sean Sieger
     [not found] <mailman.5195.1187881677.32220.help-gnu-emacs@gnu.org>
2007-08-23 15:23 ` dired-do-touch Sven Joachim
2007-08-23 17:43   ` dired-do-touch Sean Sieger
2007-08-23 20:06 dired-do-touch martin rudalics
2007-08-23 22:35 ` dired-do-touch Sean Sieger
2011-07-28 12:57 [PATCH] fix goto-line Jose E. Marchesi
2011-07-28 14:07 ` Juanma Barranquero
2011-07-29 11:15   ` Juri Linkov
2011-07-29 11:22     ` Juanma Barranquero
2011-07-29 15:28       ` Juri Linkov
2011-07-29 16:45         ` Paul Eggert
2011-07-30  9:17           ` dired-do-touch (was: [PATCH] fix goto-line) Juri Linkov
2011-07-30  9:50             ` dired-do-touch Juri Linkov
2011-07-30  9:54             ` dired-do-touch (was: [PATCH] fix goto-line) Andreas Schwab
2011-07-30 11:01               ` dired-do-touch Juri Linkov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.