emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ! in Dired--what was the outcome?


From: Luc Teirlinck
Subject: Re: ! in Dired--what was the outcome?
Date: Mon, 4 Oct 2004 12:27:36 -0500 (CDT)

What is wrong with the solution I proposed earlier?

Currently ? and * expand if and only if they are surrounded on both
sides by whitespace.

There are two problems.

One might want to use an isolated * (or less likely ?) as a wildcard.
The Emacs manual recommends using *"" (or ?"") in those cases.  The *
(or ?) is no longer surrounded by whitespace, so Emacs does not
expand.  To the shell, "" does not make any difference.

Our discussion was concerned with the opposite problem.  One wants to
expand ? in cases where it is not surrounded by whitespace, to add
prefixes or extensions to a bunch of file names.  I proposed to solve
this problem in a similar way to the opposite problem.  Namely make *
and ?  expand if and only if they are surrounded on both sides by
whitespace _or_ ''.  That is, we would treat a pair of single-quotes
as equivalent to whitespace for expansion purposes.  As for "", ''
does not make any difference for the shell.

So one could do

mv ? .''?

or:

mv ? ?''.uu

to prepend . or append .uu to a bunch of marked files.

The corresponding trick for * will very seldom be useful, but it
probably is better to make it work for * too, just for consistency.

Here is the patch to dired-aux (which I proposed earlier) that
implements the above:

===File ~/dired-aux-diff====================================
*** dired-aux.el        19 Jul 2004 11:13:15 -0500      1.126
--- dired-aux.el        21 Aug 2004 16:28:30 -0500      
***************
*** 43,50 ****
  ;;;###begin dired-cmd.el
  ;; Diffing and compressing
  
! (defconst dired-star-subst-regexp "\\(^\\|[ \t]\\)\\*\\([ \t]\\|$\\)")
! (defconst dired-quark-subst-regexp "\\(^\\|[ \t]\\)\\?\\([ \t]\\|$\\)")
  
  ;;;###autoload
  (defun dired-diff (file &optional switches)
--- 43,52 ----
  ;;;###begin dired-cmd.el
  ;; Diffing and compressing
  
! (defconst dired-star-subst-regexp
!   "\\(^\\|[ \t]\\|''\\)\\*\\([ \t]\\|''\\|$\\)")
! (defconst dired-quark-subst-regexp
!   "\\(^\\|[ \t]\\|''\\)\\?\\([ \t]\\|''\\|$\\)")
  
  ;;;###autoload
  (defun dired-diff (file &optional switches)
***************
*** 540,546 ****
             (lambda (x)
               (let ((retval command))
                 (while (string-match
!                        "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval)
                   (setq retval (replace-match x t t retval 2)))
                 retval))
           (lambda (x) (concat command dired-mark-separator x)))))
--- 542,549 ----
             (lambda (x)
               (let ((retval command))
                 (while (string-match
!                        "\\(^\\|[ \t]\\|''\\)\\([*?]\\)\\([ \t]\\|''\\|$\\)"
!                        retval)
                   (setq retval (replace-match x t t retval 2)))
                 retval))
           (lambda (x) (concat command dired-mark-separator x)))))
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]