From: Drew Adams <drew.adams@oracle.com>
To: Arthur Miller <arthur.miller@live.com>
Cc: 41250@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline
Date: Fri, 15 May 2020 15:19:03 -0700 (PDT) [thread overview]
Message-ID: <d8cd448c-4859-494d-85f2-2fc8fa2f7dd4@default> (raw)
In-Reply-To: <VI1PR06MB45262D0792D96FB34459A10B96BD0@VI1PR06MB4526.eurprd06.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 3614 bytes --]
> I have just one question/suggestion:
(Actually, it seems like several. ;-)
> You first choice: indicate by name or date, else full. Does it really
> need to be there?
Not sure I understand. Define "need".
I kept the longstanding behavior, by default (option
value nil). If you customize then you override that
default behavior. If you don't customize then nothing
changes for you (good).
> ls-switches are displayed only when dired is not
> sorted by name or date, i.e. custom
My intention is to let a user impose showing switches
even in the case where name or date regexp matches.
And to let a user instead prefer "by name" and "by
date" when they match, but default to showing all
(as now).
> Thus this customization only touches displaying of
> switches when they are displayd. I.e. it should be
> about "how", not "when".
Sorry, I don't follow. Please say what behavior
you want to be able to specify that the proposed
code doesn't provide for.
> To explain my thought: that is a hard-coded behaviour which user can't
> customize anway.
What is "this"? Please give an example of the
behavior you'd like that you don't think you
can get, or that you think is too difficult to
get.
> By looking at your code, that bevahviour indeed
> persists.
If you mean that the longstanding behavior is
still possible, and is even the default, yes.
If you mean something else, please rephrase.
> 2nd choice is the one that actually
> consider how switches will be displayed.
By "2nd choice" I guess you mean showing the
full switches? Or do you mean truncating that?
> I have same consideration about 3rd choice too.
> Function choice
(That's the 4th choice.)
> gives option to run custom hook as format. I think it is cool to have custom
> format function to display when in dired mode, so I like it, but it is
> a bit different purpose then regulating display of switches.
What do you mean? The switches string is passed
as an arg to the function, which can return
anything. It can format and return any part of
that string, or transform it in any way, or
return something descriptive (a la "by name"),
or return something completely unrelated (your
birthday, "Hello world!").
> Maybe it should get it's own custom variable instead? Like
> dired-mode-line-display-hook or something similar?
Why? Then you're essentially back to the idea
of having _only_ a function.
> 2nd option, one with number
(That's the 3rd choice.)
> does what the proposed variable name suggests.
The name just suggests something in the mode-line
that's based on switches.
> Personally I ment to code just short (first switch)
(That's name/date.)
> and long (all switches), since probably the first
> one is the most important one.
Sorry, but I'm lost in your reference to first,
second, etc.
It sounds now like you're not interested in a
truncation choice (?). I thought it was you who
requested that.
> I would also prefer nil to mean don't show switches at all, but it
> works with N chars set to 0 as well I guess.
A value of 0 shows nothing. And so does a value
of (lambda (x) "").
> Observe also that if I turn off display by using 0 chars as suggested
> there will be a small gap between word "Dired" and closing parenthesis.
> It will look like: (Dired ) on modeline. Not a deal breaker, but kind
> of small artefact. Easily fixed though. I can rework it if you wish,
> but since it is yours, you might prefer to do it yourself.
Attached patch takes care of that, and adds ellipsis.
[-- Attachment #2: dired-2020-05-15b.patch --]
[-- Type: application/octet-stream, Size: 3163 bytes --]
diff -u dired.el dired-2020-05-15b-PATCHED.el
--- dired.el 2020-05-15 11:23:32.804823800 -0700
+++ dired-2020-05-15b-PATCHED.el 2020-05-15 15:13:53.966204600 -0700
@@ -4114,22 +4114,45 @@
"Non-nil means the Dired sort command is disabled.
The idea is to set this buffer-locally in special Dired buffers.")
+(defcustom dired-switches-in-mode-line nil
+ "How to indicate `dired-actual-switches' in mode-line.
+Possible values:
+ * `nil': Indicate name-or-date sort order, if possible.
+ Else show full switches.
+ * `as-is': Show full switches.
+ * Integer: Show only the first N chars of full switches.
+ * Function: Pass `dired-actual-switches' as arg and show result."
+ :group 'Dired-Plus
+ :type '(choice
+ (const :tag "Indicate by name or date, else full" nil)
+ (const :tag "Show full switches" as-is)
+ (integer :tag "Show first N chars of switches" :value 10)
+ (function :tag "Format with function" :value identity)))
+
(defun dired-sort-set-mode-line ()
- ;; Set mode line display according to dired-actual-switches.
- ;; Mode line display of "by name" or "by date" guarantees the user a
- ;; match with the corresponding regexps. Non-matching switches are
- ;; shown literally.
+ "Set mode-line according to option `diredp-switches-in-mode-line'."
(when (eq major-mode 'dired-mode)
(setq mode-name
- (let (case-fold-search)
- (cond ((string-match-p
- dired-sort-by-name-regexp dired-actual-switches)
- "Dired by name")
- ((string-match-p
- dired-sort-by-date-regexp dired-actual-switches)
- "Dired by date")
- (t
- (concat "Dired " dired-actual-switches)))))
+ (let ((case-fold-search nil))
+ (if diredp-switches-in-mode-line
+ (concat "Dired"
+ (cond ((integerp diredp-switches-in-mode-line)
+ (let* ((l1 (length dired-actual-switches))
+ (xs (substring dired-actual-switches
+ 0 (min l1 diredp-switches-in-mode-line)))
+ (l2 (length xs)))
+ (if (zerop l2)
+ xs
+ (concat " " xs (and (< l2 l1) "…")))))
+ ((functionp diredp-switches-in-mode-line)
+ (format " %s" (funcall diredp-switches-in-mode-line
+ dired-actual-switches)))
+ (t (concat " " dired-actual-switches))))
+ (cond ((string-match-p dired-sort-by-name-regexp dired-actual-switches)
+ "Dired by name")
+ ((string-match-p dired-sort-by-date-regexp dired-actual-switches)
+ "Dired by date")
+ (t (concat "Dired " dired-actual-switches))))))
(force-mode-line-update)))
(define-obsolete-function-alias 'dired-sort-set-modeline
next prev parent reply other threads:[~2020-05-15 22:19 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 1:42 bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline Arthur Miller
2020-05-14 22:33 ` Juri Linkov
2020-05-14 23:42 ` Drew Adams
2020-05-15 8:44 ` Arthur Miller
2020-05-15 18:55 ` Drew Adams
2020-05-15 19:09 ` Eli Zaretskii
2020-05-15 21:08 ` Arthur Miller
2020-05-15 22:19 ` Drew Adams
2020-05-17 3:09 ` Arthur Miller
2020-05-17 6:59 ` Drew Adams
2020-05-17 11:12 ` Arthur Miller
2020-05-16 6:34 ` Eli Zaretskii
2020-05-16 12:18 ` Arthur Miller
2020-05-17 3:01 ` Arthur Miller
2020-05-17 15:17 ` Eli Zaretskii
2020-05-17 16:34 ` Arthur Miller
2020-05-17 16:42 ` Eli Zaretskii
2020-05-17 22:57 ` Arthur Miller
2020-05-17 23:37 ` Stefan Kangas
2020-05-18 15:08 ` Arthur Miller
2020-05-18 14:25 ` Eli Zaretskii
[not found] ` <<VI1PR06MB4526BAF92DBDCEA6A75D7A0196BD0@VI1PR06MB4526.eurprd06.prod.outlook.com>
[not found] ` <<835zcwv15e.fsf@gnu.org>
2020-05-16 14:42 ` Drew Adams
2020-05-15 19:54 ` Arthur Miller
2020-05-15 22:19 ` Drew Adams [this message]
2020-05-15 22:24 ` Drew Adams
2020-09-30 16:02 ` Lars Ingebrigtsen
2020-09-30 19:04 ` Juri Linkov
2020-09-30 19:30 ` Lars Ingebrigtsen
2020-09-30 19:58 ` Juri Linkov
2020-09-30 19:59 ` Lars Ingebrigtsen
2020-10-01 19:37 ` Juri Linkov
2020-10-01 19:59 ` Lars Ingebrigtsen
2020-10-02 6:31 ` Eli Zaretskii
2020-10-02 14:10 ` Lars Ingebrigtsen
2020-10-02 14:57 ` Eli Zaretskii
2020-10-03 17:36 ` Lars Ingebrigtsen
2020-10-02 6:54 ` Juri Linkov
2020-10-02 14:14 ` Lars Ingebrigtsen
2020-10-02 14:59 ` Eli Zaretskii
2020-10-03 17:38 ` Lars Ingebrigtsen
2020-10-04 19:44 ` Juri Linkov
2020-10-05 7:08 ` Lars Ingebrigtsen
2020-10-05 20:15 ` Juri Linkov
2020-10-06 1:37 ` Lars Ingebrigtsen
2020-10-05 15:49 ` Glenn Morris
2020-10-05 20:12 ` Juri Linkov
2020-10-05 21:31 ` Andreas Schwab
2020-10-06 13:08 ` Stefan Monnier
2020-10-06 13:28 ` Andreas Schwab
2020-10-05 23:06 ` Glenn Morris
2020-10-06 7:13 ` Andreas Schwab
2020-10-06 7:18 ` Eli Zaretskii
2020-10-06 7:28 ` Eli Zaretskii
2020-10-06 7:48 ` Andreas Schwab
2020-10-06 8:18 ` Eli Zaretskii
2020-10-06 8:44 ` Andreas Schwab
2020-10-06 9:03 ` Eli Zaretskii
2020-10-06 9:17 ` Andreas Schwab
2020-10-06 9:24 ` Eli Zaretskii
2020-10-06 9:45 ` Andreas Schwab
2020-10-06 7:52 ` Juri Linkov
2020-10-01 20:01 ` Lars Ingebrigtsen
2020-10-01 2:30 ` Eli Zaretskii
2020-10-01 2:39 ` Lars Ingebrigtsen
2020-10-01 9:24 ` Andy Moreton
2020-09-30 21:07 ` Drew Adams
2020-10-01 1:25 ` Lars Ingebrigtsen
2020-10-01 16:35 ` Drew Adams
2020-09-30 20:56 ` Drew Adams
2020-05-16 23:11 ` Juri Linkov
2020-05-17 1:16 ` Drew Adams
2020-05-15 6:43 ` Eli Zaretskii
2020-05-15 8:40 ` Arthur Miller
2020-05-15 10:15 ` Eli Zaretskii
2020-05-15 10:50 ` Arthur Miller
2020-10-06 11:36 ` Mattias Engdegård
[not found] <<VI1PR06MB45265DF0191578C413A3B37C96BC0@VI1PR06MB4526.eurprd06.prod.outlook.com>
[not found] ` <<87v9ky9p6o.fsf@mail.linkov.net>
[not found] ` <<654acc31-015d-4552-bd9b-3b8c69661fcd@default>
[not found] ` <<VI1PR06MB45265603DFF6BE71DBD819EB96BD0@VI1PR06MB4526.eurprd06.prod.outlook.com>
[not found] ` <<0957af50-7f85-455a-9d2c-e96451727872@default>
[not found] ` <<83a729uiaq.fsf@gnu.org>
2020-05-15 21:00 ` Drew Adams
2020-05-15 21:14 ` Arthur Miller
2020-05-15 22:04 ` Drew Adams
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8cd448c-4859-494d-85f2-2fc8fa2f7dd4@default \
--to=drew.adams@oracle.com \
--cc=41250@debbugs.gnu.org \
--cc=arthur.miller@live.com \
--cc=juri@linkov.net \
/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 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).