diff options
| author | Joakim Verona | 2012-01-23 15:10:06 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-01-23 15:10:06 +0100 |
| commit | 0322b140eead7c94de7f0f6d19a90bd15690b4eb (patch) | |
| tree | 950c011783cc896d0450084cb5155e54548bfe5b /lisp/dired.el | |
| parent | d5114bfea3ea4c37c57e2af0f3b095be9fcd8bac (diff) | |
| parent | cb5850f27c1b4d26957d58e2da2314dd12498671 (diff) | |
| download | emacs-0322b140eead7c94de7f0f6d19a90bd15690b4eb.tar.gz emacs-0322b140eead7c94de7f0f6d19a90bd15690b4eb.zip | |
upstream
Diffstat (limited to 'lisp/dired.el')
| -rw-r--r-- | lisp/dired.el | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index f1a778ad05a..57f67ca7c8c 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -1172,7 +1172,22 @@ see `dired-use-ls-dired' for more details.") | |||
| 1172 | "\\015" | 1172 | "\\015" |
| 1173 | (text-properties-at (match-beginning 0))) | 1173 | (text-properties-at (match-beginning 0))) |
| 1174 | nil t)) | 1174 | nil t)) |
| 1175 | (set-marker end nil))) | 1175 | (set-marker end nil)) |
| 1176 | ;; Replace any newlines in DIR with literal "\n"s, for the sake | ||
| 1177 | ;; of the header line. To disambiguate a literal "\n" in the | ||
| 1178 | ;; actual dirname, we also replace "\" with "\\". | ||
| 1179 | ;; Personally, I think this should always be done, irrespective | ||
| 1180 | ;; of the value of dired-actual-switches, because: | ||
| 1181 | ;; i) Dired simply does not work with an unescaped newline in | ||
| 1182 | ;; the directory name used in the header (bug=10469#28), and | ||
| 1183 | ;; ii) "\" is always replaced with "\\" in the listing, so doing | ||
| 1184 | ;; it in the header as well makes things consistent. | ||
| 1185 | ;; But at present it is only done if "-b" is in ls-switches, | ||
| 1186 | ;; because newlines in dirnames are uncommon, and people may | ||
| 1187 | ;; have gotten used to seeing unescaped "\" in the headers. | ||
| 1188 | ;; Note: adjust dired-build-subdir-alist if you change this. | ||
| 1189 | (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t) | ||
| 1190 | dir (replace-regexp-in-string "\n" "\\n" dir nil t))) | ||
| 1176 | (dired-insert-set-properties opoint (point)) | 1191 | (dired-insert-set-properties opoint (point)) |
| 1177 | ;; If we used --dired and it worked, the lines are already indented. | 1192 | ;; If we used --dired and it worked, the lines are already indented. |
| 1178 | ;; Otherwise, indent them. | 1193 | ;; Otherwise, indent them. |
| @@ -2541,12 +2556,31 @@ instead of `dired-actual-switches'." | |||
| 2541 | (delete-region (point) (match-end 1)) | 2556 | (delete-region (point) (match-end 1)) |
| 2542 | (insert new-dir-name)) | 2557 | (insert new-dir-name)) |
| 2543 | (setq count (1+ count)) | 2558 | (setq count (1+ count)) |
| 2559 | ;; Undo any escaping of newlines and \ by dired-insert-directory. | ||
| 2560 | ;; Convert "n" preceded by odd number of \ to newline, and \\ to \. | ||
| 2561 | (when (and (dired-switches-escape-p switches) | ||
| 2562 | (string-match-p "\\\\" new-dir-name)) | ||
| 2563 | (let (temp res) | ||
| 2564 | (mapc (lambda (char) | ||
| 2565 | (cond ((equal char ?\\) | ||
| 2566 | (if temp | ||
| 2567 | (setq res (concat res "\\") | ||
| 2568 | temp nil) | ||
| 2569 | (setq temp "\\"))) | ||
| 2570 | ((and temp (equal char ?n)) | ||
| 2571 | (setq res (concat res "\n") | ||
| 2572 | temp nil)) | ||
| 2573 | (t | ||
| 2574 | (setq res (concat res temp (char-to-string char)) | ||
| 2575 | temp nil)))) | ||
| 2576 | new-dir-name) | ||
| 2577 | (setq new-dir-name res))) | ||
| 2544 | (dired-alist-add-1 new-dir-name | 2578 | (dired-alist-add-1 new-dir-name |
| 2545 | ;; Place a sub directory boundary between lines. | 2579 | ;; Place a sub directory boundary between lines. |
| 2546 | (save-excursion | 2580 | (save-excursion |
| 2547 | (goto-char (match-beginning 0)) | 2581 | (goto-char (match-beginning 0)) |
| 2548 | (beginning-of-line) | 2582 | (beginning-of-line) |
| 2549 | (point-marker))))) | 2583 | (point-marker))))) |
| 2550 | (if (and (> count 1) (called-interactively-p 'interactive)) | 2584 | (if (and (> count 1) (called-interactively-p 'interactive)) |
| 2551 | (message "Buffer includes %d directories" count))) | 2585 | (message "Buffer includes %d directories" count))) |
| 2552 | ;; We don't need to sort it because it is in buffer order per | 2586 | ;; We don't need to sort it because it is in buffer order per |