: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
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
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")
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)
(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)
(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)))
(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)