Fix the effects and documentation of 'dired-free-space'

* lisp/dired.el (dired-free-space): Fix doc string and Custom tags.
(dired--insert-disk-space): When 'dired-free-space' is 'separate',
return the position of the beginning of the disk-space line, to be
compatible with pre-Emacs 29 behavior under
'dired-hide-details-mode'.  (Bug#65186)

* doc/emacs/dired.texi (Misc Dired Features): Fix wording in
documentation of 'dired-free-space'.
This commit is contained in:
Eli Zaretskii 2023-08-10 09:06:05 +03:00
parent 75c72e59f6
commit 97b8ac376b
2 changed files with 27 additions and 14 deletions

View file

@ -1726,12 +1726,17 @@ rotation is lossless, and uses an external utility called
@section Other Dired Features @section Other Dired Features
@vindex dired-free-space @vindex dired-free-space
By default, Dired will display the available space on the disk in By default, Dired displays the available space on the directory's
the first line. This is the @code{first} value of the disk on the first line of that directory listing, following the
@code{dired-free-space} variable. If you set this to directory name. You can control this display by customizing the
@code{separate} instead, Dired will display this on a separate line variable @code{dired-free-space}. Its default value is @code{first},
(including the space the files in the current directory takes). If which produces the available space after the directory name. If you
you set this to @code{nil}, the free space isn't displayed at all. customize it to the value @code{separate} instead, Dired will display
the disk space information on a separate line, following the line with
the directory name, and will include in that line the space used by
the files in the current directory as well as the available disk
space. If you set this to @code{nil}, the available disk space
information will not be displayed at all.
@kindex + @r{(Dired)} @kindex + @r{(Dired)}
@findex dired-create-directory @findex dired-create-directory

View file

@ -218,14 +218,19 @@ If t, they are marked if and as the files linked to were marked.
If a character, new links are unconditionally marked with that character.") If a character, new links are unconditionally marked with that character.")
(defcustom dired-free-space 'first (defcustom dired-free-space 'first
"Whether and how to display the amount of free disk space in Dired buffers. "Whether and how to display the disk space usage info in Dired buffers.
If nil, don't display. If nil, don't display.
If `separate', display on a separate line (along with used count). If `separate', display on a separate line, and include both the used
If `first', display only the free disk space on the first line, and the free disk space.
following the directory name." If `first', the default, display only the free disk space on the first
:type '(choice (const :tag "On a separate line" separate) line, following the directory name."
(const :tag "On the first line, after directory name" first) :type '(choice (const
(const :tag "Don't display" nil)) :tag
"On separate line, display both used and free space" separate)
(const
:tag
"On first line, after directory name, display only free space" first)
(const :tag "Don't display disk space usage" nil))
:version "29.1" :version "29.1"
:group 'dired) :group 'dired)
@ -1769,7 +1774,10 @@ see `dired-use-ls-dired' for more details.")
((eq dired-free-space 'separate) ((eq dired-free-space 'separate)
(end-of-line) (end-of-line)
(insert " available " available) (insert " available " available)
(forward-line 1) ;; The separate free-space line is considered part of the
;; directory content, for the purposes of
;; 'dired-hide-details-mode'.
(beginning-of-line)
(point)) (point))
((eq dired-free-space 'first) ((eq dired-free-space 'first)
(goto-char beg) (goto-char beg)