]> git.eshelyaron.com Git - emacs.git/commitdiff
Make wdired-mode ignore ls file indicators
authorStephen Berman <stephen.berman@gmx.net>
Thu, 25 Apr 2019 17:17:23 +0000 (19:17 +0200)
committerStephen Berman <stephen.berman@gmx.net>
Thu, 25 Apr 2019 17:17:23 +0000 (19:17 +0200)
* 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.

lisp/wdired.el
test/lisp/wdired-tests.el

index acc62e4e3911fbde52b221bc5ee89ead98cb6540..d2a298bd25b8a4f3266f21e5746518679f56c88b 100644 (file)
@@ -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))))))
index dc67796cdedc92bfde5f0f684ec788758379365b..9682843db29c6aaef75e5d5562e2c19203aba511 100644 (file)
@@ -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