From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.bugs Subject: bug#41250: 28.0.50; Dired displays unconditionally ls-switches on modeline Date: Fri, 15 May 2020 21:54:50 +0200 Message-ID: References: <87v9ky9p6o.fsf@mail.linkov.net> <654acc31-015d-4552-bd9b-3b8c69661fcd@default> <0957af50-7f85-455a-9d2c-e96451727872@default> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125014"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 41250@debbugs.gnu.org, Juri Linkov To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 15 21:55:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZgQJ-000WPm-LV for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 May 2020 21:55:11 +0200 Original-Received: from localhost ([::1]:43304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZgQI-0000JG-Ed for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 May 2020 15:55:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZgQA-0000J8-Mt for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZgQA-0007XM-Eg for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jZgQA-0007vB-DY for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 15:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Arthur Miller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 May 2020 19:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41250 X-GNU-PR-Package: emacs Original-Received: via spool by 41250-submit@debbugs.gnu.org id=B41250.158957250130437 (code B ref 41250); Fri, 15 May 2020 19:55:02 +0000 Original-Received: (at 41250) by debbugs.gnu.org; 15 May 2020 19:55:01 +0000 Original-Received: from localhost ([127.0.0.1]:38836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZgQ8-0007ur-L9 for submit@debbugs.gnu.org; Fri, 15 May 2020 15:55:01 -0400 Original-Received: from mail-oln040092067089.outbound.protection.outlook.com ([40.92.67.89]:14090 helo=EUR02-AM5-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZgQ6-0007ud-O9 for 41250@debbugs.gnu.org; Fri, 15 May 2020 15:54:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3MKhwllWC1Oqh22rzk9xmCo7McD4U2qc/oeKu6flT73cHcrrUHKoS1WWaB/ARJaoXjSkaUfZx9EbkuIgOUEuxzLboCc/tq5gIGygnGjWplW68R8Es8W/bBLq3E2ctRg7+wCvPgTUXg1tAqlINuO5uuX5i+eZaIBG8CxcAxR7gooMidwPWLdFcRxQI8+dTIKQffomdZyfSzs/e+QSOsNSXQz4E1WJRlSgtjiAcsHPNmyLa+rQxjx4+EVxiBZaljzcVc5o6s99mzcMNnPfbL9g0mpEWbrOz9Mr51Q7TazP8Et8Qjn9IGXE+AKUcczje0liyL8YvcGHis0cf67ut/Cnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JXrMikE5mooOHmWjRO0rDB7NogxdwdeC6McbkhaTEE4=; b=DukVarVulgRWCX6zwIWv74BMwMjTMmtYqbks86ZIRId+r+j0ADoXGAbvS3JydOfSn/SzMdkSOCEMlnBjJTmyrQUAPv0lIqggbklXqtOwN/zNT1EirvLp1SwjiKwYjfH3mrKy6/XYuWyirgLdWXZMjpMzze8ZRCDPPFSjpMK2u4wNQ78SH5gzT/uRJngWynaNxdr5/hA8vYuJ3dvNUKI5lRvCtNO3tDdYAv9cVEHWjn1s8dXqKZlKm4yh28Um0eHVTURi/l8O/HKyDoZEnhecpXpuZ/t/IHAZ1zzdlj6IMX19SBshfGLbFXx6YBw3Pxfy+Cotyj3XAtS142+64NyuYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.com; dmarc=pass action=none header.from=live.com; dkim=pass header.d=live.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JXrMikE5mooOHmWjRO0rDB7NogxdwdeC6McbkhaTEE4=; b=POjwwYniCq70Ir/dykkt8pvFN7mZPV25ilW7+XcV1+DKT0F6cS+k8++9U5TqddelVuRl3VpdSSYFKLBxC9ObLOsB1js8xJZfQTkb8LpU/rezZmLRtW/3gJHP+H2QDdjvSVhOv0r14c1hI+A5UDcZW/0FzTBm+zbQd1mFyEEloV9tkJXO4kH9rS3aDkqzVZOeuN+JplFQPJv3ehQrm+hsEupeCKW0scNnLmuRABaidBXZsP1TNPn0BmMGEDM75oy9uwpQBStVDFEMXS43wcmFFjP91FDenr1GG9w/YGe6qUzzDaEj218Y4ybo6oJp+c5E/OgKiknDxPTcq6ZclRv3mg== Original-Received: from VE1EUR02FT019.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::42) by VE1EUR02HT162.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::323) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19; Fri, 15 May 2020 19:54:51 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:7e1e::4f) by VE1EUR02FT019.mail.protection.outlook.com (2a01:111:e400:7e1e::107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Fri, 15 May 2020 19:54:51 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2B2E72AA05F4CCBD0E4AFE9466AC51601738CBEDCC3423D5B129AE061E840E24; UpperCasedChecksum:FC3AA8C4864610F6B1D3CDA55073119CA61617333C5954AAB02222311A172543; SizeAsReceived:7869; Count:48 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::49f0:2314:a959:bec5]) by VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::49f0:2314:a959:bec5%7]) with mapi id 15.20.2979.033; Fri, 15 May 2020 19:54:51 +0000 In-Reply-To: <0957af50-7f85-455a-9d2c-e96451727872@default> (Drew Adams's message of "Fri, 15 May 2020 11:55:46 -0700 (PDT)") X-ClientProxiedBy: AM5PR0402CA0010.eurprd04.prod.outlook.com (2603:10a6:203:90::20) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <87k11das8l.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM5PR0402CA0010.eurprd04.prod.outlook.com (2603:10a6:203:90::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25 via Frontend Transport; Fri, 15 May 2020 19:54:50 +0000 X-Microsoft-Original-Message-ID: <87k11das8l.fsf@live.com> X-TMN: [jjyHpmvE1Supc/KwG+UDoCV5i43KA6aU] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e0c80afd-ad47-45c1-c6d9-08d7f909d471 X-MS-TrafficTypeDiagnostic: VE1EUR02HT162: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wwmT4oZXZvmnXVKD7lBuPEw2k1+o9X6Zru/ie2rmLF+Lxi/b4u1ZNSiuRZGk0IpjY3QEqS8blvNBbWnWRUSSsG8ax5Yl8HnSLGDVLWLlrNUJgtC9X/7dRFoVPvtVsXFrAvuk3OufPBT9aMAjYTPrHsu9TUpUsm2QE3gbum85Qsys3HUVO7EZNvtokOF7AruJZxW/AmRqzmeD/Xes01R5oA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR06MB4526.eurprd06.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: ZBMhs4oldoiO4JdnD1i+kk7zpyUdB/RVgf6HHr/wKR0TLIswWrt4h3kjiq1cm7yOAU1zy/JgGX3eJXXq3L/kleU/R/vqcexP0ljSZ2MDEFHVoyk4zW6jPho68Mxkzukb5TCvUJzMixMvRa+p4FKk7A== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0c80afd-ad47-45c1-c6d9-08d7f909d471 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2020 19:54:51.5929 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT162 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180360 Archived-At: Drew Adams 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