Emacs 26.1 Windows 10, Dired

  1. Show content of folder "myproject". All files and subfolders.

  2. M-x dired-maybe-insert-subdir (C-u i) -R and here result

enter image description here


Now I want to mark only folder build

  1. %m

  2. ^build$

But I get message:

0 matching files marked


1 Answer 1


You want to match all files whose relative file names (no directory part) match ^build$. The answer, in the version of dired+.el that you have, is to use a negative prefix arg. That's the short answer, for the version you have, but please read on.

The Dired+ command didn't correspond to the doc string (which was correct), concerning what the regexp is matched against. I've fixed that now.

In the version before the fix, as just mentioned, you needed to use a negative prefix arg (e.g. M--) to match against only the relative file-name part (no directory part).

Now (after the fix) that's the default behavior, just as the doc string said - no prefix arg (to mark) or a plain prefix arg (C-u, to unmark) means match against the relative file name.

In any case, there's a lot of functionality (controlled by the prefix arg) that's rolled into % m (command dired-mark-files-regexp), so it can be confusing.

C-h f tells you:

dired-mark-files-regexp is an interactive Lisp function in dired+.el.

(dired-mark-files-regexp REGEXP &optional MARKER-CHAR LOCALP)

Mark all file names matching REGEXP for use in later commands.

. and .. are never marked or unmarked by this command.

Whether to mark or unmark, and what form of file name to match, are governed by the prefix argument. For this, a plain (C-u) or a double-plain (C-u C-u) prefix arg is considered only as such - it is not considered numerically.

Whether to mark or unmark:

  • No prefix arg, a positive arg, or a negative arg means mark.

  • Plain (C-u), double-plain (C-u C-u), or zero (e.g. M-0) means unmark.

The form of a file name used for matching:

  • No prefix arg (to mark) or a plain prefix arg (C-u, to unmark) means use the relative file name (no directory part).

  • A negative arg (e.g. M--, to mark) or a zero arg (e.g. M-0, to unmark) means use the absolute file name, that is, including all directory components.

  • A positive arg (e.g. M-+, to mark) or a double plain arg (C-u C-u, to unmark) means construct the name relative to default-directory. For an entry in an inserted subdir listing, this means prefix the relative file name (no directory part) with the subdir name relative to default-directory.

Note that the default matching behavior of this command is different for Dired+ than it is for vanilla Emacs. Using a positive prefix arg or a double plain prefix arg (C-u C-u) gives you the same behavior as vanilla Emacs (marking or unmarking, respectively): matching against names that are relative to the default-directory.

What Dired+ offers in addition is the possibility to match against names that are relative (have no directory part - no prefix arg or C-u to mark and unmark, respectively) or absolute (M-- or M-0, respectively).

The default behavior uses relative names because this is likely to be the more common use case. But matching against absolute names gives you more flexibility.

REGEXP is an Emacs regexp, not a shell wildcard. Thus, use \.o$ for object files -- just .o might mark more than you might expect.

REGEXP is added to regexp-search-ring, for regexp search.


  • MARKER-CHAR is the marker character - used for dired-marker-char.

  • LOCALP is passed to dired-get-filename. It determines the form of filename that is matched against REGEXP.

  • I'm not found new version of dired+ package in MELPA. When I can download and how install it? Thanks Oct 12, 2019 at 16:28
  • None of my libraries are on MELPA anymore. MELPA no longer pulls from Emacs Wiki. The library is here: emacswiki.org/emacs/download/dired%2b.el. (And there are two links to it in the answer.)
    – Drew
    Oct 12, 2019 at 23:28
  • I never download file not from MELPA. So to install dired+ I need: 1. Download dired+.el from here emacswiki.org/emacs/download/dired%2b.el to my custom Emacs folder (~/.emacs.d/elpa/dired+) , 2. In my init.el add (setq diredp-file "~/.emacs.d/elpa/dired+/dired+.el") (load diredp-file). Is it correct? Or has more simple approach to install dired+ ? Oct 13, 2019 at 16:11
  • 1
    Download dired+.el. Byte-compile it (B in Dired). Put dired+.el and dired+.elc in a directory that is in your load-path: (add-to-list 'load-path "/path/to/your/lisp/libraries"). Add (require 'dired+) to your init file. So your init file will contain code adding "/path/to/your/lisp/libraries/" to variable load-path, followed by (require 'dired+).
    – Drew
    Oct 13, 2019 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.