GNU bug report logs - #17218
24.3; Dired does not insert subdirs when used with switch "--group-directories-first"

Previous Next

Package: emacs;

Reported by: Tu Do <tuhdo1710 <at> gmail.com>

Date: Mon, 7 Apr 2014 15:49:03 UTC

Severity: normal

Found in version 24.3

Fixed in versions 24.4, 25.1

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17218 in the body.
You can then email your comments to 17218 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Mon, 07 Apr 2014 15:49:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tu Do <tuhdo1710 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 07 Apr 2014 15:49:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tu Do <tuhdo1710 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Mon, 7 Apr 2014 21:12:59 +0700
[Message part 1 (text/plain, inline)]
If I remove the switch "--group-directories-first", then Bookmark Jump
works as expected. However, as long as the switch is put in,
sub-directories won't be inserted again.

I found out the problem in the function "dired-insert-old-subdirs" at line
1367 in dired.el. In this function, it has an or:

(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 "R" dired-actual-switches)
(let (elt dir)
(while old-subdir-alist
(setq elt (car old-subdir-alist)
old-subdir-alist (cdr old-subdir-alist)
dir (car elt))
(condition-case ()
(progn
(dired-uncache dir)
(dired-insert-subdir dir))
(error nil))))))


The functional call to string-match:

(string-match "R" dired-actual-switches)

is the root cause. If dired-actual-switches is "-lha", then string-match
returns nil, and the code for inserting subdirs is going to be executed.
However, with dired-actual-switches is "--group-directories-first -lha",
then string-match returns 3, making the or call returns true immediately
and subdirs are never inserted.

"ls -R" recursively list directories. But matching it this way is
incorrect, since we have listing switches that contain character "R" in
it (i.e. --group-directories-first).

Hope that help.

Regards,

Tu.


In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.6.4)
of 2014-04-01 on oldfriend
Windowing system distributor `The X.Org Foundation', version 11.0.11303000
System Description: Ubuntu 13.04

Configured using:
`configure '--with-x-toolkit=gtk''

Important settings:
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t

Major mode: Bookmark Menu

Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t

Recent input:
C-v M-v M-v C-x k <return> e C-c C-c C-x o C-n C-n
C-n C-p k x C-x 1 C-x C-g C-h v d i r e d - l i s <tab>
<return> C-s c u s C-g C-x o C-s c u s C-f <return>
C-n C-n C-n C-n C-n C-n C-n C-n C-e SPC - - g r o u
p - d i r e c t o r i e s - f i r s t C-n C-a C-f C-f
C-f C-f <return> 0 q q C-x o C-x d . e m <tab> . d
<tab> <return> C-n C-n C-p i k C-n C-n C-n C-v M-v
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n M-v
M-v M-v M-v C-v C-v C-v C-v C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n C-n
C-n C-n C-n C-n C-n C-x 1 C-x r l C-x b <return> C-x
r m <return> C-x C-g C-x b <return> <return> C-v C-v
C-x k <return> <return> C-v C-v C-v M-v M-v M-v C-x
k <return> M-x e m <tab> a <tab> b u <tab> <backspace>
<backspace> r <tab> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> b u
g <tab> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
r e <tab> <tab> <backspace> <backspace> e m a <tab>
<tab> <tab> <backspace> <backspace> <backspace> <backspace>
<backspace> M-x M-x r e p o <tab> t <tab> <backspace>
r <tab> e <backspace> <return>

Recent messages:
Resetting customization items...done
Creating customization setup...done
Mark set
Killed 0 lines.
scroll-up-command: End of buffer [2 times]
scroll-down-command: Beginning of buffer [2 times]
Making completion list... [3 times]
completing-read-default: Command attempted to use minibuffer while in
minibuffer
Quit
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils cus-edit cus-start cus-load wid-edit misearch
multi-isearch bookmark pp dired-aux help-mode easymenu help-fns dired
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Mon, 07 Apr 2014 16:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Tu Do <tuhdo1710 <at> gmail.com>, 17218 <at> debbugs.gnu.org
Subject: RE: bug#17218: 24.3; Dired does not insert subdirs when used with
 switch "--group-directories-first"
Date: Mon, 7 Apr 2014 09:00:56 -0700 (PDT)
> 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.)]




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Tue, 08 Apr 2014 08:47:01 GMT) Full text and rfc822 format available.

Message #11 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Tu Do <tuhdo1710 <at> gmail.com>, 17218 <at> debbugs.gnu.org
Subject: Re: bug#17218: 24.3;
 Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Tue, 08 Apr 2014 11:45:55 +0300
>> 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.)]

Dired could use something like `ange-ftp-switches-ok' that implements
a better check for the -R switch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Sun, 27 Apr 2014 08:33:02 GMT) Full text and rfc822 format available.

Message #14 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Tu Do <tuhdo1710 <at> gmail.com>, 17218 <at> debbugs.gnu.org
Subject: Re: 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
[Message part 1 (text/plain, inline)]
>> 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:

[Message part 2 (text/x-patch, 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


Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Sat, 03 May 2014 09:29:03 GMT) Full text and rfc822 format available.

Notification sent to Tu Do <tuhdo1710 <at> gmail.com>:
bug acknowledged by developer. (Sat, 03 May 2014 09:29:03 GMT) Full text and rfc822 format available.

Message #19 received at 17218-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Tu Do <tuhdo1710 <at> gmail.com>, 17218-done <at> debbugs.gnu.org
Subject: Re: bug#17218: 24.3;
 Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Sat, 03 May 2014 12:23:54 +0300
Version: 24.5

>>> 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:

Installed to trunk since this is not a regression.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Wed, 07 May 2014 19:51:01 GMT) Full text and rfc822 format available.

Message #22 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: juri <at> jurta.org
Cc: 17218 <at> debbugs.gnu.org
Subject: Re: bug#17218: 24.3;
 Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Wed, 07 May 2014 15:50:09 -0400
Juri Linkov wrote:

> Installed to trunk since this is not a regression.

Note that emacs-24 is not yet in "regression fix only" mode
(and likely won't be for some time AFAICS).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Wed, 07 May 2014 20:25:02 GMT) Full text and rfc822 format available.

Message #25 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 17218 <at> debbugs.gnu.org
Subject: Re: bug#17218: 24.3;
 Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Wed, 07 May 2014 23:14:27 +0300
>> Installed to trunk since this is not a regression.
>
> Note that emacs-24 is not yet in "regression fix only" mode
> (and likely won't be for some time AFAICS).

Thanks for the clarification.  Then perhaps this change could be
backported to emacs-24.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17218; Package emacs. (Thu, 08 May 2014 18:16:02 GMT) Full text and rfc822 format available.

Message #28 received at 17218 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 17218 <at> debbugs.gnu.org
Subject: Re: bug#17218: 24.3;
 Dired does not insert subdirs when used with switch
 "--group-directories-first"
Date: Thu, 08 May 2014 14:15:29 -0400
Juri Linkov wrote:

> Then perhaps this change could be backported to emacs-24.

I think it should be, yes.





bug Marked as fixed in versions 24.4. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 08 May 2014 20:24:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 06 Jun 2014 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:03 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 25.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:03 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 24.5. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Nov 2014 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 190 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.