aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2019-04-25 19:17:23 +0200
committerStephen Berman2019-04-25 19:17:23 +0200
commit6d8e0fc5aa7673540486af9ecbfc0a3e23c305cf (patch)
tree75247e50c3873c8dfeb4ad9b4b4e80851d2abdbb
parent30030945c30c4710d0d70cabad9d1b512cede0ee (diff)
downloademacs-6d8e0fc5aa7673540486af9ecbfc0a3e23c305cf.tar.gz
emacs-6d8e0fc5aa7673540486af9ecbfc0a3e23c305cf.zip
Make wdired-mode ignore ls file indicators
* lisp/wdired.el (wdired--restore-dired-filename-prop): When dired-listing-switches includes "F" or "classify", don't treat appended indicator characters as part of the file name (bug#34915). * test/lisp/wdired-tests.el (wdired-test-bug34915): New test.
-rw-r--r--lisp/wdired.el25
-rw-r--r--test/lisp/wdired-tests.el45
2 files changed, 62 insertions, 8 deletions
diff --git a/lisp/wdired.el b/lisp/wdired.el
index acc62e4e391..d2a298bd25b 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -612,14 +612,23 @@ Optional arguments are ignored."
612 (when (re-search-forward 612 (when (re-search-forward
613 directory-listing-before-filename-regexp lep t) 613 directory-listing-before-filename-regexp lep t)
614 (setq beg (point) 614 (setq beg (point)
615 ;; If the file is a symlink, put the dired-filename 615 end (if (or
616 ;; property only on the link name. (Using 616 ;; If the file is a symlink, put the
617 ;; (file-symlink-p (dired-get-filename)) fails in 617 ;; dired-filename property only on the link
618 ;; wdired-mode, bug#32673.) 618 ;; name. (Using (file-symlink-p
619 end (if (and (re-search-backward 619 ;; (dired-get-filename)) fails in
620 dired-permission-flags-regexp nil t) 620 ;; wdired-mode, bug#32673.)
621 (looking-at "l") 621 (and (re-search-backward
622 (search-forward " -> " lep t)) 622 dired-permission-flags-regexp nil t)
623 (looking-at "l")
624 (search-forward " -> " lep t))
625 ;; When dired-listing-switches includes "F"
626 ;; or "classify", don't treat appended
627 ;; indicator characters as part of the file
628 ;; name (bug#34915).
629 (and (dired-check-switches dired-actual-switches
630 "F" "classify")
631 (re-search-forward "[*/@|=>]$" lep t)))
623 (goto-char (match-beginning 0)) 632 (goto-char (match-beginning 0))
624 lep)) 633 lep))
625 (put-text-property beg end 'dired-filename t)))))) 634 (put-text-property beg end 'dired-filename t))))))
diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el
index dc67796cded..9682843db29 100644
--- a/test/lisp/wdired-tests.el
+++ b/test/lisp/wdired-tests.el
@@ -124,6 +124,51 @@ wdired-mode."
124 (kill-buffer buf))) 124 (kill-buffer buf)))
125 (delete-directory test-dir t))))) 125 (delete-directory test-dir t)))))
126 126
127(ert-deftest wdired-test-bug34915 ()
128 "Test editing when dired-listing-switches includes -F.
129Appended file indicators should not count as part of the file
130name, either before or after editing. Since
131dired-move-to-end-of-filename handles indicator characters, it
132suffices to compare the return values of dired-get-filename and
133wdired-get-filename before and after editing."
134 ;; FIXME: Add a test for a door (indicator ">") only under Solaris?
135 (let* ((test-dir (make-temp-file "test-dir-" t))
136 (server-socket-dir test-dir)
137 (dired-listing-switches "-Fl")
138 (buf (find-file-noselect test-dir)))
139 (unwind-protect
140 (progn
141 (with-current-buffer buf
142 (dired-create-empty-file "foo")
143 (set-file-modes "foo" (file-modes-symbolic-to-number "+x"))
144 (make-symbolic-link "foo" "bar")
145 (make-directory "foodir")
146 (require 'dired-x)
147 (dired-smart-shell-command "mkfifo foopipe")
148 (server-force-delete)
149 (server-start) ; Add a socket file.
150 (kill-buffer buf))
151 (dired test-dir)
152 (dired-toggle-read-only)
153 (let (names)
154 ;; Test that the file names are the same in Dired and WDired.
155 (while (not (eobp))
156 (should (equal (dired-get-filename 'no-dir t)
157 (wdired-get-filename t)))
158 (insert "w")
159 (push (wdired-get-filename t) names)
160 (dired-next-line 1))
161 (wdired-finish-edit)
162 ;; Test that editing the file names ignores the indicator
163 ;; character.
164 (let (dir)
165 (while (and (dired-previous-line 1)
166 (setq dir (dired-get-filename 'no-dir t)))
167 (should (equal dir (pop names)))))))
168 (kill-buffer (get-buffer test-dir))
169 (server-force-delete)
170 (delete-directory test-dir t))))
171
127 172
128(provide 'wdired-tests) 173(provide 'wdired-tests)
129;;; wdired-tests.el ends here 174;;; wdired-tests.el ends here