* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline @ 2020-05-14 1:42 Arthur Miller 2020-05-14 22:33 ` Juri Linkov 2020-10-06 11:36 ` Mattias Engdegård 0 siblings, 2 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-14 1:42 UTC (permalink / raw) To: 41250 [-- Attachment #1: Type: text/plain, Size: 863 bytes --] There is no way to turn off displaying of ls-switches on modeline when in dired-mode. By default in certain configuration, dired display ls-switches on modeline. In case those switches are a long list, for example: "-lA --si --time-style long-iso --group-directories-first" then everything else on modeline gets pushed far to the right which is not very usable. In general I don't have much use of seing ls-switches on modeline and would like to be able to turn them off. As of current it does not seem possible since it is hard-coded in function `dired-sort-set-mode-line' in dired.el. I suggest, as small improvement, to introduce a user option to turn off or on displaying of ls-switches on modeline. As a suggestion I have attached small hack to dired.el as tested on my copy of Emacs, but you might wish to rewrite it. Drew had some other suggestions. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Patch to introduce user option to turn on/off for --] [-- Type: text/x-patch, Size: 2497 bytes --] --- dired.el 2020-05-14 03:06:34.046112281 +0200 +++ lisp/dired.el 2020-05-14 03:12:03.423097577 +0200 @@ -70,12 +70,20 @@ :type 'string :group 'dired) +(defcustom dired-display-listing-switches nil + "Display switches passed to `ls' for Dired on modeline. +If value is `t', value of dired-listing-switches will be shown on +modeline, when dired is not showing files `by name' or `by date'. +Default value is nil." + :type 'boolean + :group 'dired) + (defcustom dired-subdir-switches nil "If non-nil, switches passed to `ls' for inserting subdirectories. If nil, `dired-listing-switches' is used." - :group 'dired - :type '(choice (const :tag "Use dired-listing-switches" nil) - (string :tag "Switches"))) + :group 'dired + :type '(choice (const :tag "Use dired-listing-switches" nil) + (string :tag "Switches"))) (defcustom dired-chown-program (purecopy (cond ((executable-find "chown") "chown") @@ -4118,22 +4126,25 @@ ;; 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. + ;; shown literally if user has not disabled displaying them by + ;; customizing dired-display-listing-switches variable. (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))))) + (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") + ((eq dired-display-listing-switches t) + (concat "Dired " dired-actual-switches)) + (t + "Dired")))) (force-mode-line-update))) -(define-obsolete-function-alias 'dired-sort-set-modeline - #'dired-sort-set-mode-line "24.3") + (define-obsolete-function-alias 'dired-sort-set-modeline + #'dired-sort-set-mode-line "24.3") (defun dired-sort-toggle-or-edit (&optional arg) "Toggle sorting by date, and refresh the Dired buffer. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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 6:43 ` Eli Zaretskii 2020-10-06 11:36 ` Mattias Engdegård 1 sibling, 2 replies; 79+ messages in thread From: Juri Linkov @ 2020-05-14 22:33 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250 > There is no way to turn off displaying of ls-switches on modeline when > in dired-mode. > > By default in certain configuration, dired display ls-switches on > modeline. In case those switches are a long list, for example: > > "-lA --si --time-style long-iso --group-directories-first" > > then everything else on modeline gets pushed far to the right which is > not very usable. In general I don't have much use of seing ls-switches > on modeline and would like to be able to turn them off. As of current it > does not seem possible since it is hard-coded in function > `dired-sort-set-mode-line' in dired.el. > > I suggest, as small improvement, to introduce a user option to turn off > or on displaying of ls-switches on modeline. As a suggestion I have > attached small hack to dired.el as tested on my copy of Emacs, but you > might wish to rewrite it. Drew had some other suggestions. Maybe instead of boolean better to use a number for the allowed limit that should not grow more than this number that means the length of switches string that the user can tolerate on the modeline. Then modeline will display abbreviation truncated to the specified number of characters, with an ellipses, on the assumption that the most important switches are at the beginning of the string. Customizing it to 0 effectively disables the display of switches. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-14 22:33 ` Juri Linkov @ 2020-05-14 23:42 ` Drew Adams 2020-05-15 8:44 ` Arthur Miller 2020-05-15 6:43 ` Eli Zaretskii 1 sibling, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-05-14 23:42 UTC (permalink / raw) To: Juri Linkov, Arthur Miller; +Cc: 41250 > Maybe instead of boolean better to use a number for the allowed limit > that should not grow more than this number that means the length of > switches string that the user can tolerate on the modeline. > > Then modeline will display abbreviation truncated to the specified > number of characters, with an ellipses, on the assumption that > the most important switches are at the beginning of the string. > Customizing it to 0 effectively disables the display of switches. I suggested a choice, one possibility being a format string. A format string also lets you truncate. But sure, another choice offered could be what you suggest (a simpler way to specify just truncation). I made the suggestion in an emacs-devel thread, which hasn't been referenced so far in this bug thread: https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg01851.html https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg01964.html ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-14 23:42 ` Drew Adams @ 2020-05-15 8:44 ` Arthur Miller 2020-05-15 18:55 ` Drew Adams 0 siblings, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-15 8:44 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, Juri Linkov Drew Adams <drew.adams@oracle.com> writes: >> Maybe instead of boolean better to use a number for the allowed limit >> that should not grow more than this number that means the length of >> switches string that the user can tolerate on the modeline. >> >> Then modeline will display abbreviation truncated to the specified >> number of characters, with an ellipses, on the assumption that >> the most important switches are at the beginning of the string. >> Customizing it to 0 effectively disables the display of switches. > > I suggested a choice, one possibility being a format string. > A format string also lets you truncate. But sure, another > choice offered could be what you suggest (a simpler way to > specify just truncation). > > I made the suggestion in an emacs-devel thread, which hasn't > been referenced so far in this bug thread: > > https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg01851.html > > https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg01964.html I answered you on that mail, but I just mentioned that you had other suggestion on bug repport just for the simplicity. I think format string asks for more documentation and more cognitive effort on part of user :-) and as such maybe it is better to have it as part of Dired+. Kind-of more for hard-core users who prefer much deeper level of customization? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 8:44 ` Arthur Miller @ 2020-05-15 18:55 ` Drew Adams 2020-05-15 19:09 ` Eli Zaretskii ` (2 more replies) 0 siblings, 3 replies; 79+ messages in thread From: Drew Adams @ 2020-05-15 18:55 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, Juri Linkov [-- Attachment #1: Type: text/plain, Size: 1862 bytes --] > I think format string asks for more documentation and > more cognitive effort on part of user :-) and as such > maybe it is better to have it as part of Dired+. > > Kind-of more for hard-core users who prefer much > deeper level of customization? Emacs users are of all kinds. No user who doesn't understand `format' would need to make that particular option-value choice. This is no different from options we have that have a catch-all choice of a function, which they can use to get pretty much any behavior. And that's another reasonable alternative here to a choice of a format string: a function that accepts the current switches as its (first) argument. That's even more general, and it wouldn't freak out a user unfamiliar with format strings. ;-) And that also covers truncating, trivially. There's nothing special about truncating. It just happens to correspond directly to your immediate problem: a long list of switches. Attached is a patch that does what I think should be done. The option value can be: nil - to get the current behavior `as-is' - show the full switches an integer - show first N chars of switches a function - show whatever it returns, when passed `dired-actual-switches' If Emacs doesn't want to go this route then I guess I'll just use it for Dired+. ___ I do think your suggestion of mouseover the mode-line indication showing the full switches is a good one. I've added command `diredp-change-ls-switches' to Dired+, and added it to menu-bar menu `Dir' (aka `Subdir'). It shows the current switches in the prompt, so you can just hit `C-g' if all you want is see what the current switches are. And because it's in the menu, you can get to it by clicking the lighter in the mode-line. (Menu `Dir' is the first menu listed when you click.) [-- Attachment #2: dired-2020-05-15a.patch --] [-- Type: application/octet-stream, Size: 2747 bytes --] diff -u dired.el dired-2020-05-15a-PATCHED.el --- dired.el 2020-05-15 11:23:32.804823800 -0700 +++ dired-2020-05-15a-PATCHED.el 2020-05-15 11:26:20.702051000 -0700 @@ -4114,22 +4114,40 @@ "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 `dired-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 dired-switches-in-mode-line + (concat "Dired " + (cond ((integerp dired-switches-in-mode-line) + (substring dired-actual-switches + 0 dired-switches-in-mode-line)) + ((functionp dired-switches-in-mode-line) + (format "%s" (funcall dired-switches-in-mode-line + dired-actual-switches))) + (t 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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 18:55 ` Drew Adams @ 2020-05-15 19:09 ` Eli Zaretskii 2020-05-15 21:08 ` Arthur Miller [not found] ` <<VI1PR06MB4526BAF92DBDCEA6A75D7A0196BD0@VI1PR06MB4526.eurprd06.prod.outlook.com> 2020-05-15 19:54 ` Arthur Miller 2020-05-16 23:11 ` Juri Linkov 2 siblings, 2 replies; 79+ messages in thread From: Eli Zaretskii @ 2020-05-15 19:09 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, arthur.miller, juri > Date: Fri, 15 May 2020 11:55:46 -0700 (PDT) > From: Drew Adams <drew.adams@oracle.com> > Cc: 41250@debbugs.gnu.org, Juri Linkov <juri@linkov.net> > > an integer - show first N chars of switches I don't think this is a useful value: the user will rarely know how much space is available on the mode line. Also, truncating without showing ellipsis or some other sign of truncation is IMO a sub-optimal UI. Thanks. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 19:09 ` Eli Zaretskii @ 2020-05-15 21:08 ` Arthur Miller 2020-05-15 22:19 ` Drew Adams 2020-05-16 6:34 ` Eli Zaretskii [not found] ` <<VI1PR06MB4526BAF92DBDCEA6A75D7A0196BD0@VI1PR06MB4526.eurprd06.prod.outlook.com> 1 sibling, 2 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-15 21:08 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri Eli Zaretskii <eliz@gnu.org> writes: >> Date: Fri, 15 May 2020 11:55:46 -0700 (PDT) >> From: Drew Adams <drew.adams@oracle.com> >> Cc: 41250@debbugs.gnu.org, Juri Linkov <juri@linkov.net> >> >> an integer - show first N chars of switches > > I don't think this is a useful value: the user will rarely know how > much space is available on the mode line. Also, truncating without > showing ellipsis or some other sign of truncation is IMO a sub-optimal > UI. > > Thanks. After I saw Drews mail and patch, and answered, I was thinking additionally, and I am actually now wondering, why is it assumed that Dired will show sorting order on modeline by default? I mean other modes does not do similar. Say, cc-mode does not show which current identation scheme I use, or something similar. Why is it assumed for Dired? I don't have historical insight so I don't know why original author(s) decided to make it so? If Dired show just, word "Dired" as it's lighter only, as other modes do, then maybe Drews idea to have a format string is maybe the most flexible one? For example we could have a format string, by default nil or just "", which user could set to whatever. Or there could be a hook, say (defun dired-display-mode-line-info (info-message) (setq mode-name (concat mode-name " " info-message) (force-mode-line-update))) with some checks for empty stirng and so on. I ment just as a quick illustration. Then users could put for themselves the info they wishes to be displayed on modeline: sorting order, or number of fles, or current moon phase? Or they will be like and would prefer to show nothing. Maybe you have already discussed this when dired was written? In that case I am just curious why it was decided that Dired should show extra info on modeline? If anybody remembers, or even know, of course. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 21:08 ` Arthur Miller @ 2020-05-15 22:19 ` Drew Adams 2020-05-17 3:09 ` Arthur Miller 2020-05-16 6:34 ` Eli Zaretskii 1 sibling, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-05-15 22:19 UTC (permalink / raw) To: Arthur Miller, Eli Zaretskii; +Cc: 41250, juri > I am actually now wondering, why is it assumed that > Dired will show sorting order on modeline by default? Because it's useful. And it is very common to use `s', to toggle between name and date sorting. Those are the common sorts, and switches that match their regexps are the most common. Those predefined regexps could presumably be tweaked to accommodate more patterns that have time in them, but IMHO it's not worth it. This mode-line indication is not, primarily, about showing you the current `ls' switches. It's about telling you whether files are sorted by name or time. The relevant function is called `dired-sort-set-mode-line'. ^^^^ ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 22:19 ` Drew Adams @ 2020-05-17 3:09 ` Arthur Miller 2020-05-17 6:59 ` Drew Adams 0 siblings, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-17 3:09 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, juri Drew Adams <drew.adams@oracle.com> writes: >> I am actually now wondering, why is it assumed that >> Dired will show sorting order on modeline by default? > > Because it's useful. And it is very common to use > `s', to toggle between name and date sorting. Those > are the common sorts, and switches that match their > regexps are the most common. > > Those predefined regexps could presumably be tweaked > to accommodate more patterns that have time in them, > but IMHO it's not worth it. > > This mode-line indication is not, primarily, about > showing you the current `ls' switches. It's about > telling you whether files are sorted by name or time. > > The relevant function is called `dired-sort-set-mode-line'. > ^^^^ Yeah, I completely understand, but as I wrote to Eli too, to me, dired buffer itself is an immidate visual feedback. I don't need addtional information on modeline to tell me if files are sorted alfabetically or by some other mean. So I prefer to save mode-line space for something else. It is just my personal preference, I have understanding that other people might have different taste. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 3:09 ` Arthur Miller @ 2020-05-17 6:59 ` Drew Adams 2020-05-17 11:12 ` Arthur Miller 0 siblings, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-05-17 6:59 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > > This mode-line indication is not, primarily, about > > showing you the current `ls' switches. It's about > > telling you whether files are sorted by name or time. > > Yeah, I completely understand, but as I wrote to Eli too, to me, dired > buffer itself is an immidate visual feedback. I don't need addtional > information on modeline to tell me if files are sorted alfabetically or > by some other mean. Some of us do need/want that aid. And no, it's not always obvious what the current order is. > So I prefer to save mode-line space for something > else. It is just my personal preference, I have > understanding that other people might have different taste. Indeed; likewise. And I'm in favor of making it easy for different people to get different behavior in this regard. In general, user customization of the mode-line is not simple. When a mode like Dired can offer useful info in the mode-line, in a few chars, it should. And when it can offer users easy ways to change what's shown there and how, it should. That doesn't mean that providing a few simple choices and simple ways to choose will satisfy all user desires in this department. Fortunately ;-). ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 6:59 ` Drew Adams @ 2020-05-17 11:12 ` Arthur Miller 0 siblings, 0 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-17 11:12 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, juri Drew Adams <drew.adams@oracle.com> writes: > That doesn't mean that providing a few simple > choices and simple ways to choose will satisfy all > user desires in this department. Fortunately ;-). Indeed! If one aim to satisfy everybody one ends satisfying nobody ... usually (I talk about software platorms and architecture :-)). ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 21:08 ` Arthur Miller 2020-05-15 22:19 ` Drew Adams @ 2020-05-16 6:34 ` Eli Zaretskii 2020-05-16 12:18 ` Arthur Miller 2020-05-17 3:01 ` Arthur Miller 1 sibling, 2 replies; 79+ messages in thread From: Eli Zaretskii @ 2020-05-16 6:34 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > From: Arthur Miller <arthur.miller@live.com> > Cc: Drew Adams <drew.adams@oracle.com>, 41250@debbugs.gnu.org, > juri@linkov.net > Date: Fri, 15 May 2020 23:08:46 +0200 > > After I saw Drews mail and patch, and answered, I was thinking > additionally, and I am actually now wondering, why is it assumed that > Dired will show sorting order on modeline by default? I mean other modes > does not do similar. Say, cc-mode does not show which current identation > scheme I use, or something similar. Yes, it does: the CC Mode shows the comment style in use and the minor mode. > Why is it assumed for Dired? I don't have historical insight so I > don't know why original author(s) decided to make it so? The sorting order was just one letter originally, so it sounds like a good idea to have an indication of why the order is this and not another. > If Dired show just, word "Dired" as it's lighter only, as other modes do, > then maybe Drews idea to have a format string is maybe the most flexible > one? Not IMO. Using format strings and functions is "advanced usage", which is normally barred for newbies and relatively inexperienced Emacs users. Popular options should IMO be exposed though easier customization values. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-16 6:34 ` Eli Zaretskii @ 2020-05-16 12:18 ` Arthur Miller 2020-05-17 3:01 ` Arthur Miller 1 sibling, 0 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-16 12:18 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri Eli Zaretskii <eliz@gnu.org> writes: >> From: Arthur Miller <arthur.miller@live.com> >> Cc: Drew Adams <drew.adams@oracle.com>, 41250@debbugs.gnu.org, >> juri@linkov.net >> Date: Fri, 15 May 2020 23:08:46 +0200 >> >> After I saw Drews mail and patch, and answered, I was thinking >> additionally, and I am actually now wondering, why is it assumed that >> Dired will show sorting order on modeline by default? I mean other modes >> does not do similar. Say, cc-mode does not show which current identation >> scheme I use, or something similar. > > Yes, it does: the CC Mode shows the comment style in use and the minor > mode. > >> Why is it assumed for Dired? I don't have historical insight so I >> don't know why original author(s) decided to make it so? > > The sorting order was just one letter originally, so it sounds like a > good idea to have an indication of why the order is this and not > another. > >> If Dired show just, word "Dired" as it's lighter only, as other modes do, >> then maybe Drews idea to have a format string is maybe the most flexible >> one? > > Not IMO. Using format strings and functions is "advanced usage", > which is normally barred for newbies and relatively inexperienced > Emacs users. Popular options should IMO be exposed though easier > customization values. Oki, I understand. To me, this info on modeline is superflous. When I am in dired buffer, I have immidiate visual feedback by just lookig at the content. I see if the content is sorted alhabetically or by some other means, for example size (which is not reflected at all on modeline.) Also I like the possibility of user having option to customize this like everything else in Emacs. I will try to code another idea later in the evening as another suggestion. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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 1 sibling, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-17 3:01 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri [-- Attachment #1: Type: text/plain, Size: 2422 bytes --] Eli Zaretskii <eliz@gnu.org> writes: >> From: Arthur Miller <arthur.miller@live.com> >> Cc: Drew Adams <drew.adams@oracle.com>, 41250@debbugs.gnu.org, >> juri@linkov.net >> Date: Fri, 15 May 2020 23:08:46 +0200 >> >> After I saw Drews mail and patch, and answered, I was thinking >> additionally, and I am actually now wondering, why is it assumed that >> Dired will show sorting order on modeline by default? I mean other modes >> does not do similar. Say, cc-mode does not show which current identation >> scheme I use, or something similar. > > Yes, it does: the CC Mode shows the comment style in use and the minor > mode. > >> Why is it assumed for Dired? I don't have historical insight so I >> don't know why original author(s) decided to make it so? > > The sorting order was just one letter originally, so it sounds like a > good idea to have an indication of why the order is this and not > another. > >> If Dired show just, word "Dired" as it's lighter only, as other modes do, >> then maybe Drews idea to have a format string is maybe the most flexible >> one? > > Not IMO. Using format strings and functions is "advanced usage", > which is normally barred for newbies and relatively inexperienced > Emacs users. Popular options should IMO be exposed though easier > customization values. Ok, what about this strategy: I have introduced dired-mode-line-hook, which is a usual thing in Emacs, which is ment as a list of hooks that user can set. Each hook should return a string that will be concatenated to the lighter. So users can print whatever they want to that string (number of files, dirs etc). I have introduced also another function that will just iterate through hooks concat stuff and update the modeline and refactored some code to call this function instead of old dired-sort-set-modeline. Also dired-sort-set-modeline is changed to work as a mentioned hook and is used as default value for dired-mode-line-hook. If user does not prefer to see any aditional info on modeline then it is just to set dired-mode-line-hook to nil. Obs, that can probably be coded more elegantly, me & elisp are maybe not best friends (yet :-)). I have built and tested emacs with the patch, but I might have missed something. While I was looking through the code to set myself into dired, I have also noticed lots of '^L' chars, I took the freedom to clean it up where I saw them, there are probably more. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: dired.patch --] [-- Type: text/x-patch, Size: 12981 bytes --] --- dired.el 2020-05-14 03:06:34.046112281 +0200 +++ lisp/dired.el 2020-05-17 04:36:20.727942621 +0200 @@ -73,9 +73,9 @@ (defcustom dired-subdir-switches nil "If non-nil, switches passed to `ls' for inserting subdirectories. If nil, `dired-listing-switches' is used." - :group 'dired - :type '(choice (const :tag "Use dired-listing-switches" nil) - (string :tag "Switches"))) + :group 'dired + :type '(choice (const :tag "Use dired-listing-switches" nil) + (string :tag "Switches"))) (defcustom dired-chown-program (purecopy (cond ((executable-find "chown") "chown") @@ -238,6 +238,14 @@ :group 'dired :type 'hook) +(defcustom dired-mode-line-hook 'dired-sort-set-mode-line + "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 'hook) + (defcustom dired-before-readin-hook nil "This hook is run before a Dired buffer is read in (created or reverted)." :group 'dired @@ -634,7 +642,7 @@ "Additional expressions to highlight in Dired mode.") (defvar dnd-protocol-alist) -\f + ;;; Macros must be defined before they are used, for the byte compiler. (defmacro dired-mark-if (predicate msg) @@ -649,57 +657,57 @@ Return value is the number of files marked, or nil if none were marked." `(let* ((inhibit-read-only t) count - (use-region-p (and dired-mark-region - (region-active-p) - (> (region-end) (region-beginning)))) - (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 (eq dired-mark-region 'line) - (not (bolp)) - (get-text-property (1- (point)) 'dired-filename)) - (line-end-position) - (line-beginning-position))) - (point-max)))) - (save-excursion - (setq count 0) - (when ,msg - (message "%s %ss%s%s..." - (cond ((eq dired-marker-char ?\s) "Unmarking") - ((eq dired-del-marker dired-marker-char) - "Flagging") - (t "Marking")) - ,msg - (if (eq dired-del-marker dired-marker-char) - " for deletion" - "") - (if use-region-p - " in region" - ""))) - (goto-char beg) - (while (< (point) end) - (when ,predicate - (unless (= (following-char) dired-marker-char) - (delete-char 1) - (insert dired-marker-char) - (setq count (1+ count)))) - (forward-line 1)) - (when ,msg (message "%s %s%s %s%s%s" - count - ,msg - (dired-plural-s count) - (if (eq dired-marker-char ?\s) "un" "") - (if (eq dired-marker-char dired-del-marker) - "flagged" "marked") - (if use-region-p - " in region" - "")))) - (and (> count 0) count))) + (use-region-p (and dired-mark-region + (region-active-p) + (> (region-end) (region-beginning)))) + (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 (eq dired-mark-region 'line) + (not (bolp)) + (get-text-property (1- (point)) 'dired-filename)) + (line-end-position) + (line-beginning-position))) + (point-max)))) + (save-excursion + (setq count 0) + (when ,msg + (message "%s %ss%s%s..." + (cond ((eq dired-marker-char ?\s) "Unmarking") + ((eq dired-del-marker dired-marker-char) + "Flagging") + (t "Marking")) + ,msg + (if (eq dired-del-marker dired-marker-char) + " for deletion" + "") + (if use-region-p + " in region" + ""))) + (goto-char beg) + (while (< (point) end) + (when ,predicate + (unless (= (following-char) dired-marker-char) + (delete-char 1) + (insert dired-marker-char) + (setq count (1+ count)))) + (forward-line 1)) + (when ,msg (message "%s %s%s %s%s%s" + count + ,msg + (dired-plural-s count) + (if (eq dired-marker-char ?\s) "un" "") + (if (eq dired-marker-char dired-del-marker) + "flagged" "marked") + (if use-region-p + " in region" + "")))) + (and (> count 0) count))) (defmacro dired-map-over-marks (body arg &optional show-progress distinguish-one-marked) @@ -817,7 +825,6 @@ (user-error (if (stringp error) error "No files specified"))) result)) -\f ;; The dired command (defun dired-read-dir-and-switches (str) @@ -1197,7 +1204,6 @@ (setq blist (cdr blist)))))) found))) -\f ;; Read in a new dired buffer (defun dired-readin () @@ -1231,16 +1237,16 @@ ;; same performance advantages without the problem of breaking ;; users of after/before-change-functions. (combine-change-calls (point-min) (point-max) - (let ((inhibit-read-only t) - ;; Don't make undo entries for readin. - (buffer-undo-list t)) - (erase-buffer) - (dired-readin-insert)) - (goto-char (point-min)) - ;; Must first make alist buffer local and set it to nil because - ;; dired-build-subdir-alist will call dired-clear-alist first - (setq-local dired-subdir-alist nil) - (dired-build-subdir-alist)) + (let ((inhibit-read-only t) + ;; Don't make undo entries for readin. + (buffer-undo-list t)) + (erase-buffer) + (dired-readin-insert)) + (goto-char (point-min)) + ;; Must first make alist buffer local and set it to nil because + ;; dired-build-subdir-alist will call dired-clear-alist first + (setq-local dired-subdir-alist nil) + (dired-build-subdir-alist)) (let ((attributes (file-attributes dirname))) (if (eq (car attributes) t) (set-visited-file-modtime (file-attribute-modification-time @@ -1556,7 +1562,7 @@ (put-text-property (+ (point) 4) (line-end-position) 'invisible 'dired-hide-details-link)))) (forward-line 1)))) -\f + ;; Reverting a dired buffer (defun dired-revert (&optional _arg _noconfirm) @@ -1899,7 +1905,7 @@ ;; No need to do this, now that top-level items are fewer. ;;;; ;; Get rid of the Edit menu bar item to save space. - ;(define-key map [menu-bar edit] 'undefined) + ;(define-key map [menu-bar edit] 'undefined) (define-key map [menu-bar subdir] (cons "Subdir" (make-sparse-keymap "Subdir"))) @@ -2209,7 +2215,7 @@ map) "Local keymap for Dired mode buffers.") -\f + ;; Dired mode is suitable only for specially formatted data. (put 'dired-mode 'mode-class 'special) @@ -2317,14 +2323,14 @@ (add-hook 'file-name-at-point-functions #'dired-file-name-at-point nil t) (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t) (run-mode-hooks 'dired-mode-hook)) -\f + ;; Idiosyncratic dired commands that don't deal with marks. (defun dired-summary () "Summarize basic Dired commands and show recent Dired errors." (interactive) (dired-why) - ;>> this should check the key-bindings and use substitute-command-keys if non-standard + ;>> this should check the key-bindings and use substitute-command-keys if non-standard (message "d-elete, u-ndelete, x-punge, f-ind, o-ther window, R-ename, C-opy, h-elp")) @@ -2631,7 +2637,7 @@ (if (string-match (concat "^" (regexp-quote dir)) file) (substring file (match-end 0)) file)) -\f + (define-minor-mode dired-hide-details-mode "Toggle visibility of detailed information in current Dired buffer. When this minor mode is enabled, details such as file ownership and @@ -2668,7 +2674,7 @@ 'add-to-invisibility-spec 'remove-from-invisibility-spec) 'dired-hide-details-link)) -\f + ;;; Functions to hide/unhide text (defun dired--find-hidden-pos (start end) @@ -3553,7 +3559,7 @@ (let ((beg (point))) (completion--insert-strings files) (put-text-property beg (point) 'mouse-face nil))) -\f + ;; Commands to mark or flag file(s) at or near current line. (defun dired-repeat-over-lines (arg function) @@ -4014,7 +4020,7 @@ (message (if (= count 1) "1 mark removed" "%d marks removed") count)))) -\f + ;; Logging failures operating on files, and showing the results. (defvar dired-log-buffer "*Dired log*") @@ -4080,7 +4086,7 @@ ;; Log a summary describing a bunch of errors. (dired-log (concat "\n" string "\n")) (dired-log t)) -\f + ;;; Sorting ;; Most ls can only sort by name or by date (with -t), nothing else. @@ -4114,23 +4120,39 @@ "Non-nil means the Dired sort command is disabled. The idea is to set this buffer-locally in special Dired buffers.") +(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) + (if dired-mode-line-hook + (progn + (let ((mode-info "")) + (dolist (hook dired-mode-line-hook) + (setq mode-info (concat " " (funcall hook)))) + (setq mode-name (concat mode-name mode-info)))) + (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 literally. + ;; shown literally if user has not disabled displaying them by + ;; customizing dired-display-listing-switches variable. (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))))) - (force-mode-line-update))) + (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 (concat " " dired-actual-switches)))) + mode-line-info))) (define-obsolete-function-alias 'dired-sort-set-modeline #'dired-sort-set-mode-line "24.3") @@ -4174,7 +4196,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 +4219,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 @@ -4233,7 +4255,6 @@ ;; No pre-R subdir alist, so revert to main directory ;; listing: (list (car (reverse dired-subdir-alist)))))))) -\f ;;;; Drag and drop support @@ -4337,7 +4358,6 @@ (let ((local-file (dnd-get-local-file-uri uri))) (if local-file (dired-dnd-handle-local-file local-file action) nil))) -\f ;;;; Desktop support ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 3:01 ` Arthur Miller @ 2020-05-17 15:17 ` Eli Zaretskii 2020-05-17 16:34 ` Arthur Miller 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-05-17 15:17 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > From: Arthur Miller <arthur.miller@live.com> > Cc: drew.adams@oracle.com, 41250@debbugs.gnu.org, juri@linkov.net > Date: Sun, 17 May 2020 05:01:53 +0200 > > I have introduced dired-mode-line-hook, which is a usual thing in Emacs, > which is ment as a list of hooks that user can set. Each hook should > return a string that will be concatenated to the lighter. So users can > print whatever they want to that string (number of files, dirs etc). > > I have introduced also another function that will just iterate through > hooks concat stuff and update the modeline and refactored some code to > call this function instead of old dired-sort-set-modeline. Also > dired-sort-set-modeline is changed to work as a mentioned hook and is > used as default value for dired-mode-line-hook. > > If user does not prefer to see any aditional info on modeline then it is > just to set dired-mode-line-hook to nil. Obs, that can probably be coded > more elegantly, me & elisp are maybe not best friends (yet :-)). I have > built and tested emacs with the patch, but I might have missed > something. Once again, I think users should have simple means to request simple variations in behavior. A hook is not a simple means, it requires non-trivial knowledge of Lisp. So it should not be the only or main solution to such problems. > While I was looking through the code to set myself into dired, I have > also noticed lots of '^L' chars, I took the freedom to clean it up where > I saw them, there are probably more. You shouldn't remove them, they divide large files into sections, and make it easy to move by "pages". ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 15:17 ` Eli Zaretskii @ 2020-05-17 16:34 ` Arthur Miller 2020-05-17 16:42 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-17 16:34 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri Eli Zaretskii <eliz@gnu.org> writes: >> From: Arthur Miller <arthur.miller@live.com> >> Cc: drew.adams@oracle.com, 41250@debbugs.gnu.org, juri@linkov.net >> Date: Sun, 17 May 2020 05:01:53 +0200 >> >> I have introduced dired-mode-line-hook, which is a usual thing in Emacs, >> which is ment as a list of hooks that user can set. Each hook should >> return a string that will be concatenated to the lighter. So users can >> print whatever they want to that string (number of files, dirs etc). >> >> I have introduced also another function that will just iterate through >> hooks concat stuff and update the modeline and refactored some code to >> call this function instead of old dired-sort-set-modeline. Also >> dired-sort-set-modeline is changed to work as a mentioned hook and is >> used as default value for dired-mode-line-hook. >> >> If user does not prefer to see any aditional info on modeline then it is >> just to set dired-mode-line-hook to nil. Obs, that can probably be coded >> more elegantly, me & elisp are maybe not best friends (yet :-)). I have >> built and tested emacs with the patch, but I might have missed >> something. > > Once again, I think users should have simple means to request simple > variations in behavior. A hook is not a simple means, it requires > non-trivial knowledge of Lisp. So it should not be the only or main > solution to such problems. I agree with what you say about elisping requiring more knowledge on users end, of course. Allowing for hooks is quite standard and usual in Emacs, so in that regard, it fits into the "emacs way", if I can call it so (and also a cheap way to get away with this :-)), but yes I agree it is not a newbie friendly. Really newbie friendly would involve adding more regexps, say for type and size and maybe some other "important" criteria, and also adding means of controlling display of those on modeline, either via customize (bunch of variables) or by some kind of gui I guess. Another considerations is that this really is a minor change, since this behaviour of Dired has existed for so long and nobody but me seems to complain about it. I guess, not many people are using dired in way I do, and/or are bothered by ls switches pushing stuff away on modeline. While I was looking to see if there was a solution before I coded mine, I couldn't find anyone asking on forums or SX about this, so I guess it was more of "advanced" usage anyway? In conclusion, it might be a lot of work for quite little regard in terms of how much people would use it. A hook is not that as nice as a gui of course, but it is still better then nothing. I don't know, what do you guys think, is it worth? Is there a need for that, I mean, more than "it would be nice to have"? Another suggestion: Instead of displaying ls-switches per se, dired could display just "by custom". It is consistent with "by name" and "by date" as of currently. Then when user hoovers over that part "by ..." the tooltip showing actuall regexp could be shown. I have a technical question regarding this: is it possilbe to detect in elisp when pointer howers over part of a string, i.e. part of mode-name on a lighter, since a lighter is a button. Would this be quite involved or it can be implemented easily? >> While I was looking through the code to set myself into dired, I have >> also noticed lots of '^L' chars, I took the freedom to clean it up where >> I saw them, there are probably more. > > You shouldn't remove them, they divide large files into sections, and > make it easy to move by "pages". Aha, that is why all those were there; I didn't know. Sorry, I'll never ever touch them again :-). Thanks for the explanation. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 16:34 ` Arthur Miller @ 2020-05-17 16:42 ` Eli Zaretskii 2020-05-17 22:57 ` Arthur Miller 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-05-17 16:42 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > From: Arthur Miller <arthur.miller@live.com> > Cc: drew.adams@oracle.com, 41250@debbugs.gnu.org, juri@linkov.net > Date: Sun, 17 May 2020 18:34:53 +0200 > > I have a technical question regarding this: is it possilbe to detect in > elisp when pointer howers over part of a string, i.e. part of mode-name > on a lighter, since a lighter is a button. Would this be quite involved > or it can be implemented easily? You need to define different help-echo strings for different parts of the string, using text properties. You can see how this is done in bindings.el. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 16:42 ` Eli Zaretskii @ 2020-05-17 22:57 ` Arthur Miller 2020-05-17 23:37 ` Stefan Kangas 2020-05-18 14:25 ` Eli Zaretskii 0 siblings, 2 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-17 22:57 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri Eli Zaretskii <eliz@gnu.org> writes: >> From: Arthur Miller <arthur.miller@live.com> >> Cc: drew.adams@oracle.com, 41250@debbugs.gnu.org, juri@linkov.net >> Date: Sun, 17 May 2020 18:34:53 +0200 >> >> I have a technical question regarding this: is it possilbe to detect in >> elisp when pointer howers over part of a string, i.e. part of mode-name >> on a lighter, since a lighter is a button. Would this be quite involved >> or it can be implemented easily? > > You need to define different help-echo strings for different parts of > the string, using text properties. You can see how this is done in > bindings.el. Yes. 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? If we can assume that, then I can add sort by extension & size, and feature to group dirs first and reverse sort. I can try to detect if gnu ls is present say when dired-mode is loaded, but that would slow down dired every time we open a directory. I can also make a customize option for user to enable those regexpes which requires that user is knowledgable what he/she has on the system, but maybe it is fairly safe to assume that most people have gnu ls these days? :-) Sorry ... ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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 1 sibling, 1 reply; 79+ messages in thread From: Stefan Kangas @ 2020-05-17 23:37 UTC (permalink / raw) To: Arthur Miller, Eli Zaretskii; +Cc: 41250, juri 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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 23:37 ` Stefan Kangas @ 2020-05-18 15:08 ` Arthur Miller 0 siblings, 0 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-18 15:08 UTC (permalink / raw) To: Stefan Kangas; +Cc: 41250, juri [-- 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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-17 22:57 ` Arthur Miller 2020-05-17 23:37 ` Stefan Kangas @ 2020-05-18 14:25 ` Eli Zaretskii 1 sibling, 0 replies; 79+ messages in thread From: Eli Zaretskii @ 2020-05-18 14:25 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > From: Arthur Miller <arthur.miller@live.com> > Cc: drew.adams@oracle.com, 41250@debbugs.gnu.org, juri@linkov.net > Date: Mon, 18 May 2020 00:57:42 +0200 > > 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? No, we cannot assume GNU 'ls', since both *BSD Unix systems and macOS (which is BSD-ish) use non-GNU 'ls'. > I can try to detect if gnu ls is present say when dired-mode is > loaded, but that would slow down dired every time we open a directory. Don't we already detect GNU 'ls' by looking at the //DIRED signature? Look in files.el. ^ permalink raw reply [flat|nested] 79+ messages in thread
[parent not found: <<VI1PR06MB4526BAF92DBDCEA6A75D7A0196BD0@VI1PR06MB4526.eurprd06.prod.outlook.com>]
[parent not found: <<835zcwv15e.fsf@gnu.org>]
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline [not found] ` <<835zcwv15e.fsf@gnu.org> @ 2020-05-16 14:42 ` Drew Adams 0 siblings, 0 replies; 79+ messages in thread From: Drew Adams @ 2020-05-16 14:42 UTC (permalink / raw) To: Eli Zaretskii, Arthur Miller; +Cc: 41250, juri > > maybe Drews idea to have a format string is > > maybe the most flexible one? A function, rather than just a format string, is clearly the most flexible one, of the ones I made available as choices for the option value. And many more users will know how to define a simple function that returns something than will necessarily know about `format' etc. > Not IMO. Using format strings and functions is > "advanced usage", which is normally barred for > newbies and relatively inexperienced Emacs users. > Popular options should IMO be exposed though > easier customization values. Where is it barred to have an option `choice' that allows for a function value? If that were the case then we would presumably not even have `function' as a `defcustom' type. Likewise other types, such as `regexp' and `alist'. The Customize UI is, after all, for newbies too. Some (not I) think it is primarily or _only_ for newbies. But more importantly, there are also very simple choices defined for this option (and `function' is the last in `Value Menu'). And the default behavior is nil - which keeps the longstanding behavior. Nothing obliges a newbie to customize the option to a function value. Barring the use of options that have a function - or a regexp, for that matter - as one of a set of `choice's would be very wrong, IMHO. And I don't see such a barring or convention anywhere in the doc. Anyway, do what you want. If this isn't taken up by vanilla Emacs I'll use it in Dired+. My preference is for vanilla Emacs to do it, to lessen my own maintenance burden, but it's not a big deal. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 18:55 ` Drew Adams 2020-05-15 19:09 ` Eli Zaretskii @ 2020-05-15 19:54 ` Arthur Miller 2020-05-15 22:19 ` Drew Adams 2020-05-16 23:11 ` Juri Linkov 2 siblings, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-15 19:54 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, Juri Linkov Drew Adams <drew.adams@oracle.com> writes: > Attached is a patch that does what I think > should be done. The option value can be: > > nil - to get the current behavior > `as-is' - show the full switches > an integer - show first N chars of switches > a function - show whatever it returns, when > passed `dired-actual-switches' Cool. I was actually sitting and coding but you have already done it, nice. I have just one question/suggestion: You first choice: indicate by name or date, else full. Does it really need to be there? ls-switches are displayed only when dired is not sorted by name or date, i.e. custom hence displaying ls switches as part of mode name. Thus this customization only touches displaying of switches when they are displayd. I.e. it should be about "how", not "when". To explain my thought: that is a hard-coded behaviour which user can't customize anway. By looking at your code, that bevahviour indeed persists. 2nd choice is the one that actually consider how switches will be displayed. I have same consideration about 3rd choice too. Function 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. As I perceive it. Maybe it should get it's own custom variable instead? Like dired-mode-line-display-hook or something similar? 2nd option, one with number does what the proposed variable name suggests. Personally I ment to code just short (first switch) and long (all switches), since probably the first one is the most important one. 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. 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. That is just my opinion, in general I think it does the jobb anyway, so if you guys are happy, I am happy. As long as it is possible to get rid of switches on modeline in some way, it is an improvement. > diff -u dired.el dired-2020-05-15a-PATCHED.el > --- dired.el 2020-05-15 11:23:32.804823800 -0700 > +++ dired-2020-05-15a-PATCHED.el 2020-05-15 11:26:20.702051000 -0700 > @@ -4114,22 +4114,40 @@ > "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 `dired-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 dired-switches-in-mode-line > + (concat "Dired " > + (cond ((integerp dired-switches-in-mode-line) > + (substring dired-actual-switches > + 0 dired-switches-in-mode-line)) > + ((functionp dired-switches-in-mode-line) > + (format "%s" (funcall dired-switches-in-mode-line > + dired-actual-switches))) > + (t 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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 19:54 ` Arthur Miller @ 2020-05-15 22:19 ` Drew Adams 2020-05-15 22:24 ` Drew Adams 0 siblings, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-05-15 22:19 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, Juri Linkov [-- 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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 22:19 ` Drew Adams @ 2020-05-15 22:24 ` Drew Adams 2020-09-30 16:02 ` Lars Ingebrigtsen 0 siblings, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-05-15 22:24 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, Juri Linkov [-- Attachment #1: Type: text/plain, Size: 83 bytes --] Sorry. `diredp' should be `dired' everywhere. This patch takes care of that typo. [-- Attachment #2: dired-2020-05-15c.patch --] [-- Type: application/octet-stream, Size: 3095 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 `dired-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 dired-switches-in-mode-line + (concat "Dired" + (cond ((integerp dired-switches-in-mode-line) + (let* ((l1 (length dired-actual-switches)) + (xs (substring dired-actual-switches + 0 (min l1 dired-switches-in-mode-line))) + (l2 (length xs))) + (if (zerop l2) + xs + (concat " " xs (and (< l2 l1) "…"))))) + ((functionp dired-switches-in-mode-line) + (format " %s" (funcall dired-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 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 22:24 ` Drew Adams @ 2020-09-30 16:02 ` Lars Ingebrigtsen 2020-09-30 19:04 ` Juri Linkov 2020-09-30 20:56 ` Drew Adams 0 siblings, 2 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-09-30 16:02 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, Arthur Miller, Juri Linkov Drew Adams <drew.adams@oracle.com> writes: > Sorry. `diredp' should be `dired' everywhere. > This patch takes care of that typo. Looks good to me, so I've now applied your patch to Emacs 28. Some bikeshedding ensued, and people should feel free to alter the code (as-is vs t, for instance). And I'm not sure about this: + (concat " " xs (and (< l2 l1) "…"))))) Perhaps that should be conditional upon the terminal being able to display that character? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 16:02 ` Lars Ingebrigtsen @ 2020-09-30 19:04 ` Juri Linkov 2020-09-30 19:30 ` Lars Ingebrigtsen 2020-09-30 21:07 ` Drew Adams 2020-09-30 20:56 ` Drew Adams 1 sibling, 2 replies; 79+ messages in thread From: Juri Linkov @ 2020-09-30 19:04 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller > Drew Adams <drew.adams@oracle.com> writes: > >> Sorry. `diredp' should be `dired' everywhere. >> This patch takes care of that typo. > > Looks good to me, so I've now applied your patch to Emacs 28. > > Some bikeshedding ensued, and people should feel free to alter the code > (as-is vs t, for instance). I recall I asked for 't' instead of 'as-is', but actually 'as-is' is fine as a value as long as it is not checked for this value in function body. And indeed it's on the 't' branch of 'cond'. > And I'm not sure about this: > > + (concat " " xs (and (< l2 l1) "…"))))) > > Perhaps that should be conditional upon the terminal being able to > display that character? Like everywhere else (if (char-displayable-p ?…) "…" "...") ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:04 ` Juri Linkov @ 2020-09-30 19:30 ` Lars Ingebrigtsen 2020-09-30 19:58 ` Juri Linkov 2020-10-01 2:30 ` Eli Zaretskii 2020-09-30 21:07 ` Drew Adams 1 sibling, 2 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-09-30 19:30 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: >> And I'm not sure about this: >> >> + (concat " " xs (and (< l2 l1) "…"))))) >> >> Perhaps that should be conditional upon the terminal being able to >> display that character? > > Like everywhere else (if (char-displayable-p ?…) "…" "...") Yes. But this is surely a general problem, and: `truncate-string-to-width'. ---- If ELLIPSIS is non-nil, it should be a string which will replace the end of STR (including any padding) if it extends beyond END-COLUMN, unless the display width of STR is equal to or less than the display width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS defaults to ‘truncate-string-ellipsis’. ---- *sigh* Would anybody mind very much if I added a `string-truncate-right' that does all this automatically, and amend `string-truncate-left' in the same way? I.e., use (if (char-displayable-p ?…) "…" "..."). -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:30 ` Lars Ingebrigtsen @ 2020-09-30 19:58 ` Juri Linkov 2020-09-30 19:59 ` Lars Ingebrigtsen 2020-10-01 2:30 ` Eli Zaretskii 1 sibling, 1 reply; 79+ messages in thread From: Juri Linkov @ 2020-09-30 19:58 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller > Would anybody mind very much if I added a `string-truncate-right' that > does all this automatically, and amend `string-truncate-left' in the > same way? I.e., use (if (char-displayable-p ?…) "…" "..."). There is a better function 'truncate-string-to-width'. But users need to set up 'truncate-string-ellipsis' explicitly in init files as (with-eval-after-load 'mule-util (setq truncate-string-ellipsis "…")) ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:58 ` Juri Linkov @ 2020-09-30 19:59 ` Lars Ingebrigtsen 2020-10-01 19:37 ` Juri Linkov 0 siblings, 1 reply; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-09-30 19:59 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: > There is a better function 'truncate-string-to-width'. I mentioned that in the previous paragraph. :-/ -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:59 ` Lars Ingebrigtsen @ 2020-10-01 19:37 ` Juri Linkov 2020-10-01 19:59 ` Lars Ingebrigtsen 2020-10-01 20:01 ` Lars Ingebrigtsen 0 siblings, 2 replies; 79+ messages in thread From: Juri Linkov @ 2020-10-01 19:37 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller >> There is a better function 'truncate-string-to-width'. > > I mentioned that in the previous paragraph. :-/ Oh, sorry. But anyway I think that it would be better to keep 'truncate-string-to-width', and to turn 'truncate-string-ellipsis' into a user option (defvar -> defcustom) with the default value computed as (if (char-displayable-p ?…) "…" "...") If this doesn't work on dynamically created mixed X/tty frames, then maybe allow some value (e.g. 'auto-detect') for 'truncate-string-ellipsis', so 'truncate-string-to-width' would call (if (char-displayable-p ?…) "…" "...") every time when 'truncate-string-to-width' is used and recompute the value of ellipsis. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 19:37 ` Juri Linkov @ 2020-10-01 19:59 ` Lars Ingebrigtsen 2020-10-02 6:31 ` Eli Zaretskii 2020-10-02 6:54 ` Juri Linkov 2020-10-01 20:01 ` Lars Ingebrigtsen 1 sibling, 2 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-01 19:59 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: > But anyway I think that it would be better to keep > 'truncate-string-to-width', and to turn 'truncate-string-ellipsis' > into a user option (defvar -> defcustom) with the default value > computed as (if (char-displayable-p ?…) "…" "...") > > If this doesn't work on dynamically created mixed X/tty frames, then > maybe allow some value (e.g. 'auto-detect') for > 'truncate-string-ellipsis', so 'truncate-string-to-width' would call > (if (char-displayable-p ?…) "…" "...") every time when > 'truncate-string-to-width' is used and recompute the value of > ellipsis. The variable doesn't work as is (because of the problem of mixed frames), and `auto-detect' doesn't have much meaning, which is why this should never have been a variable in the first place. Instead of trying to fix that mess, I thought it would be easier to introduce a new function that does the right thing automatically, and without a gazillion optional parameters, and then make the old function obsolete. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 19:59 ` Lars Ingebrigtsen @ 2020-10-02 6:31 ` Eli Zaretskii 2020-10-02 14:10 ` Lars Ingebrigtsen 2020-10-02 6:54 ` Juri Linkov 1 sibling, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-02 6:31 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, arthur.miller, juri > From: Lars Ingebrigtsen <larsi@gnus.org> > Date: Thu, 01 Oct 2020 21:59:13 +0200 > Cc: 41250@debbugs.gnu.org, Arthur Miller <arthur.miller@live.com> > > Juri Linkov <juri@linkov.net> writes: > > > But anyway I think that it would be better to keep > > 'truncate-string-to-width', and to turn 'truncate-string-ellipsis' > > into a user option (defvar -> defcustom) with the default value > > computed as (if (char-displayable-p ?…) "…" "...") > > > > If this doesn't work on dynamically created mixed X/tty frames, then > > maybe allow some value (e.g. 'auto-detect') for > > 'truncate-string-ellipsis', so 'truncate-string-to-width' would call > > (if (char-displayable-p ?…) "…" "...") every time when > > 'truncate-string-to-width' is used and recompute the value of > > ellipsis. > > The variable doesn't work as is (because of the problem of mixed > frames), and `auto-detect' doesn't have much meaning, which is why this > should never have been a variable in the first place. > > Instead of trying to fix that mess, I thought it would be easier to > introduce a new function that does the right thing automatically, and > without a gazillion optional parameters, and then make the old function > obsolete. How about making char-displayable-p accept an optional argument, a frame for which to perform the test? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 6:31 ` Eli Zaretskii @ 2020-10-02 14:10 ` Lars Ingebrigtsen 2020-10-02 14:57 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-02 14:10 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, arthur.miller, juri Eli Zaretskii <eliz@gnu.org> writes: > How about making char-displayable-p accept an optional argument, a > frame for which to perform the test? I thought char-displayable-p worked based on the current frame? Which is what we'd want in a truncate-string-visually function (or whatever it'd be called). But having that function take an optional frame parameter wouldn't help with the initialisation of the 'truncate-string-ellipsis' variable (a variable I think is misguided)... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 14:10 ` Lars Ingebrigtsen @ 2020-10-02 14:57 ` Eli Zaretskii 2020-10-03 17:36 ` Lars Ingebrigtsen 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-02 14:57 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, arthur.miller, juri > From: Lars Ingebrigtsen <larsi@gnus.org> > Cc: juri@linkov.net, 41250@debbugs.gnu.org, arthur.miller@live.com > Date: Fri, 02 Oct 2020 16:10:41 +0200 > > Eli Zaretskii <eliz@gnu.org> writes: > > > How about making char-displayable-p accept an optional argument, a > > frame for which to perform the test? > > I thought char-displayable-p worked based on the current frame? The selected-frame, yes. I though that wasn't good enough in this case, but maybe I was confused? If the latter, what exactly is the problem that caused you to say "The variable doesn't work as is (because of the problem of mixed frames)"? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 14:57 ` Eli Zaretskii @ 2020-10-03 17:36 ` Lars Ingebrigtsen 0 siblings, 0 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-03 17:36 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, arthur.miller, juri Eli Zaretskii <eliz@gnu.org> writes: >> > How about making char-displayable-p accept an optional argument, a >> > frame for which to perform the test? >> >> I thought char-displayable-p worked based on the current frame? > > The selected-frame, yes. I though that wasn't good enough in this > case, but maybe I was confused? If the latter, what exactly is the > problem that caused you to say "The variable doesn't work as is > (because of the problem of mixed frames)"? There's a variable -- 'truncate-string-ellipsis' -- set globally, and it was suggested that the default of that variable should depend on char-displayable-p. I pointed out that that isn't very useful, in general, in a mixed frame situation. The char-displayable-p function is fine as is, though. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 19:59 ` Lars Ingebrigtsen 2020-10-02 6:31 ` Eli Zaretskii @ 2020-10-02 6:54 ` Juri Linkov 2020-10-02 14:14 ` Lars Ingebrigtsen 1 sibling, 1 reply; 79+ messages in thread From: Juri Linkov @ 2020-10-02 6:54 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller [-- Attachment #1: Type: text/plain, Size: 882 bytes --] > The variable doesn't work as is (because of the problem of mixed > frames), and `auto-detect' doesn't have much meaning, which is why this > should never have been a variable in the first place. > > Instead of trying to fix that mess, I thought it would be easier to > introduce a new function that does the right thing automatically, and > without a gazillion optional parameters, and then make the old function > obsolete. I have no opinion about a new function. Like everyone else, I'm using truncate-string-to-width, and happy with it, except of one complaint: on every use I need to wrap it with such code: (let ((ellipsis (cond (truncate-string-ellipsis) ((char-displayable-p ?…) "…") ("...")))) (truncate-string-to-width string max nil nil ellipsis)) Preferably, this should be fixed with this patch: [-- Attachment #2: truncate-string-ellipsis.patch --] [-- Type: text/x-diff, Size: 1077 bytes --] diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 660ac58e02..a2bd5802cc 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -44,10 +44,16 @@ store-substring (setq i (1+ i))))) string) -(defvar truncate-string-ellipsis "..." ;"…" +(defvar truncate-string-ellipsis nil "String to use to indicate truncation. Serves as default value of ELLIPSIS argument to `truncate-string-to-width'.") +(defun truncate-string-ellipsis () + (cond + (truncate-string-ellipsis) + ((char-displayable-p ?…) "…") + ("..."))) + ;;;###autoload (defun truncate-string-to-width (str end-column &optional start-column padding ellipsis @@ -81,7 +87,7 @@ truncate-string-to-width (or start-column (setq start-column 0)) (when (and ellipsis (not (stringp ellipsis))) - (setq ellipsis truncate-string-ellipsis)) + (setq ellipsis (truncate-string-ellipsis))) (let ((str-len (length str)) (str-width (string-width str)) (ellipsis-width (if ellipsis (string-width ellipsis) 0)) ^ permalink raw reply related [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 6:54 ` Juri Linkov @ 2020-10-02 14:14 ` Lars Ingebrigtsen 2020-10-02 14:59 ` Eli Zaretskii 2020-10-04 19:44 ` Juri Linkov 0 siblings, 2 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-02 14:14 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: > I have no opinion about a new function. Like everyone else, I'm using > truncate-string-to-width, and happy with it, except of one complaint: > on every use I need to wrap it with such code: > > (let ((ellipsis (cond > (truncate-string-ellipsis) > ((char-displayable-p ?…) "…") > ("...")))) > (truncate-string-to-width string max nil nil ellipsis)) > > Preferably, this should be fixed with this patch: Your patch is a distinct improvement on the current state of affairs, so please go ahead and push to master (with a NEWS item). A new function that's more pixel-aware can be added at a later date, and is pretty much an orthogonal issue anyway. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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 1 sibling, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-02 14:59 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, arthur.miller, juri > From: Lars Ingebrigtsen <larsi@gnus.org> > Date: Fri, 02 Oct 2020 16:14:31 +0200 > Cc: 41250@debbugs.gnu.org, Arthur Miller <arthur.miller@live.com> > > > (let ((ellipsis (cond > > (truncate-string-ellipsis) > > ((char-displayable-p ?…) "…") > > ("...")))) > > (truncate-string-to-width string max nil nil ellipsis)) > > > > Preferably, this should be fixed with this patch: > > Your patch is a distinct improvement on the current state of affairs, so > please go ahead and push to master (with a NEWS item). > > A new function that's more pixel-aware can be added at a later date, and > is pretty much an orthogonal issue anyway. To be pixel-aware, we need to use window-text-pixel-size. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 14:59 ` Eli Zaretskii @ 2020-10-03 17:38 ` Lars Ingebrigtsen 0 siblings, 0 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-03 17:38 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, arthur.miller, juri Eli Zaretskii <eliz@gnu.org> writes: > To be pixel-aware, we need to use window-text-pixel-size. Yup. This is the strategy that eww--pixel-column and friends use to figure out where to truncate the title in the header line of the eww buffers. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-02 14:14 ` Lars Ingebrigtsen 2020-10-02 14:59 ` Eli Zaretskii @ 2020-10-04 19:44 ` Juri Linkov 2020-10-05 7:08 ` Lars Ingebrigtsen 2020-10-05 15:49 ` Glenn Morris 1 sibling, 2 replies; 79+ messages in thread From: Juri Linkov @ 2020-10-04 19:44 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller >> on every use I need to wrap it with such code: >> >> (let ((ellipsis (cond >> (truncate-string-ellipsis) >> ((char-displayable-p ?…) "…") >> ("...")))) >> (truncate-string-to-width string max nil nil ellipsis)) >> >> Preferably, this should be fixed with this patch: > > Your patch is a distinct improvement on the current state of affairs, so > please go ahead and push to master (with a NEWS item). Pushed now with a NEWS item. When I grepped for more usages of truncate-string-to-width, I found one call in Gnus. It seems this patch could improve gnus-set-mode-line, but I'm not sure, and moreover I have no idea how to test this: diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index b3ed5cb664..42ba4fbd71 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -6240,8 +6240,7 @@ gnus-set-mode-line ;; We might have to chop a bit of the string off... (when (> (length mode-string) max-len) (setq mode-string - (concat (truncate-string-to-width mode-string (- max-len 3)) - "..."))))) + (truncate-string-to-width mode-string (- max-len 3) nil nil t))))) ;; Update the mode line. (setq mode-line-buffer-identification (gnus-mode-line-buffer-identification (list mode-string))) Here is another function, and it needs not just an improvement, but a plain bug fix because its args were wrong, and this patch should fix its args, but again currently I don't yet know how to test this: diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index c9a748830c..8ff3b56c5e 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -1597,7 +1597,7 @@ ibuffer-compile-make-eliding-form (defun ibuffer-compile-make-substring-form (strvar maxvar from-end-p) (if from-end-p ;; FIXME: not sure if this case is correct (Bug#24972) - `(truncate-string-to-width str strlen (- strlen ,maxvar) nil ?\s) + `(truncate-string-to-width str strlen (- strlen ,maxvar) ?\s) `(truncate-string-to-width ,strvar ,maxvar nil ?\s))) (defun ibuffer-compile-make-format-form (strvar widthform alignment) ^ permalink raw reply related [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-04 19:44 ` Juri Linkov @ 2020-10-05 7:08 ` Lars Ingebrigtsen 2020-10-05 20:15 ` Juri Linkov 2020-10-05 15:49 ` Glenn Morris 1 sibling, 1 reply; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-05 7:08 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: > Pushed now with a NEWS item. Great! > When I grepped for more usages of truncate-string-to-width, I found > one call in Gnus. It seems this patch could improve gnus-set-mode-line, > but I'm not sure, and moreover I have no idea how to test this: [...] > - (concat (truncate-string-to-width mode-string (- max-len 3)) > - "..."))))) > + (truncate-string-to-width mode-string (- max-len 3) nil nil t))))) I applied the patch and tested it, and it looks fine, so I've pushed it to Emacs 28. > Here is another function, and it needs not just an improvement, > but a plain bug fix because its args were wrong, and this patch should fix > its args, but again currently I don't yet know how to test this: [...] > - `(truncate-string-to-width str strlen (- strlen ,maxvar) nil ?\s) > + `(truncate-string-to-width str strlen (- strlen ,maxvar) ?\s) > `(truncate-string-to-width ,strvar ,maxvar nil ?\s))) Testing should be pretty easy -- just say `M-x ibuffer' and look at how it truncates buffer names. :-) However, the patch doesn't fix the ellipsis stuff here, because ibuffer has a `ibuffer-eliding-string' variable (that could be obsoleted now). (But the patch otherwise looks "obviously correct" to me; passing in ?\s as the ellipsis argument doesn't make much sense.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 7:08 ` Lars Ingebrigtsen @ 2020-10-05 20:15 ` Juri Linkov 2020-10-06 1:37 ` Lars Ingebrigtsen 0 siblings, 1 reply; 79+ messages in thread From: Juri Linkov @ 2020-10-05 20:15 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller >> - `(truncate-string-to-width str strlen (- strlen ,maxvar) nil ?\s) >> + `(truncate-string-to-width str strlen (- strlen ,maxvar) ?\s) >> `(truncate-string-to-width ,strvar ,maxvar nil ?\s))) > > Testing should be pretty easy -- just say `M-x ibuffer' and look at how > it truncates buffer names. :-) > > However, the patch doesn't fix the ellipsis stuff here, because ibuffer > has a `ibuffer-eliding-string' variable (that could be obsoleted now). Yep, this is what I tried, but it had no immediate effect :-) > (But the patch otherwise looks "obviously correct" to me; passing in ?\s > as the ellipsis argument doesn't make much sense.) It seems this code is over-complicated with several levels of backquoting. So maybe better just to push this obvious fix. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 20:15 ` Juri Linkov @ 2020-10-06 1:37 ` Lars Ingebrigtsen 0 siblings, 0 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-06 1:37 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Juri Linkov <juri@linkov.net> writes: >> (But the patch otherwise looks "obviously correct" to me; passing in ?\s >> as the ellipsis argument doesn't make much sense.) > > It seems this code is over-complicated with several levels of backquoting. > So maybe better just to push this obvious fix. Yup. And ibuffer probably can't use the ellipsis stuff from the function anyway, because it wants to create a tabulated buffer layout, and assumes that all the characters have the same width. (I've just skimmed the code; I may well be wrong here.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-04 19:44 ` Juri Linkov 2020-10-05 7:08 ` Lars Ingebrigtsen @ 2020-10-05 15:49 ` Glenn Morris 2020-10-05 20:12 ` Juri Linkov 1 sibling, 1 reply; 79+ messages in thread From: Glenn Morris @ 2020-10-05 15:49 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Lars Ingebrigtsen, Arthur Miller 5ec2115 seems to cause a build failure in some cases. Ref https://hydra.nixos.org/build/128075429 ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 15:49 ` Glenn Morris @ 2020-10-05 20:12 ` Juri Linkov 2020-10-05 21:31 ` Andreas Schwab 2020-10-05 23:06 ` Glenn Morris 0 siblings, 2 replies; 79+ messages in thread From: Juri Linkov @ 2020-10-05 20:12 UTC (permalink / raw) To: Glenn Morris; +Cc: 41250, Lars Ingebrigtsen, Arthur Miller > 5ec2115 seems to cause a build failure in some cases. > Ref https://hydra.nixos.org/build/128075429 I tried to bootstrap several times, but can't reproduce the error. Here are the relevant parts of the hydra log: make -C ../leim all EMACS="../src/bootstrap-emacs" GEN ../lisp/leim/ja-dic/ja-dic.el INFO Processing OKURI-ARI entries INFO Processing POSTFIX entries Loading macroexp.elc... Invalid read syntax: "?" make[3]: *** [Makefile:143: ../lisp/leim/ja-dic/ja-dic.el] Error 255 When I tried the command make -C leim all EMACS="../src/bootstrap-emacs" its output was: GEN ../lisp/leim/ja-dic/ja-dic.el INFO Processing OKURI-ARI entries INFO Processing POSTFIX entries Source file `lisp/international/mule-util.el' newer than byte-compiled file; using older file INFO Processing PREFIX entries ... INFO Processing OKURI-NASI entries...done and successfully finished. The interesting line is "Source file `lisp/international/mule-util.el' newer" this means that skkdic-convert-postfix in ja-dic-cnv.el calls set-nested-alist that autoloads mule-util.el. So the question is why loading mule-util.el produces this error? It seems loading can't parse this recently added line: (char-displayable-p ?…) and gives the error `Invalid read syntax: "?"`. Maybe this Unicode character should be replaced in the source file with its name: (char-displayable-p ?\N{HORIZONTAL ELLIPSIS}) ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 20:12 ` Juri Linkov @ 2020-10-05 21:31 ` Andreas Schwab 2020-10-06 13:08 ` Stefan Monnier 2020-10-05 23:06 ` Glenn Morris 1 sibling, 1 reply; 79+ messages in thread From: Andreas Schwab @ 2020-10-05 21:31 UTC (permalink / raw) To: Juri Linkov; +Cc: Glenn Morris, Lars Ingebrigtsen, Arthur Miller, 41250 On Okt 05 2020, Juri Linkov wrote: > So the question is why loading mule-util.el produces this error? Because skkdic-convert binds coding-system-for-read to euc-japan. $ ../src/bootstrap-emacs -batch --eval "(let ((coding-system-for-read 'euc-japan)) (require 'mule-util))" Invalid read syntax: "?" Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 21:31 ` Andreas Schwab @ 2020-10-06 13:08 ` Stefan Monnier 2020-10-06 13:28 ` Andreas Schwab 0 siblings, 1 reply; 79+ messages in thread From: Stefan Monnier @ 2020-10-06 13:08 UTC (permalink / raw) To: Andreas Schwab Cc: 41250, Lars Ingebrigtsen, Juri Linkov, Arthur Miller, Glenn Morris >> So the question is why loading mule-util.el produces this error? > Because skkdic-convert binds coding-system-for-read to euc-japan. > > $ ../src/bootstrap-emacs -batch --eval "(let ((coding-system-for-read > 'euc-japan)) (require 'mule-util))" > Invalid read syntax: "?" Does the patch below address the issue? Stefan diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index f5e70ce702..5f645b6e8e 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -329,12 +329,12 @@ skkdic-convert the generated Emacs Lisp is saved. The name of generated file is specified by the variable `ja-dic-filename'." (interactive "FSKK dictionary file: ") - (let* ((coding-system-for-read 'euc-japan) - (skkbuf (get-buffer-create " *skkdic-unannotated*")) + (let* ((skkbuf (get-buffer-create " *skkdic-unannotated*")) (buf (get-buffer-create "*skkdic-work*"))) ;; Set skkbuf to an unannotated copy of the dictionary. (with-current-buffer skkbuf - (insert-file-contents (expand-file-name filename)) + (let ((coding-system-for-read 'euc-japan)) + (insert-file-contents (expand-file-name filename))) (re-search-forward "^[^;]") (while (re-search-forward ";[^\n/]*/" nil t) (replace-match "/"))) ^ permalink raw reply related [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 13:08 ` Stefan Monnier @ 2020-10-06 13:28 ` Andreas Schwab 0 siblings, 0 replies; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 13:28 UTC (permalink / raw) To: Stefan Monnier Cc: 41250, Lars Ingebrigtsen, Juri Linkov, Arthur Miller, Glenn Morris On Okt 06 2020, Stefan Monnier wrote: >>> So the question is why loading mule-util.el produces this error? >> Because skkdic-convert binds coding-system-for-read to euc-japan. >> >> $ ../src/bootstrap-emacs -batch --eval "(let ((coding-system-for-read >> 'euc-japan)) (require 'mule-util))" >> Invalid read syntax: "?" > > Does the patch below address the issue? It is the right way to use coding-system-for-read in any case. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 20:12 ` Juri Linkov 2020-10-05 21:31 ` Andreas Schwab @ 2020-10-05 23:06 ` Glenn Morris 2020-10-06 7:13 ` Andreas Schwab 1 sibling, 1 reply; 79+ messages in thread From: Glenn Morris @ 2020-10-05 23:06 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Lars Ingebrigtsen, Arthur Miller Juri Linkov wrote: >> 5ec2115 seems to cause a build failure in some cases. >> Ref https://hydra.nixos.org/build/128075429 > > I tried to bootstrap several times, but can't reproduce the error. I think doing a non-parallel build in a completely clean tree (not just a bootstrap) should make it reproducible. > make -C leim all EMACS="../src/bootstrap-emacs" > Source file `lisp/international/mule-util.el' newer than byte-compiled file; using older file leim/Makefile.in should probably set load-prefer-newer, as lisp/Makefile.in does. > So the question is why loading mule-util.el produces this error? Thanks to Andreas for answering that. Simply making ja-dic-cnv.el require mule-util at top-level seems to avoid the problem? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-05 23:06 ` Glenn Morris @ 2020-10-06 7:13 ` Andreas Schwab 2020-10-06 7:18 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 7:13 UTC (permalink / raw) To: Glenn Morris; +Cc: 41250, Lars Ingebrigtsen, Arthur Miller, Juri Linkov On Okt 05 2020, Glenn Morris wrote: > Thanks to Andreas for answering that. Simply making ja-dic-cnv.el > require mule-util at top-level seems to avoid the problem? Autoloading should probably bind coding-system-for-read to nil. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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:52 ` Juri Linkov 0 siblings, 2 replies; 79+ messages in thread From: Eli Zaretskii @ 2020-10-06 7:18 UTC (permalink / raw) To: Andreas Schwab; +Cc: 41250, rgm, larsi, arthur.miller, juri > From: Andreas Schwab <schwab@linux-m68k.org> > Date: Tue, 06 Oct 2020 09:13:21 +0200 > Cc: 41250@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>, > Arthur Miller <arthur.miller@live.com>, Juri Linkov <juri@linkov.net> > > On Okt 05 2020, Glenn Morris wrote: > > > Thanks to Andreas for answering that. Simply making ja-dic-cnv.el > > require mule-util at top-level seems to avoid the problem? > > Autoloading should probably bind coding-system-for-read to nil. Perhaps if it is not already bound to something. But not unconditionally, I think. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 7:18 ` Eli Zaretskii @ 2020-10-06 7:28 ` Eli Zaretskii 2020-10-06 7:48 ` Andreas Schwab 2020-10-06 7:52 ` Juri Linkov 1 sibling, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-06 7:28 UTC (permalink / raw) To: schwab; +Cc: 41250, larsi, rgm, arthur.miller, juri > Date: Tue, 06 Oct 2020 10:18:17 +0300 > From: Eli Zaretskii <eliz@gnu.org> > Cc: 41250@debbugs.gnu.org, rgm@gnu.org, larsi@gnus.org, arthur.miller@live.com, > juri@linkov.net > > > Autoloading should probably bind coding-system-for-read to nil. > > Perhaps if it is not already bound to something. But not > unconditionally, I think. Actually, aren't *.elc files always encoded in utf-8-emacs? If so, perhaps we should treat them as such in load-with-code-conversion, bypassing coding-system-for-read entirely? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 7:28 ` Eli Zaretskii @ 2020-10-06 7:48 ` Andreas Schwab 2020-10-06 8:18 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 7:48 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, larsi, rgm, arthur.miller, juri On Okt 06 2020, Eli Zaretskii wrote: > Actually, aren't *.elc files always encoded in utf-8-emacs? This is about uncompiled files. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 7:48 ` Andreas Schwab @ 2020-10-06 8:18 ` Eli Zaretskii 2020-10-06 8:44 ` Andreas Schwab 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-06 8:18 UTC (permalink / raw) To: Andreas Schwab; +Cc: 41250, larsi, rgm, arthur.miller, juri > From: Andreas Schwab <schwab@linux-m68k.org> > Cc: 41250@debbugs.gnu.org, rgm@gnu.org, larsi@gnus.org, > arthur.miller@live.com, juri@linkov.net > Date: Tue, 06 Oct 2020 09:48:26 +0200 > > On Okt 06 2020, Eli Zaretskii wrote: > > > Actually, aren't *.elc files always encoded in utf-8-emacs? > > This is about uncompiled files. But the error message which started this bug report was about macroexp.elc, no? I guess I'm missing something. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 8:18 ` Eli Zaretskii @ 2020-10-06 8:44 ` Andreas Schwab 2020-10-06 9:03 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 8:44 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, larsi, rgm, arthur.miller, juri On Okt 06 2020, Eli Zaretskii wrote: > But the error message which started this bug report was about > macroexp.elc, no? No, this is unrelated. It just happend to be loaded at the same time. See the recipe in <87mu10s6kn.fsf@igel.home>. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 8:44 ` Andreas Schwab @ 2020-10-06 9:03 ` Eli Zaretskii 2020-10-06 9:17 ` Andreas Schwab 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-06 9:03 UTC (permalink / raw) To: Andreas Schwab; +Cc: 41250, larsi, rgm, arthur.miller, juri > From: Andreas Schwab <schwab@linux-m68k.org> > Cc: 41250@debbugs.gnu.org, rgm@gnu.org, larsi@gnus.org, > arthur.miller@live.com, juri@linkov.net > Date: Tue, 06 Oct 2020 10:44:30 +0200 > > On Okt 06 2020, Eli Zaretskii wrote: > > > But the error message which started this bug report was about > > macroexp.elc, no? > > No, this is unrelated. It just happend to be loaded at the same time. Ah, okay. So perhaps adding a coding: cookie in mule-utils.el would solve this? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 9:03 ` Eli Zaretskii @ 2020-10-06 9:17 ` Andreas Schwab 2020-10-06 9:24 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 9:17 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, larsi, rgm, arthur.miller, juri On Okt 06 2020, Eli Zaretskii wrote: > So perhaps adding a coding: cookie in mule-utils.el would solve this? No, coding-system-for-read takes precedence. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 9:17 ` Andreas Schwab @ 2020-10-06 9:24 ` Eli Zaretskii 2020-10-06 9:45 ` Andreas Schwab 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-06 9:24 UTC (permalink / raw) To: Andreas Schwab; +Cc: 41250, larsi, rgm, arthur.miller, juri > From: Andreas Schwab <schwab@linux-m68k.org> > Cc: 41250@debbugs.gnu.org, rgm@gnu.org, larsi@gnus.org, > arthur.miller@live.com, juri@linkov.net > Date: Tue, 06 Oct 2020 11:17:55 +0200 > > On Okt 06 2020, Eli Zaretskii wrote: > > > So perhaps adding a coding: cookie in mule-utils.el would solve this? > > No, coding-system-for-read takes precedence. Perhaps this is what we should change in load-with-code-conversion? Does it make sense to have any coding-system-for-read except no-conversion take precedence over an explicit file-local encoding value of a .el file? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 9:24 ` Eli Zaretskii @ 2020-10-06 9:45 ` Andreas Schwab 0 siblings, 0 replies; 79+ messages in thread From: Andreas Schwab @ 2020-10-06 9:45 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, larsi, rgm, arthur.miller, juri On Okt 06 2020, Eli Zaretskii wrote: > Perhaps this is what we should change in load-with-code-conversion? > Does it make sense to have any coding-system-for-read except > no-conversion take precedence over an explicit file-local encoding > value of a .el file? That's basically what I proposed. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-06 7:18 ` Eli Zaretskii 2020-10-06 7:28 ` Eli Zaretskii @ 2020-10-06 7:52 ` Juri Linkov 1 sibling, 0 replies; 79+ messages in thread From: Juri Linkov @ 2020-10-06 7:52 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, larsi, Andreas Schwab, arthur.miller, rgm >> > Thanks to Andreas for answering that. Simply making ja-dic-cnv.el >> > require mule-util at top-level seems to avoid the problem? >> >> Autoloading should probably bind coding-system-for-read to nil. > > Perhaps if it is not already bound to something. But not > unconditionally, I think. As a quick fix before deciding for a more general solution I replaced the character with its name. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 19:37 ` Juri Linkov 2020-10-01 19:59 ` Lars Ingebrigtsen @ 2020-10-01 20:01 ` Lars Ingebrigtsen 1 sibling, 0 replies; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-01 20:01 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller Perhaps call it... `limit-string-for-display'... And it could work for the displayed pixel width of all the characters involved, so that it'd also work on variable-pitch characters (and compute the correct length occupied for … vs ..., too. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:30 ` Lars Ingebrigtsen 2020-09-30 19:58 ` Juri Linkov @ 2020-10-01 2:30 ` Eli Zaretskii 2020-10-01 2:39 ` Lars Ingebrigtsen 1 sibling, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-10-01 2:30 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, arthur.miller, juri > From: Lars Ingebrigtsen <larsi@gnus.org> > Date: Wed, 30 Sep 2020 21:30:56 +0200 > Cc: 41250@debbugs.gnu.org, Arthur Miller <arthur.miller@live.com> > > Would anybody mind very much if I added a `string-truncate-right' that > does all this automatically, and amend `string-truncate-left' in the > same way? I.e., use (if (char-displayable-p ?…) "…" "..."). That could be useful, but it would be better if the name hinted on the fact that char-displayable-p is involved. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 2:30 ` Eli Zaretskii @ 2020-10-01 2:39 ` Lars Ingebrigtsen 2020-10-01 9:24 ` Andy Moreton 0 siblings, 1 reply; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-01 2:39 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, arthur.miller, juri Eli Zaretskii <eliz@gnu.org> writes: >> Would anybody mind very much if I added a `string-truncate-right' that >> does all this automatically, and amend `string-truncate-left' in the >> same way? I.e., use (if (char-displayable-p ?…) "…" "..."). > > That could be useful, but it would be better if the name hinted on the > fact that char-displayable-p is involved. Uhm... truncate-string-prettily? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 2:39 ` Lars Ingebrigtsen @ 2020-10-01 9:24 ` Andy Moreton 0 siblings, 0 replies; 79+ messages in thread From: Andy Moreton @ 2020-10-01 9:24 UTC (permalink / raw) To: 41250 On Thu 01 Oct 2020, Lars Ingebrigtsen wrote: > Eli Zaretskii <eliz@gnu.org> writes: > >>> Would anybody mind very much if I added a `string-truncate-right' that >>> does all this automatically, and amend `string-truncate-left' in the >>> same way? I.e., use (if (char-displayable-p ?…) "…" "..."). >> >> That could be useful, but it would be better if the name hinted on the >> fact that char-displayable-p is involved. > > Uhm... truncate-string-prettily? Using truncate could lead to confusion with string-trim-{left,right}. Perhaps string-elide-left etc ? AndyM ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 19:04 ` Juri Linkov 2020-09-30 19:30 ` Lars Ingebrigtsen @ 2020-09-30 21:07 ` Drew Adams 2020-10-01 1:25 ` Lars Ingebrigtsen 1 sibling, 1 reply; 79+ messages in thread From: Drew Adams @ 2020-09-30 21:07 UTC (permalink / raw) To: Juri Linkov, Lars Ingebrigtsen; +Cc: 41250, Arthur Miller > > And I'm not sure about this: > > > > + (concat " " xs (and (< l2 l1) > "…"))))) > > > > Perhaps that should be conditional upon the terminal being able to > > display that character? > > Like everywhere else (if (char-displayable-p ?…) "…" "...") I'd argue (but not forcefully) for just "...". As I mentioned, "…" is, for me, useless as an ellipsis. I think it must be useless for nearly everyone, with a fixed-width font. I imagine that I included it in the patch (it's not in my code, which is otherwise identical to what's in the patch) only because some were worried about mode-line real estate. Maybe it's worth a defvar (string value), so code that wants to tweak the mode-line can adapt it? ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 21:07 ` Drew Adams @ 2020-10-01 1:25 ` Lars Ingebrigtsen 2020-10-01 16:35 ` Drew Adams 0 siblings, 1 reply; 79+ messages in thread From: Lars Ingebrigtsen @ 2020-10-01 1:25 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, Arthur Miller, Juri Linkov Drew Adams <drew.adams@oracle.com> writes: > I'd argue (but not forcefully) for just "...". As I > mentioned, "…" is, for me, useless as an ellipsis. I think > it must be useless for nearly everyone, with a fixed-width > font. I kinda like … because it takes up so little space, and the reason we're normally truncating strings is because they take up too much space. So using that limited space for "..." is counter-productive. But this should be standardised throughout Emacs, and work out of the box automatically on systems that can display the character and not, which makes truncate-string-to-width less than ideal. There also, of course, the issue of "well, if the call says 'truncate to 15 characters', how much should we remove when we add the …?" Because … usually takes a bit more than a single normal character to display, while "..." takes three. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-10-01 1:25 ` Lars Ingebrigtsen @ 2020-10-01 16:35 ` Drew Adams 0 siblings, 0 replies; 79+ messages in thread From: Drew Adams @ 2020-10-01 16:35 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller, Juri Linkov > > I'd argue (but not forcefully) for just "...". As I > > mentioned, "…" is, for me, useless as an ellipsis. I think > > it must be useless for nearly everyone, with a fixed-width > > font. > > I kinda like … because it takes up so little space, and the reason we're > normally truncating strings is because they take up too much space. So > using that limited space for "..." is counter-productive. It's not about losing any more mode-line space. Instead, it should be about losing 2 more chars from the info displayed for this in the mode-line. > But this should be standardised throughout Emacs, and work out of the > box automatically on systems that can display the character and not, > which makes truncate-string-to-width less than ideal. > > There also, of course, the issue of "well, if the call says 'truncate to > 15 characters', how much should we remove when we add the …?" Because … > usually takes a bit more than a single normal character to display, > while "..." takes three. FTR, I disagree. Better to truncate an additional 2 chars and use a "real" ellipsis: "...". The single char ellipsis is awful, at least in any fixed-width font I've used. If we're truncating, we're truncating. Truncating 2 more chars is not so bad. It's more important to clearly pass the message that the thing _is_ truncated. And the ellipsis char doesn't do that clearly. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-09-30 16:02 ` Lars Ingebrigtsen 2020-09-30 19:04 ` Juri Linkov @ 2020-09-30 20:56 ` Drew Adams 1 sibling, 0 replies; 79+ messages in thread From: Drew Adams @ 2020-09-30 20:56 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: 41250, Arthur Miller, Juri Linkov > And I'm not sure about this: > > + (concat " " xs (and (< l2 l1) > "…"))))) > > Perhaps that should be conditional upon the terminal being able to > display that character? Interesting. Dunno why I used that char (which I guess is HORIZONTAL ELLIPSIS). In my own code I in fact use "..." (3 period chars). Maybe I tossed in an ellipsis char because others in the thread were worried about losing mode-line space. (FWIW, I had that ellipsis char in Emacs doc etc. At least in the fonts I use (fixed width) it's so tiny as to be illegible. An ellipsis in ordinary printed text is quite a bit wider than other chars (which are anyway of unequal width). That Unicode provides a single char for ellipsis is not a reason that we have to, or should, use it. I think it works against readability - everywhere I've seen it in Emacs.) ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 18:55 ` Drew Adams 2020-05-15 19:09 ` Eli Zaretskii 2020-05-15 19:54 ` Arthur Miller @ 2020-05-16 23:11 ` Juri Linkov 2020-05-17 1:16 ` Drew Adams 2 siblings, 1 reply; 79+ messages in thread From: Juri Linkov @ 2020-05-16 23:11 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, Arthur Miller > nil - to get the current behavior > `as-is' - show the full switches > an integer - show first N chars of switches > a function - show whatever it returns, when > passed `dired-actual-switches' Instead of `as-is' a simpler value could be just `t'. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-16 23:11 ` Juri Linkov @ 2020-05-17 1:16 ` Drew Adams 0 siblings, 0 replies; 79+ messages in thread From: Drew Adams @ 2020-05-17 1:16 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, Arthur Miller > > nil - to get the current behavior > > `as-is' - show the full switches > > an integer - show first N chars of switches > > a function - show whatever it returns, when > > passed `dired-actual-switches' > > Instead of `as-is' a simpler value could be just `t'. Simpler how? Because it's self-evaluating? :as-is ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-14 22:33 ` Juri Linkov 2020-05-14 23:42 ` Drew Adams @ 2020-05-15 6:43 ` Eli Zaretskii 2020-05-15 8:40 ` Arthur Miller 1 sibling, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-05-15 6:43 UTC (permalink / raw) To: Juri Linkov; +Cc: 41250, arthur.miller > From: Juri Linkov <juri@linkov.net> > Date: Fri, 15 May 2020 01:33:51 +0300 > Cc: 41250@debbugs.gnu.org > > > I suggest, as small improvement, to introduce a user option to turn off > > or on displaying of ls-switches on modeline. As a suggestion I have > > attached small hack to dired.el as tested on my copy of Emacs, but you > > might wish to rewrite it. Drew had some other suggestions. > > Maybe instead of boolean better to use a number for the allowed limit > that should not grow more than this number that means the length of > switches string that the user can tolerate on the modeline. > > Then modeline will display abbreviation truncated to the specified > number of characters, with an ellipses, on the assumption that > the most important switches are at the beginning of the string. That sounds better. Bonus points for arranging a tooltip that would show the full string when the mouse is over that part of the mode line. > Customizing it to 0 effectively disables the display of switches. Why not simply use nil? We could use zero, but that is a bit "tricky", and doesn't seem to me justified in this case. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 6:43 ` Eli Zaretskii @ 2020-05-15 8:40 ` Arthur Miller 2020-05-15 10:15 ` Eli Zaretskii 0 siblings, 1 reply; 79+ messages in thread From: Arthur Miller @ 2020-05-15 8:40 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, Juri Linkov Eli Zaretskii <eliz@gnu.org> writes: >> From: Juri Linkov <juri@linkov.net> >> Date: Fri, 15 May 2020 01:33:51 +0300 >> Cc: 41250@debbugs.gnu.org >> >> > I suggest, as small improvement, to introduce a user option to turn off >> > or on displaying of ls-switches on modeline. As a suggestion I have >> > attached small hack to dired.el as tested on my copy of Emacs, but you >> > might wish to rewrite it. Drew had some other suggestions. >> >> Maybe instead of boolean better to use a number for the allowed limit >> that should not grow more than this number that means the length of >> switches string that the user can tolerate on the modeline. >> >> Then modeline will display abbreviation truncated to the specified >> number of characters, with an ellipses, on the assumption that >> the most important switches are at the beginning of the string. > > That sounds better. Bonus points for arranging a tooltip that would > show the full string when the mouse is over that part of the mode > line. Currently, if I disable ls-switches, it displays just "(Dired)" on modeline, as I coded in my patch. When mouse is over it displays help-tooltip, ("Major mode", "Mouse1 - ..." etc). Is it maybe better to put ls-switches as a submenu to pop-up menu that appears when one click with mouse button1? Or how do you imagine the tooltip - to replace one with help or soemthing else? I don't know how to add a submenu to that pop-up or a tooltip, but I can look it up. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 8:40 ` Arthur Miller @ 2020-05-15 10:15 ` Eli Zaretskii 2020-05-15 10:50 ` Arthur Miller 0 siblings, 1 reply; 79+ messages in thread From: Eli Zaretskii @ 2020-05-15 10:15 UTC (permalink / raw) To: Arthur Miller; +Cc: 41250, juri > From: Arthur Miller <arthur.miller@live.com> > Cc: Juri Linkov <juri@linkov.net>, 41250@debbugs.gnu.org > Date: Fri, 15 May 2020 10:40:34 +0200 > > > That sounds better. Bonus points for arranging a tooltip that would > > show the full string when the mouse is over that part of the mode > > line. > > Currently, if I disable ls-switches, it displays just "(Dired)" on > modeline, as I coded in my patch. When mouse is over it displays > help-tooltip, ("Major mode", "Mouse1 - ..." etc). Is it maybe better to > put ls-switches as a submenu to pop-up menu that appears when one click > with mouse button1? Or how do you imagine the tooltip - to replace one > with help or soemthing else? Figuring this out is part of the job, I guess. One possibility would be to show the tooltip only when the imaginary defcustom is non-nil, i.e. when the user expressed his/her desire to see the switches, but there's no space to show them in their entirety. Maybe there are other possibilities, I didn't think long enough about this to tell. As for the mode tooltip, I think you could work around the problem by making the switches tooltip pop up only on the partial text of the switches, not on the mode string itself. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 10:15 ` Eli Zaretskii @ 2020-05-15 10:50 ` Arthur Miller 0 siblings, 0 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-15 10:50 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, juri Eli Zaretskii <eliz@gnu.org> writes: >> From: Arthur Miller <arthur.miller@live.com> >> Cc: Juri Linkov <juri@linkov.net>, 41250@debbugs.gnu.org >> Date: Fri, 15 May 2020 10:40:34 +0200 >> >> > That sounds better. Bonus points for arranging a tooltip that would >> > show the full string when the mouse is over that part of the mode >> > line. >> >> Currently, if I disable ls-switches, it displays just "(Dired)" on >> modeline, as I coded in my patch. When mouse is over it displays >> help-tooltip, ("Major mode", "Mouse1 - ..." etc). Is it maybe better to >> put ls-switches as a submenu to pop-up menu that appears when one click >> with mouse button1? Or how do you imagine the tooltip - to replace one >> with help or soemthing else? > > Figuring this out is part of the job, I guess. One possibility would > be to show the tooltip only when the imaginary defcustom is non-nil, > i.e. when the user expressed his/her desire to see the switches, but > there's no space to show them in their entirety. Maybe there are > other possibilities, I didn't think long enough about this to tell. > > As for the mode tooltip, I think you could work around the problem by > making the switches tooltip pop up only on the partial text of the > switches, not on the mode string itself. Ok. I'll think about it more and see what I can come up with. An impuls idea is to have the variable as a stae: nil, short, long, where nil will hide ls-switches completely, short will show them shortened and long will display ls-switches entirely, and tooltip could then be shown when mouse is over the short version. I will have to look up how to code this with tooltip, but I'll try to code it :-). ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 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-10-06 11:36 ` Mattias Engdegård 1 sibling, 0 replies; 79+ messages in thread From: Mattias Engdegård @ 2020-10-06 11:36 UTC (permalink / raw) To: Andreas Schwab, Eli Zaretskii, 41250, larsi, juri, arthur.miller, Glenn Morris To repair the build, I changed from \N{...} to hex escapes. Perhaps you want a different solution eventually. Putting (require 'mule-util) at the top level of ja-dic-cnv.el doesn't help -- \N{...} escapes don't seem to work at this stage of the build. ^ permalink raw reply [flat|nested] 79+ messages in thread
[parent not found: <<VI1PR06MB45265DF0191578C413A3B37C96BC0@VI1PR06MB4526.eurprd06.prod.outlook.com>]
[parent not found: <<87v9ky9p6o.fsf@mail.linkov.net>]
[parent not found: <<654acc31-015d-4552-bd9b-3b8c69661fcd@default>]
[parent not found: <<VI1PR06MB45265603DFF6BE71DBD819EB96BD0@VI1PR06MB4526.eurprd06.prod.outlook.com>]
[parent not found: <<0957af50-7f85-455a-9d2c-e96451727872@default>]
[parent not found: <<83a729uiaq.fsf@gnu.org>]
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline [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 0 siblings, 2 replies; 79+ messages in thread From: Drew Adams @ 2020-05-15 21:00 UTC (permalink / raw) To: Eli Zaretskii, Drew Adams; +Cc: 41250, arthur.miller, juri > > an integer - show first N chars of switches > > I don't think this is a useful value: the user will rarely know how > much space is available on the mode line. A user may know how much space they're willing to give to this, as a general preference/rule. Mode-line data can vary considerably, depending on one's setup, the buffer's mode, and other things. And the effective available space depends on window width. So of course no particular truncation constant length will fit all contexts. Such truncation is of limited utility, IMO, but I thought that's what was requested. Sure, truncation could instead be relative (%). In that case what it's relative to needs to be considered. This is why, in the general case, a function value is there. You'll recall that in an earlier mail I said that truncation can just be done by such a function. (Well, at that point I said a `format' string - that too can truncate.) What I wrote up is just a simple truncation. If you have a better one you want to suggest, fine. > Also, truncating without showing ellipsis or some > other sign of truncation is IMO a sub-optimal UI. Arguable - mode-line space is limited. But maybe. I imagine you're suggesting appending a char such as `.' to whatever truncation is used. That's fine by me (though I'm not crazy about that char, which I find generally illegible). An alternative (more readable, but wastes 2 more chars, is `...'. Another alternative is to surround the set of switches with delimiters, e.g. "" or '' or [] ... ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 21:00 ` Drew Adams @ 2020-05-15 21:14 ` Arthur Miller 2020-05-15 22:04 ` Drew Adams 1 sibling, 0 replies; 79+ messages in thread From: Arthur Miller @ 2020-05-15 21:14 UTC (permalink / raw) To: Drew Adams; +Cc: 41250, juri Drew Adams <drew.adams@oracle.com> writes: >> > an integer - show first N chars of switches >> >> I don't think this is a useful value: the user will rarely know how >> much space is available on the mode line. > > A user may know how much space they're willing > to give to this, as a general preference/rule. > > Mode-line data can vary considerably, depending > on one's setup, the buffer's mode, and other > things. And the effective available space > depends on window width. > > So of course no particular truncation constant > length will fit all contexts. Such truncation > is of limited utility, IMO, but I thought that's > what was requested. > > Sure, truncation could instead be relative (%). > In that case what it's relative to needs to be > considered. > > This is why, in the general case, a function > value is there. You'll recall that in an earlier > mail I said that truncation can just be done by > such a function. (Well, at that point I said a > `format' string - that too can truncate.) > > What I wrote up is just a simple truncation. If > you have a better one you want to suggest, fine. > >> Also, truncating without showing ellipsis or some >> other sign of truncation is IMO a sub-optimal UI. > > Arguable - mode-line space is limited. But maybe. > > I imagine you're suggesting appending a char such > as `.' to whatever truncation is used. That's > fine by me (though I'm not crazy about that char, > which I find generally illegible). An alternative > (more readable, but wastes 2 more chars, is `...'. > Another alternative is to surround the set of > switches with delimiters, e.g. "" or '' or [] ... As I understand Eli, he means, if switches are displayed only partially on modeline, then after the switch chars there would be an elipsis, which I understand means "...". I think it is OK since it indicates that there is more to it which indeed is quite common, but yes it does take more space on modeline. ^ permalink raw reply [flat|nested] 79+ messages in thread
* bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline 2020-05-15 21:00 ` Drew Adams 2020-05-15 21:14 ` Arthur Miller @ 2020-05-15 22:04 ` Drew Adams 1 sibling, 0 replies; 79+ messages in thread From: Drew Adams @ 2020-05-15 22:04 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 41250, arthur.miller, juri > I imagine you're suggesting appending a char such > as `.' to whatever truncation is used. ^ That was supposed to be a horizontal ellipsis char. ^ permalink raw reply [flat|nested] 79+ messages in thread
end of thread, other threads:[~2020-10-06 13:28 UTC | newest] Thread overview: 79+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).