unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22894: 25.1.50; dired-mark: Not remark a marked file
@ 2016-03-03 10:09 Tino Calancha
  2016-03-04 12:31 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Tino Calancha @ 2016-03-03 10:09 UTC (permalink / raw)
  To: 22894

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]



* lisp/dired.el (dired-mark-files-in-region,dired-mark):
A marked file can be remarked just:
1) To mark for deletion.
2) To unmark it, that is, the mark changes to `?\\s'.
3) If its marked for deletion, a different mark can be assigned.

The purpose of this changes is to prevent changing accidentally
the mark of a file. Current code allow to change marks on files very
easily.

Marking many files using several markers may need some time, with
some regexp gimnastics. Its a pity if someone accidentaly change
one of the marks. For instance, using `dired-mark-files-in-region',
the last/first file in the region could be included unintentionally
changing the mark of one file.


I'm not sure if allow 1) or to ban it.
I'm not sure if someone find this thread useful either :-)

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.29)
  of 2016-03-03 built on calancha-pc
Repository revision: 887f6126c5ce9084f93083765ac026ca6b28175c

[-- Attachment #2: Type: text/plain, Size: 3428 bytes --]

diff --git a/lisp/dired.el b/lisp/dired.el
index 6c7445c..057e533 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3215,20 +3215,29 @@ dired-file-marker
 	       (following-char))))))
 
 (defun dired-mark-files-in-region (start end)
+  "Mark all files inside the region in the Dired buffer.
+The mark MARK of a file already marked only changes if:
+1) MARK equals to `dired-del-marker'.
+2) `dired-marked-char' equals to `?\\s' or `dired-del-marker'."
+
   (let ((inhibit-read-only t))
     (if (> start end)
-	(error "start > end"))
-    (goto-char start)			; assumed at beginning of line
+    (error "start > end"))
+    (goto-char start)           ; assumed at beginning of line
     (while (< (point) end)
       ;; Skip subdir line and following garbage like the `total' line:
       (while (and (< (point) end) (dired-between-files))
-	(forward-line 1))
-      (if (and (not (looking-at-p dired-re-dot))
-	       (dired-get-filename nil t))
-	  (progn
-	    (delete-char 1)
-	    (insert dired-marker-char)))
-      (forward-line 1))))
+    (forward-line 1))
+      (when (and (not (looking-at-p dired-re-dot))
+                 (or (looking-at-p "^ ")
+                     (looking-at-p (concat "^" (regexp-quote (char-to-string dired-del-marker))))
+                     (eq dired-marker-char ?\s)
+                     (eq dired-marker-char dired-del-marker))
+                 (dired-get-filename nil t))
+        (delete-char 1)
+        (insert dired-marker-char))
+      (forward-line 1))
+    (deactivate-mark 'force)))
 
 (defun dired-mark (arg &optional interactive)
   "Mark the file at point in the Dired buffer.
@@ -3237,6 +3246,10 @@ dired-mark
 
 If on a subdir headerline, mark all its files except `.' and `..'.
 
+The mark MARK of a file already marked only changes if:
+1) MARK equals to `dired-del-marker'.
+2) `dired-marked-char' equals to `?\\s' or `dired-del-marker'.
+
 Use \\[dired-unmark-all-files] to remove all marks
 and \\[dired-unmark] on a subdir to remove the marks in
 this subdir."
@@ -3246,10 +3259,10 @@ dired-mark
    ((and interactive (use-region-p))
     (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) (line-beginning-position))))))
+        (end (region-end)))
+    (dired-mark-files-in-region
+     (progn (goto-char beg) (line-beginning-position))
+     (progn (goto-char end) (line-beginning-position))))))
    ;; Mark subdir files from the subdir headerline.
    ((dired-get-subdir)
     (save-excursion (dired-mark-subdir-files)))
@@ -3258,7 +3271,11 @@ dired-mark
     (let ((inhibit-read-only t))
       (dired-repeat-over-lines
        (prefix-numeric-value arg)
-       (function (lambda () (delete-char 1) (insert dired-marker-char))))))))
+       (function (lambda () (when (or (looking-at-p "^ ")
+                                      (looking-at-p (concat "^" (regexp-quote (char-to-string dired-del-marker))))
+                                      (eq dired-marker-char ?\s)
+                                      (eq dired-marker-char dired-del-marker))
+                              (delete-char 1) (insert dired-marker-char)))))))))
 
 (defun dired-unmark (arg &optional interactive)
   "Unmark the file at point in the Dired buffer.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#22894: 25.1.50; dired-mark: Not remark a marked file
  2016-03-03 10:09 bug#22894: 25.1.50; dired-mark: Not remark a marked file Tino Calancha
@ 2016-03-04 12:31 ` Lars Ingebrigtsen
  2016-03-05 13:41   ` Tino Calancha
  2016-03-05 14:06   ` Tino Calancha
  0 siblings, 2 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2016-03-04 12:31 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 22894

Tino Calancha <f92capac@gmail.com> writes:

> Marking many files using several markers may need some time, with
> some regexp gimnastics. Its a pity if someone accidentaly change
> one of the marks. For instance, using `dired-mark-files-in-region',
> the last/first file in the region could be included unintentionally
> changing the mark of one file.
>
> I'm not sure if allow 1) or to ban it.
> I'm not sure if someone find this thread useful either :-)

You're right.  :-)  I think if the user tries to change the marks in a
region, then the marks in the region should be changed.  So I'm not sure
I understand the use case at all...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22894: 25.1.50; dired-mark: Not remark a marked file
  2016-03-04 12:31 ` Lars Ingebrigtsen
@ 2016-03-05 13:41   ` Tino Calancha
  2016-03-05 18:59     ` Drew Adams
  2016-03-05 14:06   ` Tino Calancha
  1 sibling, 1 reply; 6+ messages in thread
From: Tino Calancha @ 2016-03-05 13:41 UTC (permalink / raw)
  To: 22894


> You're right.  :-)  I think if the user tries to change the marks in a
> region, then the marks in the region should be changed.  So I'm not sure
> I understand the use case at all...
User can change the marks with:
1) `dired-change-marks': this is, IMO, the recommended way: you control 
what you want to change, let's say, the mark 'F' into the mark 'G'.
2) Calling `dired-mark-files-regexp': the patch does't prevent this 
function changing mark 'F' into `dired-marker-char'.
3) Calling `dired-flag-file-deletion', that is, changing from mark 'F'
to 'D' (that is what i called before 1) in previous comunication).
4) In two steps: unmarking the file, and after that marking it.

What i am trying to prevent is related with `dired-mark' and 
`dired-mark-files-in-region'. The former is bound to 'm'. I can imagine
someone, keeping push the 'm' button to mark a bunch of files, and 
releasing such button one fraction of seocnd late, so one marked file with
'F' get remarked by `dired-marker-char'.
Similar thing could happen if using the second function setting the region 
not very carefully (pick uping one additional file up/down in the region).

