summaryrefslogtreecommitdiff
path: root/lisp/dired.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2020-03-24 23:58:01 +0200
committerJuri Linkov <juri@linkov.net>2020-03-24 23:58:01 +0200
commitce141686d2d890d9d7c3dd881dc5f9bfb5d6d296 (patch)
tree536d2c09c3f03dc2030618e826ec0cf99bc8bc09 /lisp/dired.el
parente906cd0d58f3197edf15ccb843bc2577b879af61 (diff)
downloademacs-ce141686d2d890d9d7c3dd881dc5f9bfb5d6d296.tar.gz
emacs-ce141686d2d890d9d7c3dd881dc5f9bfb5d6d296.tar.bz2
emacs-ce141686d2d890d9d7c3dd881dc5f9bfb5d6d296.zip
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)
Diffstat (limited to 'lisp/dired.el')
-rw-r--r--lisp/dired.el33
1 files changed, 20 insertions, 13 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 438f5e7d8b4..41bbf9f56a2 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -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)