Commit 6d8e0fc5 authored by Stephen Berman's avatar Stephen Berman

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.
parent 30030945
Pipeline #1456 failed with stage
in 51 minutes and 6 seconds
......@@ -612,14 +612,23 @@ Optional arguments are ignored."
(when (re-search-forward
directory-listing-before-filename-regexp lep t)
(setq beg (point)
;; If the file is a symlink, put the dired-filename
;; property only on the link name. (Using
;; (file-symlink-p (dired-get-filename)) fails in
;; wdired-mode, bug#32673.)
end (if (and (re-search-backward
dired-permission-flags-regexp nil t)
(looking-at "l")
(search-forward " -> " lep t))
end (if (or
;; If the file is a symlink, put the
;; dired-filename property only on the link
;; name. (Using (file-symlink-p
;; (dired-get-filename)) fails in
;; wdired-mode, bug#32673.)
(and (re-search-backward
dired-permission-flags-regexp nil t)
(looking-at "l")
(search-forward " -> " lep t))
;; When dired-listing-switches includes "F"
;; or "classify", don't treat appended
;; indicator characters as part of the file
;; name (bug#34915).
(and (dired-check-switches dired-actual-switches
"F" "classify")
(re-search-forward "[*/@|=>]$" lep t)))
(goto-char (match-beginning 0))
lep))
(put-text-property beg end 'dired-filename t))))))
......
......@@ -124,6 +124,51 @@ wdired-mode."
(kill-buffer buf)))
(delete-directory test-dir t)))))
(ert-deftest wdired-test-bug34915 ()
"Test editing when dired-listing-switches includes -F.
Appended file indicators should not count as part of the file
name, either before or after editing. Since
dired-move-to-end-of-filename handles indicator characters, it
suffices to compare the return values of dired-get-filename and
wdired-get-filename before and after editing."
;; FIXME: Add a test for a door (indicator ">") only under Solaris?
(let* ((test-dir (make-temp-file "test-dir-" t))
(server-socket-dir test-dir)
(dired-listing-switches "-Fl")
(buf (find-file-noselect test-dir)))
(unwind-protect
(progn
(with-current-buffer buf
(dired-create-empty-file "foo")
(set-file-modes "foo" (file-modes-symbolic-to-number "+x"))
(make-symbolic-link "foo" "bar")
(make-directory "foodir")
(require 'dired-x)
(dired-smart-shell-command "mkfifo foopipe")
(server-force-delete)
(server-start) ; Add a socket file.
(kill-buffer buf))
(dired test-dir)
(dired-toggle-read-only)
(let (names)
;; Test that the file names are the same in Dired and WDired.
(while (not (eobp))
(should (equal (dired-get-filename 'no-dir t)
(wdired-get-filename t)))
(insert "w")
(push (wdired-get-filename t) names)
(dired-next-line 1))
(wdired-finish-edit)
;; Test that editing the file names ignores the indicator
;; character.
(let (dir)
(while (and (dired-previous-line 1)
(setq dir (dired-get-filename 'no-dir t)))
(should (equal dir (pop names)))))))
(kill-buffer (get-buffer test-dir))
(server-force-delete)
(delete-directory test-dir t))))
(provide 'wdired-tests)
;;; wdired-tests.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment