Rename dired-mark-region choices and ignore empty region.
* lisp/dired.el (dired-mark-region): Rename choices 'exclusive' to 'file', and 'inclusive' to 'line'. (dired-mark-if, dired-mark): Check for non-empty region explicitly instead of using use-region-p to ignore non-nil value of use-empty-active-region. (Bug#39902)
This commit is contained in:
parent
e906cd0d58
commit
ce141686d2
2 changed files with 22 additions and 15 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -104,8 +104,8 @@ shows equivalent key bindings for all commands that have them.
|
|||
*** New option 'dired-mark-region' affects all Dired commands that mark files.
|
||||
When non-nil and the region is active in Transient Mark mode,
|
||||
then Dired commands operate only on files in the active region.
|
||||
The values 'exclusive' and 'inclusive' of this option define
|
||||
the details of marking the last file at the end of the region.
|
||||
The values 'file' and 'line' of this option define the details of
|
||||
marking the file at the end of the region.
|
||||
|
||||
*** State changing VC operations are supported in dired-mode on files
|
||||
(but still not on directories).
|
||||
|
|
|
@ -296,7 +296,7 @@ new Dired buffers."
|
|||
:version "26.1"
|
||||
:group 'dired)
|
||||
|
||||
(defcustom dired-mark-region 'exclusive
|
||||
(defcustom dired-mark-region 'file
|
||||
"Defines what commands that mark files do with the active region.
|
||||
|
||||
When nil, marking commands don't operate on all files in the
|
||||
|
@ -306,7 +306,8 @@ When the value of this option is non-nil, then all Dired commands
|
|||
that mark or unmark files will operate on all files in the region
|
||||
if the region is active in Transient Mark mode.
|
||||
|
||||
When `exclusive', don't mark the file if the end of the region is
|
||||
When `file', the region marking is based on the file name.
|
||||
This means don't mark the file if the end of the region is
|
||||
before the file name displayed on the Dired line, so the file name
|
||||
is visually outside the region. This behavior is consistent with
|
||||
marking files without the region using the key `m' that advances
|
||||
|
@ -315,12 +316,13 @@ of keys used to mark files is the same as the number of keys
|
|||
used to select the region, e.g. `M-2 m' marks 2 files, and
|
||||
`C-SPC M-2 n m' marks 2 files, and `M-2 S-down m' marks 2 files.
|
||||
|
||||
When `inclusive', include the file into marking if the end of the region
|
||||
When `line', the region marking is based on Dired lines,
|
||||
so include the file into marking if the end of the region
|
||||
is anywhere on its Dired line, except the beginning of the line."
|
||||
:type '(choice
|
||||
(const :tag "Don't mark files in active region" nil)
|
||||
(const :tag "Exclude file name outside of region" exclusive)
|
||||
(const :tag "Include the file at region end line" inclusive))
|
||||
(const :tag "Exclude file name outside of region" file)
|
||||
(const :tag "Include the file at region end line" line))
|
||||
:group 'dired
|
||||
:version "28.1")
|
||||
|
||||
|
@ -646,16 +648,19 @@ of the region if `dired-mark-region' is non-nil. Otherwise, operate
|
|||
on the whole buffer.
|
||||
|
||||
Return value is the number of files marked, or nil if none were marked."
|
||||
`(let ((inhibit-read-only t) count
|
||||
(beg (if (and dired-mark-region (use-region-p))
|
||||
`(let* ((inhibit-read-only t) count
|
||||
(use-region-p (and dired-mark-region
|
||||
(region-active-p)
|
||||
(> (region-end) (region-beginning))))
|
||||
(beg (if use-region-p
|
||||
(save-excursion
|
||||
(goto-char (region-beginning))
|
||||
(line-beginning-position))
|
||||
(point-min)))
|
||||
(end (if (and dired-mark-region (use-region-p))
|
||||
(end (if use-region-p
|
||||
(save-excursion
|
||||
(goto-char (region-end))
|
||||
(if (if (eq dired-mark-region 'inclusive)
|
||||
(if (if (eq dired-mark-region 'line)
|
||||
(not (bolp))
|
||||
(get-text-property (1- (point)) 'dired-filename))
|
||||
(line-end-position)
|
||||
|
@ -673,7 +678,7 @@ Return value is the number of files marked, or nil if none were marked."
|
|||
(if (eq dired-del-marker dired-marker-char)
|
||||
" for deletion"
|
||||
"")
|
||||
(if (and dired-mark-region (use-region-p))
|
||||
(if use-region-p
|
||||
" in region"
|
||||
"")))
|
||||
(goto-char beg)
|
||||
|
@ -691,7 +696,7 @@ Return value is the number of files marked, or nil if none were marked."
|
|||
(if (eq dired-marker-char ?\s) "un" "")
|
||||
(if (eq dired-marker-char dired-del-marker)
|
||||
"flagged" "marked")
|
||||
(if (and dired-mark-region (use-region-p))
|
||||
(if use-region-p
|
||||
" in region"
|
||||
""))))
|
||||
(and (> count 0) count)))
|
||||
|
@ -3645,14 +3650,16 @@ this subdir."
|
|||
(interactive (list current-prefix-arg t))
|
||||
(cond
|
||||
;; Mark files in the active region.
|
||||
((and dired-mark-region interactive (use-region-p))
|
||||
((and interactive dired-mark-region
|
||||
(region-active-p)
|
||||
(> (region-end) (region-beginning)))
|
||||
(save-excursion
|
||||
(let ((beg (region-beginning))
|
||||
(end (region-end)))
|
||||
(dired-mark-files-in-region
|
||||
(progn (goto-char beg) (line-beginning-position))
|
||||
(progn (goto-char end)
|
||||
(if (if (eq dired-mark-region 'inclusive)
|
||||
(if (if (eq dired-mark-region 'line)
|
||||
(not (bolp))
|
||||
(get-text-property (1- (point)) 'dired-filename))
|
||||
(line-end-position)
|
||||
|
|
Loading…
Add table
Reference in a new issue