From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#17218: 24.3; Dired does not insert subdirs when used with switch "--group-directories-first" Date: Sun, 27 Apr 2014 11:30:58 +0300 Organization: JURTA Message-ID: <871twjjhrx.fsf@mail.jurta.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1398587609 4552 80.91.229.3 (27 Apr 2014 08:33:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2014 08:33:29 +0000 (UTC) Cc: Tu Do , 17218@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 27 10:33:22 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WeKWX-00037R-EF for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Apr 2014 10:33:21 +0200 Original-Received: from localhost ([::1]:38427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeKWX-0000su-31 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Apr 2014 04:33:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeKWM-0000r5-Ls for bug-gnu-emacs@gnu.org; Sun, 27 Apr 2014 04:33:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WeKWF-0000Q0-0e for bug-gnu-emacs@gnu.org; Sun, 27 Apr 2014 04:33:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeKWE-0000Ps-TC for bug-gnu-emacs@gnu.org; Sun, 27 Apr 2014 04:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WeKWE-0006Lb-2N for bug-gnu-emacs@gnu.org; Sun, 27 Apr 2014 04:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Apr 2014 08:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17218 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17218-submit@debbugs.gnu.org id=B17218.139858757324384 (code B ref 17218); Sun, 27 Apr 2014 08:33:02 +0000 Original-Received: (at 17218) by debbugs.gnu.org; 27 Apr 2014 08:32:53 +0000 Original-Received: from localhost ([127.0.0.1]:59523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WeKW5-0006LD-1O for submit@debbugs.gnu.org; Sun, 27 Apr 2014 04:32:53 -0400 Original-Received: from alc-vshost7.dreamhost.com ([69.163.216.107]:36435 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WeKW3-0006L6-GA for 17218@debbugs.gnu.org; Sun, 27 Apr 2014 04:32:52 -0400 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 9C245315ED45D7; Sun, 27 Apr 2014 01:32:49 -0700 (PDT) In-Reply-To: (Drew Adams's message of "Mon, 7 Apr 2014 09:00:56 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:88325 Archived-At: --=-=-= Content-Type: text/plain >> I found out the problem in the function "dired-insert-old-subdirs" >> at line 1367 in dired.el. > > There is a similar problem in `dired-sort-R-check' and > `dired-build-subdir-alist'. > > [There probably should be a function that checks for a given switch, > and does not just use `string-match-p' in such a simple way. > (At least it should respect case etc.)] Below is the implementation of such a function: --=-=-= Content-Type: text/x-patch Content-Disposition: inline === modified file 'lisp/dired.el' --- lisp/dired.el 2014-04-22 18:17:17 +0000 +++ lisp/dired.el 2014-04-27 08:28:10 +0000 @@ -1142,10 +1142,20 @@ (defun dired-align-file (beg end) (defvar ls-lisp-use-insert-directory-program) +(defun dired-switches-check (switches long short) + "Return non-nil if the string SWITCHES matches LONG or SHORT format." + (let (case-fold-search) + (string-match-p (concat "\\(\\`\\| \\)-[[:alnum:]]*" short + "\\|--" long "\\>") switches))) + (defun dired-switches-escape-p (switches) "Return non-nil if the string SWITCHES contains -b or --escape." ;; Do not match things like "--block-size" that happen to contain "b". - (string-match-p "\\(\\`\\| \\)-[[:alnum:]]*b\\|--escape\\>" switches)) + (dired-switches-check switches "escape" "b")) + +(defun dired-switches-recursive-p (switches) + "Return non-nil if the string SWITCHES contains -R or --recursive." + (dired-switches-check switches "recursive" "R")) (defun dired-insert-directory (dir switches &optional file-list wildcard hdr) "Insert a directory listing of DIR, Dired style. @@ -1402,7 +1412,7 @@ (defun dired-remember-hidden () (defun dired-insert-old-subdirs (old-subdir-alist) "Try to insert all subdirs that were displayed before. Do so according to the former subdir alist OLD-SUBDIR-ALIST." - (or (string-match-p "R" dired-actual-switches) + (or (dired-switches-recursive-p dired-actual-switches) (let (elt dir) (while old-subdir-alist (setq elt (car old-subdir-alist) @@ -2613,7 +2623,7 @@ (defun dired-build-subdir-alist (&option (R-ftp-base-dir-regex ;; Used to expand subdirectory names correctly in recursive ;; ange-ftp listings. - (and (string-match-p "R" switches) + (and (dired-switches-recursive-p switches) (string-match "\\`/.*:\\(/.*\\)" default-directory) (concat "\\`" (match-string 1 default-directory))))) (goto-char (point-min)) @@ -3688,12 +3698,12 @@ (defun dired-sort-R-check (switches) minus any directories explicitly deleted when R is cleared. To be called first in body of `dired-sort-other', etc." (cond - ((and (string-match-p "R" switches) - (not (string-match-p "R" dired-actual-switches))) + ((and (dired-switches-recursive-p switches) + (not (dired-switches-recursive-p dired-actual-switches))) ;; Adding -R to ls switches -- save `dired-subdir-alist': (setq dired-subdir-alist-pre-R dired-subdir-alist)) - ((and (string-match-p "R" dired-actual-switches) - (not (string-match-p "R" switches))) + ((and (dired-switches-recursive-p dired-actual-switches) + (not (dired-switches-recursive-p switches))) ;; Deleting -R from ls switches -- revert to pre-R subdirs ;; that are still present: (setq dired-subdir-alist --=-=-=--