emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117089: Backport dired-check-switches from trunk


From: Juri Linkov
Subject: [Emacs-diffs] emacs-24 r117089: Backport dired-check-switches from trunk.
Date: Thu, 08 May 2014 19:22:49 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117089
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17218
committer: Juri Linkov <address@hidden>
branch nick: emacs-24
timestamp: Thu 2014-05-08 22:22:43 +0300
message:
  Backport dired-check-switches from trunk.
  * lisp/dired.el (dired-check-switches, dired-switches-recursive-p): New 
functions. 
  (dired-switches-escape-p, dired-move-to-end-of-filename):
  Use `dired-check-switches'.
  (dired-insert-old-subdirs, dired-build-subdir-alist)
  (dired-sort-R-check): Use `dired-switches-recursive-p'.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/dired.el                  dired.el-20091113204419-o5vbwnq5f7feedwu-482
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-05-08 18:12:34 +0000
+++ b/lisp/ChangeLog    2014-05-08 19:22:43 +0000
@@ -1,3 +1,12 @@
+2014-05-08  Juri Linkov  <address@hidden>
+
+       * dired.el (dired-check-switches, dired-switches-recursive-p):
+       New functions.  (Bug#17218)
+       (dired-switches-escape-p, dired-move-to-end-of-filename):
+       Use `dired-check-switches'.
+       (dired-insert-old-subdirs, dired-build-subdir-alist)
+       (dired-sort-R-check): Use `dired-switches-recursive-p'.
+
 2014-05-08  Glenn Morris  <address@hidden>
 
        * net/browse-url.el (browse-url-mosaic):

=== modified file 'lisp/dired.el'
--- a/lisp/dired.el     2014-04-30 16:59:03 +0000
+++ b/lisp/dired.el     2014-05-08 19:22:43 +0000
@@ -1142,10 +1142,22 @@
 
 (defvar ls-lisp-use-insert-directory-program)
 
+(defun dired-check-switches (switches short &optional long)
+  "Return non-nil if the string SWITCHES matches LONG or SHORT format."
+  (let (case-fold-search)
+    (and (stringp switches)
+        (string-match-p (concat "\\(\\`\\| \\)-[[:alnum:]]*" short
+                                (if long (concat "\\|--" 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-check-switches switches "b" "escape"))
+
+(defun dired-switches-recursive-p (switches)
+  "Return non-nil if the string SWITCHES contains -R or --recursive."
+  (dired-check-switches switches "R" "recursive"))
 
 (defun dired-insert-directory (dir switches &optional file-list wildcard hdr)
   "Insert a directory listing of DIR, Dired style.
@@ -1402,7 +1414,7 @@
 (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)
@@ -2349,9 +2361,8 @@
   ;; This is the UNIX version.
   (if (get-text-property (point) 'dired-filename)
       (goto-char (next-single-property-change (point) 'dired-filename))
-    (let (opoint file-type executable symlink hidden case-fold-search used-F 
eol)
-      ;; case-fold-search is nil now, so we can test for capital F:
-      (setq used-F (string-match-p "F" dired-actual-switches)
+    (let (opoint file-type executable symlink hidden used-F eol)
+      (setq used-F (dired-check-switches dired-actual-switches "F" "classify")
            opoint (point)
            eol (line-end-position)
            hidden (and selective-display
@@ -2613,7 +2624,7 @@
           (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 +3699,12 @@
 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 via email to

[Prev in Thread] Current Thread [Next in Thread]