bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Juri Linkov
Subject: bug#39902: 28.0.50; Marking in dired with active region
Date: Mon, 23 Mar 2020 02:43:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> I took a quick look - didn't check much.  
>
> Seems OK to me too (but I'd prefer a non-nil default
> value for the option, as already mentioned).
>
> ---
>
> However, I notice one thing that seems like a bug
> (didn't notice it before) - and the bug is present even
> without the patch:
>
> If `use-empty-active-region' is non-nil, and the region
> is empty, then `m' marks the current line only sometimes,
> depending on where point is.  And the behavior differs,
> depending on the value of option `dired-mark-inclusive':
>
> `dired-mark-inclusive' = nil:
>
>    marks line only if point is on the 2nd file-name
>    char or any char after that (including eol, i.e.,
>    _after_ the file name)
>
> `dired-mark-inclusive' = t:
>
>    marks only if point is not at bol
>
> IMO, the behavior should be the same, regardless of
> the cursor position on the line.  I think it should
> mark the line:
>
> * for any position, if `dired-mark-inclusive' = t
> * for any position on the file name, otherwise
>
> Juri, you decide the behavior for the nil case, but
> I think it should be consistent.  Personally, I see
> no reason that point on the first file-name char
> would act differently from point on the second.  And
> by the logic of non-inclusive I'd think that an empty
> region _after_ the file name wouldn't mark the line
> (no part of the file name is in the region).
>
> For the non-nil case, I think it's important that the
> line get marked even when point is at bol.
>
> Why?  Consistency.  And it's easy to hit `C-SPC'
> without realizing that you've done so - there's no
> good visual signal (just the "Mark activated" msg).
>
> In the non-nil case, especially, I really feel that
> a user expects the line to be marked, even if the
> region is empty (when `use-empty-active-region' is
> non-nil).
>
> ---
>
> As I said earlier, I really suspect that Emacs may
> have lurking bugs because stuff that makes use of
> `use-region-p' might not get tested with non-nil
> `use-empty-active-region'.  And yet the reason for
> creating that option was for the addition of that
> function (or vice versa).
>
> [Frankly, I think things were clearer in the code
> before `use-region-p' and that option were added.
> `region-active-p' was clear; `use-region-p' hides
> use of an option, and I suspect that the non-nil
> case doesn't get tested much.  When just
> `region-active-p' was used, it kinda invited testing
> whether the region was empty.]
>
> (FWIW, I don't use non-nil `use-empty-active-region'.
> But I imagine some people do.)

Sorry, I received your message only after I pushed to master.
But nonetheless, your test cases should be handled carefully.
The simplest solution would be just to disallow the option
`use-empty-active-region' to use the empty region in Dired,
i.e. instead of

  (if (use-region-p)
  ... then mark files in the active region ...

to use

  (if (let ((use-empty-active-region nil)) (use-region-p))
  ... then mark files in the active region ...





reply via email to

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