diff options
| author | Juri Linkov | 2014-05-08 22:22:43 +0300 |
|---|---|---|
| committer | Juri Linkov | 2014-05-08 22:22:43 +0300 |
| commit | c055a50b4a1a0785e4008f80e8724ee16d5cf3cf (patch) | |
| tree | 1e57a0a50862fa72604856867937313b38f65ebe | |
| parent | a9fd3545bb4fba4def6d1a97d3647bf59870dce7 (diff) | |
| download | emacs-c055a50b4a1a0785e4008f80e8724ee16d5cf3cf.tar.gz emacs-c055a50b4a1a0785e4008f80e8724ee16d5cf3cf.zip | |
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'.
Fixes: debbugs:17218
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/dired.el | 31 |
2 files changed, 30 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 323363bc977..8f3a245e2ad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-05-08 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * dired.el (dired-check-switches, dired-switches-recursive-p): | ||
| 4 | New functions. (Bug#17218) | ||
| 5 | (dired-switches-escape-p, dired-move-to-end-of-filename): | ||
| 6 | Use `dired-check-switches'. | ||
| 7 | (dired-insert-old-subdirs, dired-build-subdir-alist) | ||
| 8 | (dired-sort-R-check): Use `dired-switches-recursive-p'. | ||
| 9 | |||
| 1 | 2014-05-08 Glenn Morris <rgm@gnu.org> | 10 | 2014-05-08 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * net/browse-url.el (browse-url-mosaic): | 12 | * net/browse-url.el (browse-url-mosaic): |
diff --git a/lisp/dired.el b/lisp/dired.el index 3b986e99f60..07fe6fe7d14 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -1142,10 +1142,22 @@ BEG..END is the line where the file info is located." | |||
| 1142 | 1142 | ||
| 1143 | (defvar ls-lisp-use-insert-directory-program) | 1143 | (defvar ls-lisp-use-insert-directory-program) |
| 1144 | 1144 | ||
| 1145 | (defun dired-check-switches (switches short &optional long) | ||
| 1146 | "Return non-nil if the string SWITCHES matches LONG or SHORT format." | ||
| 1147 | (let (case-fold-search) | ||
| 1148 | (and (stringp switches) | ||
| 1149 | (string-match-p (concat "\\(\\`\\| \\)-[[:alnum:]]*" short | ||
| 1150 | (if long (concat "\\|--" long "\\>") "")) | ||
| 1151 | switches)))) | ||
| 1152 | |||
| 1145 | (defun dired-switches-escape-p (switches) | 1153 | (defun dired-switches-escape-p (switches) |
| 1146 | "Return non-nil if the string SWITCHES contains -b or --escape." | 1154 | "Return non-nil if the string SWITCHES contains -b or --escape." |
| 1147 | ;; Do not match things like "--block-size" that happen to contain "b". | 1155 | ;; Do not match things like "--block-size" that happen to contain "b". |
| 1148 | (string-match-p "\\(\\`\\| \\)-[[:alnum:]]*b\\|--escape\\>" switches)) | 1156 | (dired-check-switches switches "b" "escape")) |
| 1157 | |||
| 1158 | (defun dired-switches-recursive-p (switches) | ||
| 1159 | "Return non-nil if the string SWITCHES contains -R or --recursive." | ||
| 1160 | (dired-check-switches switches "R" "recursive")) | ||
| 1149 | 1161 | ||
| 1150 | (defun dired-insert-directory (dir switches &optional file-list wildcard hdr) | 1162 | (defun dired-insert-directory (dir switches &optional file-list wildcard hdr) |
| 1151 | "Insert a directory listing of DIR, Dired style. | 1163 | "Insert a directory listing of DIR, Dired style. |
| @@ -1402,7 +1414,7 @@ Each element of ALIST looks like (FILE . MARKERCHAR)." | |||
| 1402 | (defun dired-insert-old-subdirs (old-subdir-alist) | 1414 | (defun dired-insert-old-subdirs (old-subdir-alist) |
| 1403 | "Try to insert all subdirs that were displayed before. | 1415 | "Try to insert all subdirs that were displayed before. |
| 1404 | Do so according to the former subdir alist OLD-SUBDIR-ALIST." | 1416 | Do so according to the former subdir alist OLD-SUBDIR-ALIST." |
| 1405 | (or (string-match-p "R" dired-actual-switches) | 1417 | (or (dired-switches-recursive-p dired-actual-switches) |
| 1406 | (let (elt dir) | 1418 | (let (elt dir) |
| 1407 | (while old-subdir-alist | 1419 | (while old-subdir-alist |
| 1408 | (setq elt (car old-subdir-alist) | 1420 | (setq elt (car old-subdir-alist) |
| @@ -2349,9 +2361,8 @@ Return the position of the beginning of the filename, or nil if none found." | |||
| 2349 | ;; This is the UNIX version. | 2361 | ;; This is the UNIX version. |
| 2350 | (if (get-text-property (point) 'dired-filename) | 2362 | (if (get-text-property (point) 'dired-filename) |
| 2351 | (goto-char (next-single-property-change (point) 'dired-filename)) | 2363 | (goto-char (next-single-property-change (point) 'dired-filename)) |
| 2352 | (let (opoint file-type executable symlink hidden case-fold-search used-F eol) | 2364 | (let (opoint file-type executable symlink hidden used-F eol) |
| 2353 | ;; case-fold-search is nil now, so we can test for capital F: | 2365 | (setq used-F (dired-check-switches dired-actual-switches "F" "classify") |
| 2354 | (setq used-F (string-match-p "F" dired-actual-switches) | ||
| 2355 | opoint (point) | 2366 | opoint (point) |
| 2356 | eol (line-end-position) | 2367 | eol (line-end-position) |
| 2357 | hidden (and selective-display | 2368 | hidden (and selective-display |
| @@ -2613,7 +2624,7 @@ instead of `dired-actual-switches'." | |||
| 2613 | (R-ftp-base-dir-regex | 2624 | (R-ftp-base-dir-regex |
| 2614 | ;; Used to expand subdirectory names correctly in recursive | 2625 | ;; Used to expand subdirectory names correctly in recursive |
| 2615 | ;; ange-ftp listings. | 2626 | ;; ange-ftp listings. |
| 2616 | (and (string-match-p "R" switches) | 2627 | (and (dired-switches-recursive-p switches) |
| 2617 | (string-match "\\`/.*:\\(/.*\\)" default-directory) | 2628 | (string-match "\\`/.*:\\(/.*\\)" default-directory) |
| 2618 | (concat "\\`" (match-string 1 default-directory))))) | 2629 | (concat "\\`" (match-string 1 default-directory))))) |
| 2619 | (goto-char (point-min)) | 2630 | (goto-char (point-min)) |
| @@ -3688,12 +3699,12 @@ Saves `dired-subdir-alist' when R is set and restores saved value | |||
| 3688 | minus any directories explicitly deleted when R is cleared. | 3699 | minus any directories explicitly deleted when R is cleared. |
| 3689 | To be called first in body of `dired-sort-other', etc." | 3700 | To be called first in body of `dired-sort-other', etc." |
| 3690 | (cond | 3701 | (cond |
| 3691 | ((and (string-match-p "R" switches) | 3702 | ((and (dired-switches-recursive-p switches) |
| 3692 | (not (string-match-p "R" dired-actual-switches))) | 3703 | (not (dired-switches-recursive-p dired-actual-switches))) |
| 3693 | ;; Adding -R to ls switches -- save `dired-subdir-alist': | 3704 | ;; Adding -R to ls switches -- save `dired-subdir-alist': |
| 3694 | (setq dired-subdir-alist-pre-R dired-subdir-alist)) | 3705 | (setq dired-subdir-alist-pre-R dired-subdir-alist)) |
| 3695 | ((and (string-match-p "R" dired-actual-switches) | 3706 | ((and (dired-switches-recursive-p dired-actual-switches) |
| 3696 | (not (string-match-p "R" switches))) | 3707 | (not (dired-switches-recursive-p switches))) |
| 3697 | ;; Deleting -R from ls switches -- revert to pre-R subdirs | 3708 | ;; Deleting -R from ls switches -- revert to pre-R subdirs |
| 3698 | ;; that are still present: | 3709 | ;; that are still present: |
| 3699 | (setq dired-subdir-alist | 3710 | (setq dired-subdir-alist |