all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: 41250@debbugs.gnu.org, juri@linkov.net
Subject: bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline
Date: Mon, 18 May 2020 17:08:40 +0200	[thread overview]
Message-ID: <VI1PR06MB4526BE122B1A62BF4FD38F2696B80@VI1PR06MB4526.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <CADwFkmnEHAYuvTTOuxONQsoHsYttgJQHx=+Gh5dPaHY=Np4tEQ@mail.gmail.com> (Stefan Kangas's message of "Sun, 17 May 2020 16:37:15 -0700")

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

Stefan Kangas <stefankangas@gmail.com> writes:

> Arthur Miller <arthur.miller@live.com> writes:
>
>> Another question: can I assume, at this time of civilisation
>> development, that everybody has GNU ls, since binutils, or coreutils, or
>> what is the name, is probably default on most *nix distros, as well as
>> on msys2 which is needed to build on Windows. No idea how Mac people are
>> doing in that regard though?
>
> MacOS has BSD userland, as does *BSD.
>
> You can install it and use GNU coreutils optionally, but I would expect
> only a minority of users to do that.
>
> Best regards,
> Stefan Kangas
Alright, thanks. I can then either opt for status quo, as it is now
(just date and name) or add extra sort options and bool flag in
defcustom for users to enable if they now they have gnu ls. I could also
add utility funciton to print version of ls in say message buffer.

Anyway I have red the manual about propertize and seen some examples in
code that Eli pointed me to, online aw well, and as I understand this
feature (help-echo) is fairly trivial and easy to use. I like it, it
seems really usefull. However, for some reason modeline ignores my
propertized string :-).

Below is another sketch for this. Instead of displaying actual switches,
I display string "by user". I tested with elipsis at the end, "by
user...", but I don't think it lookes so nice on modeline. The strategy
is to show the tooltip with switches when user hoovers with pointer over
the modeline (I completely missed that feature of Emacs since I use
mouse and modeline so little :-)).

Attached is a patch with this sketch, the only problem seems that I
missundestand something, seems modeline does not display the tooltip.

I am sorry for me being such noob, I will look around more, but if
somebody can point out the misstake it will be helpful.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired.patch --]
[-- Type: text/x-patch, Size: 3504 bytes --]

--- dired.el	2020-05-14 03:06:34.046112281 +0200
+++ lisp/dired.el	2020-05-18 13:37:21.934674831 +0200
@@ -223,6 +223,14 @@
 (define-obsolete-variable-alias 'dired-free-space-args
   'directory-free-space-args "27.1")
 
+(defcustom dired-sort-mode-line-info t
+  "Run when dired is displaying it's info on modeline. Default hook is
+dired-set-sort-mode-line, which displays sorting order used in current
+  dired buffer. Every hook in the list should return a string that
+  will be appended to dired info already shown on modeline."
+  :group 'dired
+  :type 'boolean)
+
 ;;; Hook variables
 
 (defcustom dired-load-hook nil
@@ -4114,24 +4122,43 @@
   "Non-nil means the Dired sort command is disabled.
 The idea is to set this buffer-locally in special Dired buffers.")
 
-(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.
+(defun dired-set-mode-line ()
+  ;; Flush dired info to mode-line (eval all dired-mode-line-hook)
+  ;; If dired-mode-line-hook is nil, it means user has manually
+  ;; disabled displaying of Dired info on mode-line, so let's respect
+  ;; the user decision.
   (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)))))
+    (if dired-sort-mode-line-info
+        (setq mode-name
+              (concat
+               mode-name
+               (propertize
+                (dired-sort-set-mode-line)
+                'help-echo dired-actual-switches)))
+      (setq mode-name "Dired")) ;; reset name if dired-mode-line-hook is nil
     (force-mode-line-update)))
 
+(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 as \"by user\". has not disabled displaying them by
+  customizing dired-display-listing-switches variable."
+  (when (eq major-mode 'dired-mode)
+    (let* ((mode-line-info)
+           (case-fold-search))
+      (cond ((string-match-p
+	      dired-sort-by-name-regexp dired-actual-switches)
+             (setq mode-line-info " by name"))
+
+            ((string-match-p
+	      dired-sort-by-date-regexp dired-actual-switches)
+             (setq mode-line-info " by date"))
+
+            (t
+             (setq mode-line-info " by user")))
+      mode-line-info)))
+
 (define-obsolete-function-alias 'dired-sort-set-modeline
   #'dired-sort-set-mode-line "24.3")
 
@@ -4174,7 +4201,7 @@
                                         dired-actual-switches)
                         "t"
                       " -t")))))
-  (dired-sort-set-mode-line)
+  (dired-set-mode-line)
   (revert-buffer))
 
 ;; Some user code loads dired especially for this.
@@ -4197,7 +4224,7 @@
 With optional second arg NO-REVERT, don't refresh the listing afterwards."
   (dired-sort-R-check switches)
   (setq dired-actual-switches switches)
-  (dired-sort-set-mode-line)
+  (dired-set-mode-line)
   (or no-revert (revert-buffer)))
 
 (defvar-local dired-subdir-alist-pre-R nil

  reply	other threads:[~2020-05-18 15:08 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 [this message]
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
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR06MB4526BE122B1A62BF4FD38F2696B80@VI1PR06MB4526.eurprd06.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=41250@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=stefankangas@gmail.com \
    /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.