[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39902: 28.0.50; Marking in dired with active region

From: Drew Adams
Subject: bug#39902: 28.0.50; Marking in dired with active region
Date: Wed, 4 Mar 2020 17:11:25 -0800 (PST)

> The peculiarity of dired mode is that it puts point in front of file name.
> So when the region doesn't cover the file name visually, it should not take
> the file name outside the region into consideration for marking.

That's what I said.  It's the navigation keys,
which didn't select complete lines, which led
to the impression that not all files "in" the
region got marked.

It's about creation of the region.  You can
select complete lines, in which case `dired-mark'
does what is expected: marks all of the files
whose (full) lines are selected.

But it's also possible to have `dired-mark'
instead mark all of the files with ANY part of
their line (not ALL of their line) in the region.

> Exactly like kill-region should not kill text outside of the active region,
> dired-mark should not mark files outside of the active region.

Bad analogy.  Especially for purposes of marking or
acting on files "in the region", what's important is
that the region capture _some part_ of a file's line,
not necessarily all of it.

Marking is not, like `kill-region', an action on the
characters of text in the region.  It uses the region
only to indicate a sequence of files to act on.

This, or similar, is the behavior needed, as
Stephen Berman pointed out:

(defun diredp-mark-region-files (&optional unmark-p)
  "Mark all of the files in the current region (if it is active).
With non-nil prefix arg, unmark them instead."
  (interactive "P")
  (let ((beg  (min (point) (mark)))
        (end  (max (point) (mark)))
        (inhibit-field-text-motion  t)) ; Just in case.
    (setq beg  (save-excursion (goto-char beg)
          end  (save-excursion (goto-char end)
    (let ((dired-marker-char  (if unmark-p
      (diredp-mark-if (and (<= (point) end)
                           (>= (point) beg)
                      "region file"))))

> Especially more dangerous command dired-flag-file-deletion
> should not delete files outside of the active region.

Not at all.  The command simply marks; it does not
delete.  Subsequently using `x', to delete, prompts
you for confirmation, specifying the files to be
deleted.  I don't see any danger.

> > (2) Most of the time I rather want `dired-mark-files-regexp' to respect
> > an active region - but that isn't implemented (though it would not be
> > hard to do).  I think that would be useful.
> The problem is that this feature should be implemented in the macro
> dired-mark-if, but then it will affect many other commands:
> dired-mark-files-containing-regexp
> dired-mark-symlinks
> dired-mark-directories
> dired-mark-executables
> dired-flag-auto-save-files
> dired-flag-backup-files
> dired-compare-directories
> dired-mark-unmarked-files
> dired-mark-sexp
> ...

Those are all marking commands, so there's no problem.

That said, I'm not sure it would be a great idea to
have them (or have even just `dired-mark-files-regexp')
act on only the files in the active region.  Maybe,
maybe not.

It's certainly not hard, as a user, to narrow first
and then use such commands (but yes, in that case
you'll want to be sure to get the full lines in the

reply via email to

[Prev in Thread] Current Thread [Next in Thread]