This page describes libraries Lisp:dired-details.el and Lisp:dired-details+.el, which let you hide or show the file and directory details in a Dired listing, to save space and clutter. When details are hidden, all you see (and all IncrementalSearch sees) are the file names.
This functionality is now available by default starting with Emacs 24.4.
The Changelog explains:
New minor mode ``dired-hide-details-mode`` hides details.
According to the Emacs manual:
The command ( (dired-hide-details-mode) toggles whether details, such as ownership or file permissions, are visible in the current Dired buffer. By default, it also hides the targets of symbolic links, and all lines other than the header line and file/directory listings. To change this, customize the options dired-hide-details-hide-symlink-targets and dired-hide-details-hide-information-lines, respectively.
You can run it with either M-x dired-hide-details-mode or ( when in a dired buffer.
Hiding details reduces a verbose directory listing such as this:
-rw-r--r-- 1 rgiardin svrtech 4141 Aug 23 17:07 dired-details.el -rw-r--r-- 1 rgiardin svrtech 56 Aug 23 17:07 linked-file.el -> /var/tmp/checkouts/linked-file.el
to just this:
[...] dired-details.el [...] linked-file.el -> [...]
or to just this, if you set
"" instead of
dired-details.el linked-file.el ->
Here are two screenshots, one showing details, one hiding them:
dired-details+.el provides the following enhancements:
‘dired-details-toggle’to both `
)’ and `
(’, so you don’t need to remember which shows and which hides.
‘dired-details-propagate-flag’). If non-
‘nil’, future Dired buffers you open use the hide/show appearance that you last had.
When editing file names with
‘dired-toggle-read-only’ and committing, everything works as expected, but if changes are aborted details are displayed until the listing is refreshed.
It would be good if when copying text from a dired buffer with details hidden, the details are not also copied (which is what happens at the moment), e.g. when sending somebody a message with a list of filenames. – JoeBloggs
This applies to hidden details in Emacs 23 and later, as well to details hidden by
1. You can control this with user option
‘yank-excluded-properties’. By default, yanking text that has property
‘invisible’ (as is the case here) strips the text of that property, which means that the hidden text is not hidden after yanking.
You can, for example, define a yank command for use in this context that binds
‘yank-excluded-properties’ to its current value minus any
‘invisible’ entry and then calls
‘insert-for-yank’. Such a command could be useful for cases like this, where you want to hide invisible text after yanking.
But Emacs has no way of knowing, unless you tell it, that in general you do want to strip property
‘invisible’ when you yank, but you do not want to strip it in some particular contexts, such as this one.
2. But all of that concerns only yanking in Emacs, not pasting to some other application. It does not remove the text that was invisible, it just keeps it invisible. If you want to actually remove invisible text from the copied string then you need to jump through different hoops. You can do what you want using functions from library subr+.el. Function
‘buffer-substring-visible’, for example, returns the buffer text between any two positions, but with invisible parts of it stripped out. You can see an example of using
‘buffer-substring-visible’ in library narrow-indirect.el – see function
‘ni-buffer-substring-collapsed-visible’, where the buffer text between two limits has its invisible text removed and its whitespace collapsed. – DrewAdams