The patch just prevent in this two function, one marked file be remarked. 
Those files still not marked are marked.

I am against to restrict users, and i understand this thread is 
controversial, but i use a lot these features and i believe it could
prevent people (including me) doing unintentional changes.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22894: 25.1.50; dired-mark: Not remark a marked file
  2016-03-04 12:31 ` Lars Ingebrigtsen
  2016-03-05 13:41   ` Tino Calancha
@ 2016-03-05 14:06   ` Tino Calancha
  2016-07-01  3:22     ` npostavs
  1 sibling, 1 reply; 6+ messages in thread
From: Tino Calancha @ 2016-03-05 14:06 UTC (permalink / raw)
  To: 22894


>i believe it could prevent people (including me) doing unintentional 
>changes.
I miss a point: certainly we could use 'dired-undo' so i lost my main
argument.
I still don't like `dired-mark' remarking but now becames a matter of 
taste, so i agree to keep the things as they are.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22894: 25.1.50; dired-mark: Not remark a marked file
  2016-03-05 13:41   ` Tino Calancha
@ 2016-03-05 18:59     ` Drew Adams
  0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2016-03-05 18:59 UTC (permalink / raw)
  To: Tino Calancha, 22894

Hi Tino,

> What i am trying to prevent is related with `dired-mark' and
> `dired-mark-files-in-region'. The former is bound to 'm'. I can
> imagine someone, keeping push the 'm' button to mark a bunch of files,
> and releasing such button one fraction of seocnd late, so one marked
> file with 'F' get remarked by `dired-marker-char'.
> Similar thing could happen if using the second function setting the
> region not very carefully (pick uping one additional file up/down
> in the region).
> 
> The patch just prevent in this two function, one marked file be
> remarked. Those files still not marked are marked.

Doesn't sound like a great idea, to me.  At most it should be
optional behavior: a user choice.

Novice users, whom one could think might benefit most from this
protection, will not benefit from it, because they are not likely
to have changed marks.

(In my experience, very few people are even aware of the ability
to change marks, and this is true even of people who have been
developing and maintaining Emacs.)

> I am against to restrict users, and i understand this thread is
> controversial, but i use a lot these features and i believe it
> could prevent people (including me) doing unintentional changes.

But also intentional changes.  Users who know about and use the
ability to change marks should be able to mark over changed marks
with `*', including with `m' and using the region.

You say that you have been using this feature for a while and
appreciate it.  That is the best argument for it, I guess.

If this behavior is optional then it is OK, but I don't see a
great use case for it.  And you mention undo, which also argues
against this.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22894: 25.1.50; dired-mark: Not remark a marked file
  2016-03-05 14:06   ` Tino Calancha
@ 2016-07-01  3:22     ` npostavs
  0 siblings, 0 replies; 6+ messages in thread
From: npostavs @ 2016-07-01  3:22 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 22894

tags 22894 wontfix
close 22894
quit

Tino Calancha <f92capac@gmail.com> writes:

>> i believe it could prevent people (including me) doing unintentional
>> changes.
> I miss a point: certainly we could use 'dired-undo' so i lost my main
> argument.
> I still don't like `dired-mark' remarking but now becames a matter of
> taste, so i agree to keep the things as they are.

Hence closing.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-07-01  3:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 10:09 bug#22894: 25.1.50; dired-mark: Not remark a marked file Tino Calancha
2016-03-04 12:31 ` Lars Ingebrigtsen
2016-03-05 13:41   ` Tino Calancha
2016-03-05 18:59     ` Drew Adams
2016-03-05 14:06   ` Tino Calancha
2016-07-01  3:22     ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).