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: Sun, 17 May 2020 05:01:53 +0200 Message-ID: References: <87v9ky9p6o.fsf@mail.linkov.net> <654acc31-015d-4552-bd9b-3b8c69661fcd@default> <0957af50-7f85-455a-9d2c-e96451727872@default> <83a729uiaq.fsf@gnu.org> <835zcwv15e.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="92683"; 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.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 17 05:03:33 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 1ja9aO-000NxM-4Q for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 05:03:32 +0200 Original-Received: from localhost ([::1]:35154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja9aM-00048b-MP for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 May 2020 23:03:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ja9aD-00047Q-3w for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:03:22 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ja9Zt-0005hr-Tu for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:03:20 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ja9Zt-0006CW-QR for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Arthur Miller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 May 2020 03:03:01 +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.158968452723776 (code B ref 41250); Sun, 17 May 2020 03:03:01 +0000 Original-Received: (at 41250) by debbugs.gnu.org; 17 May 2020 03:02:07 +0000 Original-Received: from localhost ([127.0.0.1]:42019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja9Z0-0006BP-Lz for submit@debbugs.gnu.org; Sat, 16 May 2020 23:02:07 -0400 Original-Received: from mail-oln040092074054.outbound.protection.outlook.com ([40.92.74.54]:19827 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja9Yv-0006As-Om for 41250@debbugs.gnu.org; Sat, 16 May 2020 23:02:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bEMYeFuk5QShdjTJ1vvoG+HXolAEI3zruPDBL445bO+yyT947Gk6UmqEE6bLAi7zbAgUQTb4Gpr6MXokU2AgGwYWxKXjxweDQ7QJLNe9b3HqubP45AB7DnQngLh3TcSLFtBSNh8jIeCkT+wjSMlvlyfgjlzl5UwGjChBXUHAxxyXx/UhDinlcL7vSvD1gilTd9ZRDuLuql0zt+wri7qoywnOVD/XQSO1PNxbUhrijvnUIU+ZeLzuFcaZTniEfRl7OlUO7aHnoQQm8rJLiKrJRECi6XaqOaykc9j47gfhVgWNLcdbSMe4MgU1OJAZJGzuZ6RbbIy4AzReJLjkMKvheA== 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=cg6Kqu45EXWuU81LxNccitXKsUXwNJ6o9Ff5yVfZ1rI=; b=QbpsWeKF8owDB6wn6c6In/Zqd0brBf7kyZYS/jQ9r+5Rx9RUBXbnjyhiiP9ctUlOus8WylfPEVavHvK4lwHlokHL5e9hmOf2P4GNTPPnNcEhKrHhFI1Fq5/buZkVNAoPaq0KDcB9M1SKb+4AWt9p0M13iaJwN7e0RH6qPa+rYA1KOc7rXZGFgJ66RBdlmkZSsQatBvTnUd8iWbUTLJPyAnD12YL4sbJzkp9umZ2BaKt+3NCzgET4o1Tf0O6X2ObFRi8BkCstAwf8eEzP3F1HvH4fAh8yOSgJZxueKkMaG0Tn/WIHDQMgCxut+IV/dSS95T3JG5KMInoN4sZI/Uw0jA== 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=cg6Kqu45EXWuU81LxNccitXKsUXwNJ6o9Ff5yVfZ1rI=; b=kNB1pmzJI/j6n1fxYw2vqfFdVt35tSE58NBrmNmXIs5ZjooMobwZTrA/zmdr0BbNvKcM1TnIsTsVCujjQAQ8gcrXM8wOgf2eEQ6DtQI5/KdF6S9BNfMjH0cfmJuF2M5lG62/7nNtcjM/E+iELzl1oCaRirx8phDF/Xq6Az0ZYZI+QKs83Z8mubX0yysalaaIeysAZvMgyLcIg+WM4Hc9Hz61DiJcFHe4j2UQXu9yBE3CCY+h2BCXT0maRKYkZDwREeEsn2FSfuRXumCBAhaIVBJ4dRlXJ1cQtM3I/g/pyuBqtv+0Vo88R7FbM2cCudczFzYzo7K9Fq03BIzeXI8+rg== Original-Received: from HE1EUR04FT038.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04HT009.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19; Sun, 17 May 2020 03:01:55 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:7e0d::43) by HE1EUR04FT038.mail.protection.outlook.com (2a01:111:e400:7e0d::189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Sun, 17 May 2020 03:01:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BE45E7D1A11BA29A21D725E58CC7E2D9F6CD67F0C80B776DEE9487AC931BBEE9; UpperCasedChecksum:B00238031957298F852D01BEBD7C50CA7148B4002A3E5C39330B273F7AB0223F; SizeAsReceived:7981; 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.3000.022; Sun, 17 May 2020 03:01:55 +0000 In-Reply-To: <835zcwv15e.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 16 May 2020 09:34:21 +0300") X-ClientProxiedBy: AM6P195CA0069.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::46) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <87a7271cym.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM6P195CA0069.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Sun, 17 May 2020 03:01:54 +0000 X-Microsoft-Original-Message-ID: <87a7271cym.fsf@live.com> X-TMN: [OyJmYYMuaL/qg3RZfB35zfaFX5v/HOEx] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 085dafbf-e832-4658-cd2e-08d7fa0ea7b7 X-MS-TrafficTypeDiagnostic: HE1EUR04HT009: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /Qd8//rEV3/+5DS6moS2cqdcRqkRNm2ZZkDL9oonBce7tBxF8bV4VPB2s+T8houPm5PQcpNs/HSoKkhPvMRk7VtEmJ8jp4lFqNOgFxpK92G4I0E0x8KUNTPLvd+iBJT5UD+2cBD5E2pp8Ulcwr8NrPSI5od/FfraNUc5RnDQOUqCtAans0tm4HAM3vFZvOUNceoZiOo+Wx7Ha8iPuakpmg== 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: pjDNUjhsT0ynGRqiPrVHHLP+/Dc9ab99cTc+q3KymJwZCc45MANE8hpc7hLyFWep3LNC0Pu8j+B85uEpP8Pnr6+G66IzL5HZSqYqXZQzEWVaUtXLIdI7jqP3zcTXBXl7ldZlUOkdHGLAy74JLFHPXA== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 085dafbf-e832-4658-cd2e-08d7fa0ea7b7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2020 03:01:55.3427 (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: HE1EUR04HT009 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:180428 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Arthur Miller >> Cc: Drew Adams , 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=dired.patch --- 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) - + ;;; 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)) - ;; The dired command (defun dired-read-dir-and-switches (str) @@ -1197,7 +1204,6 @@ (setq blist (cdr blist)))))) found))) - ;; 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)))) - + ;; 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.") - + ;; 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)) - + ;; 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)) - + (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)) - + ;;; 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))) - + ;; 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)))) - + ;; 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)) - + ;;; 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)))))))) - ;;;; 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))) - ;;;; Desktop support --=-=-=--