From: Tino Calancha <f92capac@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Tino Calancha <f92capac@gmail.com>,
22893@debbugs.gnu.org, larsi@gnus.org
Subject: bug#22893: 25.1.50; dired-get-marked-files get all marked
Date: Thu, 10 Mar 2016 13:19:10 +0900 (JST) [thread overview]
Message-ID: <alpine.LRH.2.20.1603101317100.23082@calancha-ilc.kek.jp> (raw)
In-Reply-To: <87h9gfus7a.fsf@mail.linkov.net>
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
> Since you are changing the function signatures anyway,
> you could make them consistent between `dired-map-over-marks'
> and `dired-get-marked-files' by adding an explicit arg `marker-char',
> i.e. both `dired-get-marked-files' and `dired-map-over-marks'
> could end with "distinguish-one-marked marker-char all-marks",
> thus explicitly passing `marker-char' arg down the call chain.
> Then you'll need `(or marker-char dired-marker-char)' in
> `dired-marker-regexp' for backward-compatibility. And then also
> no need to let-bind `dired-marker-char' in `dired-get-marked-files'
> (it's better to avoid dynamically binding global variables where possible).
It sounds good. Thank you. Implemented in the new patch.
[-- Attachment #2: Type: text/plain, Size: 5033 bytes --]
From 54428444410aaacc8d1e86678dcb9a8e95fccd4b Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Thu, 10 Mar 2016 13:11:23 +0900
Subject: [PATCH] Avoid dynamic global var binding
* lisp/dired.el (dired-map-over-marks): Last 3 arguments
like in 'dired-get-marked-files' (Bug#22893).
(dired-get-marked-files): Passing arg. MARKER-CHAR directly to
'dired-map-over-marks' call instead of binding 'dired-marker-char'
as before.
Fixed typo in doc. string.
(dired-marker-regexp): Accept two optional args.
; * etc/NEWS: Document the change.
---
etc/NEWS | 5 +++++
lisp/dired.el | 34 ++++++++++++++++++++--------------
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index b651b9e..83f66b3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1512,6 +1512,11 @@ previous commands, `dired-do-search' and
keys; rebind `A' and `Q' to invoke them if you want the old behavior
back. We intend to obsolete the old commands in a future release.
+*** New optional args MARKER-CHAR and ALL-MARKS for
+`dired-map-over-marks', `dired-get-marked-files' and `dired-marker-regexp'
+allow to operate over files marked with MARKER-CHAR, or over all
+marked files.
+
** Tabulated List Mode
+++
diff --git a/lisp/dired.el b/lisp/dired.el
index bf81649..618feb2 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -553,7 +553,7 @@ dired-mark-if
(and (> count 0) count)))
(defmacro dired-map-over-marks (body arg &optional show-progress
- distinguish-one-marked all-marks)
+ distinguish-one-marked marker-char all-marks)
"Eval BODY with point on each marked line. Return a list of BODY's results.
If no marked file could be found, execute BODY on the current
line. ARG, if non-nil, specifies the files to use instead of the
@@ -581,8 +581,11 @@ dired-map-over-marks
If DISTINGUISH-ONE-MARKED is non-nil, then if we find just one
marked file, return (t FILENAME) instead of (FILENAME).
+If MARKER-CHAR is non-nil, then it is the mark
+character to search. Otherwise use `dired-marker-char'.
+
If ALL-MARKS is non-nil, accept all mark characters. Otherwise use
-just `dired-marker-char'."
+just MARKER-CHAR."
;;
;;Warning: BODY must not add new lines before point - this may cause an
;;endless loop.
@@ -602,7 +605,8 @@ dired-map-over-marks
results))
;; non-nil, non-integer ARG means use current file:
(list ,body))
- (let ((regexp (dired-marker-regexp ,all-marks)) next-position)
+ (let ((regexp (dired-marker-regexp ,marker-char ,all-marks))
+ next-position)
(save-excursion
(goto-char (point-min))
;; remember position of next marked file before BODY
@@ -633,7 +637,7 @@ dired-map-over-marks
(defun dired-get-marked-files (&optional localp arg filter
distinguish-one-marked
marker-char all-marks)
- "Return the marked files' names as list of strings.
+ "Return the marked files names as a list of strings.
The list is in the same order as the buffer, that is, the car is the
first marked file.
Values returned are normally absolute file names.
@@ -656,13 +660,12 @@ dired-get-marked-files
Optional arg ALL-MARKS, if non-nil, then accept all mark characters.
Otherwise use just MARKER-CHAR."
- (let* ((dired-marker-char (or marker-char dired-marker-char))
- (all-of-them
- (save-excursion
- (delq nil (dired-map-over-marks
- (dired-get-filename localp 'no-error-if-not-filep)
- arg nil distinguish-one-marked all-marks))))
- result)
+ (let ((all-of-them
+ (save-excursion
+ (delq nil (dired-map-over-marks
+ (dired-get-filename localp 'no-error-if-not-filep)
+ arg nil distinguish-one-marked marker-char all-marks))))
+ result)
(when (equal all-of-them '(t))
(setq all-of-them nil))
(if (not filter)
@@ -3043,13 +3046,16 @@ dired-clean-up-after-deletion
\f
;; Confirmation
-(defun dired-marker-regexp (&optional all-marks)
+(defun dired-marker-regexp (&optional marker-char all-marks)
"Return a regexp matching `dired-marker-char' at the beginning of line.
-If optional argument ALL-MARKS evaluates to non-nil, the regexp
+If MARKER-CHAR evaluates non-nil, then the regexp matches MARKER-CHAR
+instead of `dired-marker-char'.
+If optional argument ALL-MARKS evaluates to non-nil, then the regexp
matches any mark character."
(if all-marks
"^[^\t ]"
- (concat "^" (regexp-quote (char-to-string dired-marker-char)))))
+ (concat "^" (regexp-quote (char-to-string (or marker-char
+ dired-marker-char))))))
(defun dired-plural-s (count)
(if (= 1 count) "" "s"))
--
2.7.0
next prev parent reply other threads:[~2016-03-10 4:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 9:38 bug#22893: 25.1.50; dired-get-marked-files get all marked Tino Calancha
2016-03-04 12:32 ` Lars Ingebrigtsen
2016-03-05 13:14 ` Tino Calancha
2016-03-08 5:18 ` Tino Calancha
2016-03-08 16:01 ` Eli Zaretskii
2016-03-09 15:27 ` Tino Calancha
2016-03-09 23:57 ` Juri Linkov
2016-03-10 4:19 ` Tino Calancha [this message]
2019-06-25 14:07 ` bug#22892: " Lars Ingebrigtsen
2020-08-12 11:58 ` Lars Ingebrigtsen
2016-03-10 4:43 ` Tino Calancha
2016-03-11 0:48 ` Juri Linkov
2016-03-22 9:31 ` bug#22893: dired-marker-regexp use dired-re-mark Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LRH.2.20.1603101317100.23082@calancha-ilc.kek.jp \
--to=f92capac@gmail.com \
--cc=22893@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.