mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 12:20:17 -08:00
* lisp/wdired.el (wdired-normalize-filename): Sync with
dired-get-filename. (Bug#48659)
This commit is contained in:
parent
246a41759c
commit
1855e3d0c4
1 changed files with 26 additions and 7 deletions
|
|
@ -351,13 +351,32 @@ or \\[wdired-abort-changes] to abort changes")))
|
||||||
;; This code is a copy of some dired-get-filename lines.
|
;; This code is a copy of some dired-get-filename lines.
|
||||||
(defsubst wdired-normalize-filename (file unquotep)
|
(defsubst wdired-normalize-filename (file unquotep)
|
||||||
(when unquotep
|
(when unquotep
|
||||||
(setq file
|
;; Unquote names quoted by ls or by dired-insert-directory.
|
||||||
;; FIXME: shouldn't we check for a `b' argument or somesuch before
|
;; This code was written using `read' to unquote, because
|
||||||
;; doing such unquoting? --Stef
|
;; it's faster than substituting \007 (4 chars) -> ^G (1
|
||||||
(read (concat
|
;; char) etc. in a lisp loop. Unfortunately, this decision
|
||||||
"\"" (replace-regexp-in-string
|
;; has necessitated hacks such as dealing with filenames
|
||||||
"\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file)
|
;; with quotation marks in their names.
|
||||||
"\""))))
|
(while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file)
|
||||||
|
(setq file (replace-match "\\\"" nil t file 1)))
|
||||||
|
;; Unescape any spaces escaped by ls -b (bug#10469).
|
||||||
|
;; Other -b quotes, eg \t, \n, work transparently.
|
||||||
|
(if (dired-switches-escape-p dired-actual-switches)
|
||||||
|
(let ((start 0)
|
||||||
|
(rep "")
|
||||||
|
(shift -1))
|
||||||
|
(while (string-match "\\(\\\\\\) " file start)
|
||||||
|
(setq file (replace-match rep nil t file 1)
|
||||||
|
start (+ shift (match-end 0))))))
|
||||||
|
(when (eq system-type 'windows-nt)
|
||||||
|
(save-match-data
|
||||||
|
(let ((start 0))
|
||||||
|
(while (string-match "\\\\" file start)
|
||||||
|
(aset file (match-beginning 0) ?/)
|
||||||
|
(setq start (match-end 0))))))
|
||||||
|
|
||||||
|
;; Hence we don't need to worry about converting `\\' back to `\'.
|
||||||
|
(setq file (read (concat "\"" file "\""))))
|
||||||
(and file buffer-file-coding-system
|
(and file buffer-file-coding-system
|
||||||
(not file-name-coding-system)
|
(not file-name-coding-system)
|
||||||
(not default-file-name-coding-system)
|
(not default-file-name-coding-system)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue