From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#39902: 28.0.50; Marking in dired with active region Date: Fri, 20 Mar 2020 01:54:36 +0200 Organization: LINKOV.NET Message-ID: <87o8sruchv.fsf@mail.linkov.net> References: <87d09suras.fsf@web.de> <87y2sbloaa.fsf@mail.linkov.net> <877dzvgd4l.fsf@web.de> <8736aiqu3y.fsf@mail.linkov.net> <7a0a6f19-f958-4b38-beaf-3d60dc8a279f@default> <87d09lb1ts.fsf@mail.linkov.net> <87a74n4vet.fsf@web.de> <87eetzah2s.fsf@mail.linkov.net> <87zhcn9229.fsf@mail.linkov.net> <6d82d04a-db94-4df4-82cc-3ea13a78a4dd@default> <877dzqidzn.fsf@mail.linkov.net> <1e37a524-80d3-445f-8f81-a18539105ac3@default> <87pndhhyvk.fsf@mail.linkov.net> <1ce62594-cc2a-4e95-b2b3-d022fa65decd@default> <87bloybivx.fsf@mail.linkov.net> <0066d43a-5f97-4c9d-a4b7-84c6b0ecf356@default> <87bloxgp9g.fsf@mail.linkov.net> <8736a7ajn5.fsf@web.de> <87fte52pbf.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="49875"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 39902@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 20 00:59:17 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jF54H-000Csd-KL for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 20 Mar 2020 00:59:17 +0100 Original-Received: from localhost ([::1]:44474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jF54G-0002U4-9F for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Mar 2020 19:59:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48340) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jF544-0002Tp-G5 for bug-gnu-emacs@gnu.org; Thu, 19 Mar 2020 19:59:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jF542-0004Mg-US for bug-gnu-emacs@gnu.org; Thu, 19 Mar 2020 19:59:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jF542-0004Ly-OQ for bug-gnu-emacs@gnu.org; Thu, 19 Mar 2020 19:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jF542-0001qt-NL for bug-gnu-emacs@gnu.org; Thu, 19 Mar 2020 19:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Mar 2020 23:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39902 X-GNU-PR-Package: emacs Original-Received: via spool by 39902-submit@debbugs.gnu.org id=B39902.15846623147065 (code B ref 39902); Thu, 19 Mar 2020 23:59:02 +0000 Original-Received: (at 39902) by debbugs.gnu.org; 19 Mar 2020 23:58:34 +0000 Original-Received: from localhost ([127.0.0.1]:43777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jF53a-0001pt-1W for submit@debbugs.gnu.org; Thu, 19 Mar 2020 19:58:34 -0400 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:49053) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jF53X-0001pe-FB for 39902@debbugs.gnu.org; Thu, 19 Mar 2020 19:58:32 -0400 Original-Received: from mail.gandi.net (m91-129-96-173.cust.tele2.ee [91.129.96.173]) (Authenticated sender: juri@linkov.net) by relay11.mail.gandi.net (Postfix) with ESMTPSA id E43C3100004; Thu, 19 Mar 2020 23:58:23 +0000 (UTC) In-Reply-To: <87fte52pbf.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 19 Mar 2020 01:51:27 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177554 Archived-At: --=-=-= Content-Type: text/plain >> I see our different views as of the same right and value. And the use >> case (who uses marking commands with an active region at all?) is a >> corner case. I don't mind about the default as long as there is a new >> option. > > So Dired could do the same and support both range types using a new option > 'dired-mark-inclusive'. > >> I would rather want to discuss what else should be done >> (behavior of other marking commands etc, should we change >> `dired-mark-if', etc. > > I think `dired-mark-if' should respect that option too. Here is a complete implementation, please try if it works for you: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-mark-inclusive.patch diff --git a/lisp/dired.el b/lisp/dired.el index a4de51f609..6858245ab7 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -296,6 +296,12 @@ dired-always-read-filesystem :version "26.1" :group 'dired) +(defcustom dired-mark-inclusive nil + "Non-nil means `dired-mark' is inclusive." + :type 'boolean + :version "28.1" + :group 'dired) + ;; Internal variables (defvar dired-marker-char ?* ; the answer is 42 @@ -613,7 +619,21 @@ dired-mark-if MSG is a noun phrase for the type of files being marked. It should end with a noun that can be pluralized by adding `s'. Return value is the number of files marked, or nil if none were marked." - `(let ((inhibit-read-only t) count) + `(let ((inhibit-read-only t) count + (beg (if (use-region-p) + (save-excursion + (goto-char (region-beginning)) + (line-beginning-position)) + (point-min))) + (end (if (use-region-p) + (save-excursion + (goto-char (region-end)) + (if (if dired-mark-inclusive + (not (bolp)) + (get-text-property (1- (point)) 'dired-filename)) + (line-end-position) + (line-beginning-position))) + (point-max)))) (save-excursion (setq count 0) (when ,msg @@ -626,8 +646,8 @@ dired-mark-if (if (eq dired-del-marker dired-marker-char) " for deletion" ""))) - (goto-char (point-min)) - (while (not (eobp)) + (goto-char beg) + (while (< (point) end) (when ,predicate (unless (= (following-char) dired-marker-char) (delete-char 1) @@ -3597,7 +3622,12 @@ dired-mark (end (region-end))) (dired-mark-files-in-region (progn (goto-char beg) (line-beginning-position)) - (progn (goto-char end) (line-beginning-position)))))) + (progn (goto-char end) + (if (if dired-mark-inclusive + (not (bolp)) + (get-text-property (1- (point)) 'dired-filename)) + (line-end-position) + (line-beginning-position))))))) ;; Mark subdir files from the subdir headerline. ((dired-get-subdir) (save-excursion (dired-mark-subdir-files))) --=-=-=--