gnu-emacs-sources
[Top][All Lists]
Advanced

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

modification to dired to allow an "or" syntax


From: Tom Wurgler
Subject: modification to dired to allow an "or" syntax
Date: Mon, 1 Dec 2003 10:02:54 -0500 (EST)

Defadvice to allow a "|" to act as an "or" construct for dired.

I was all the time wanting to limit what files dired would show me.
M-x dired > a* would give all files starting with "a" etc, but I
wanted to be able to give multiple strings, and so came up with this.

Tested on unix csh and sh shells.

Usage: M-x dired > string1|string2 causes dired to just list the files
that have string1 OR string2 in the name.

(defadvice dired (before allow_for_or activate)
  "Allows using a `|' as an `or' operator in dired.
For example, when it prompts for the directory to dired, typing a|b
direds all files containing string a along with files that contain
string b.  No limit on the number of `|'."
  (if (string-match "|" dirname)
      (let ((dir)
            (file))
        (setq dir (file-name-directory dirname))
        (setq file (file-name-nondirectory dirname))
        (setq dir (concat dir "*{"))
        (while (string-match "|" file)
          (setq dir (concat dir (substring file 0 (1- (match-end 0))) ","))
          (setq file (substring file (match-end 0))))
        (setq dirname (concat dir file "}*")))))
                                        




reply via email to

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