]> git.eshelyaron.com Git - emacs.git/commitdiff
Support old BSD find and "root dir symlink" better
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 7 Jun 2021 01:52:30 +0000 (04:52 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 7 Jun 2021 01:52:30 +0000 (04:52 +0300)
* lisp/progmodes/grep.el (grep-compute-defaults):
Add '-H' to grep-find-template (bug#48471).

* lisp/cedet/semantic/symref/grep.el (semantic-symref-perform-search):
Pass the root directory name without the trailing slash.

* lisp/progmodes/xref.el (xref-matches-in-directory): Ditto.

* test/lisp/progmodes/xref-tests.el (xref--xref-file-name-display-is-abs)
(xref--xref-file-name-display-is-relative-to-project-root):
Make tests more strict again.

lisp/cedet/semantic/symref/grep.el
lisp/progmodes/grep.el
lisp/progmodes/xref.el
test/lisp/progmodes/xref-tests.el

index 46027f1f91e401649d0d35690746d0514c44450d..180d779a780f2f56e15a0c5981e11fb5e401888e 100644 (file)
@@ -168,7 +168,7 @@ This shell should support pipe redirect syntax."
       (erase-buffer)
       (setq default-directory rootdir)
       (let ((cmd (semantic-symref-grep-use-template
-                  (file-name-as-directory (file-local-name rootdir))
+                  (directory-file-name (file-local-name rootdir))
                   filepattern grepflags greppat)))
         (process-file semantic-symref-grep-shell nil b nil
                       shell-command-switch cmd)))
index 80c3e7840f0e80b73544e357524038a9d3a8d9e4..8647c7089d50427b75f353e06ae348cd3af51c5c 100644 (file)
@@ -774,25 +774,24 @@ The value depends on `grep-command', `grep-template',
                (let ((gcmd (format "%s <C> %s <R>"
                                    grep-program grep-options))
                      (null (if grep-use-null-device
-                               (format "%s " (null-device))
-                             "")))
-                 (cond ((eq grep-find-use-xargs 'gnu)
-                        (format "%s <D> <X> -type f <F> -print0 | \"%s\" -0 %s"
-                                find-program xargs-program gcmd))
-                       ((eq grep-find-use-xargs 'gnu-sort)
-                        (format "%s <D> <X> -type f <F> -print0 | sort -z | \"%s\" -0 %s"
-                                find-program xargs-program gcmd))
-                       ((eq grep-find-use-xargs 'exec)
-                        (format "%s <D> <X> -type f <F> -exec %s %s %s%s"
-                                find-program gcmd quot-braces null quot-scolon))
-                       ((eq grep-find-use-xargs 'exec-plus)
-                        (format "%s <D> <X> -type f <F> -exec %s %s%s +"
-                                find-program gcmd null quot-braces))
-                       (t
-                        (format "%s <D> <X> -type f <F> -print | \"%s\" %s"
-                                find-program xargs-program gcmd))))))))
-
-    ;; Save defaults for this host.
+                                (format "%s " (null-device))
+                              "")))
+                  (cond ((eq grep-find-use-xargs 'gnu)
+                         (format "%s -H <D> <X> -type f <F> -print0 | \"%s\" -0 %s"
+                                 find-program xargs-program gcmd))
+                        ((eq grep-find-use-xargs 'gnu-sort)
+                         (format "%s -H <D> <X> -type f <F> -print0 | sort -z | \"%s\" -0 %s"
+                                 find-program xargs-program gcmd))
+                        ((eq grep-find-use-xargs 'exec)
+                         (format "%s -H <D> <X> -type f <F> -exec %s %s %s%s"
+                                 find-program gcmd quot-braces null quot-scolon))
+                        ((eq grep-find-use-xargs 'exec-plus)
+                         (format "%s -H <D> <X> -type f <F> -exec %s %s%s +"
+                                 find-program gcmd null quot-braces))
+                        (t
+                         (format "%s -H <D> <X> -type f <F> -print | \"%s\" %s"
+                                 find-program xargs-program gcmd))))))))
+     ;; Save defaults for this host.
     (setq grep-host-defaults-alist
          (delete (assq host-id grep-host-defaults-alist)
                  grep-host-defaults-alist))
index d307c31df8be16a99f74f3a4cb67642af9d22781..b7a926f82e0af0fd7b8093879e39b7fbcde4555a 100644 (file)
@@ -1464,7 +1464,7 @@ IGNORES is a list of glob patterns for files to ignore."
        ;; do that reliably enough, without creating false negatives?
        (command (xref--rgrep-command (xref--regexp-to-extended regexp)
                                      files
-                                     (file-name-as-directory
+                                     (directory-file-name
                                       (file-name-unquote
                                        (file-local-name (expand-file-name dir))))
                                      ignores))
index 66099dc110c77e5e934f2fc5c208985d7f3184b0..d29452243b2bca124a0ba62e13ee789146b295a1 100644 (file)
     (should (null (marker-position (cdr (nth 0 (cdr cons2))))))))
 
 (ert-deftest xref--xref-file-name-display-is-abs ()
-  (let* ((xref-file-name-display 'abs)
-         ;; Some older BSD find versions can produce '//' in the output.
-         (expected (list
-                    (concat xref-tests--data-dir "/?file1.txt")
-                    (concat xref-tests--data-dir "/?file2.txt")))
-         (actual (delete-dups
-                  (mapcar 'xref-location-group
-                          (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))))
-    (should (= (length expected) (length actual)))
-    (should (cl-every (lambda (e1 e2)
-                        (string-match-p e1 e2))
-                      expected actual))))
+  (let ((xref-file-name-display 'abs))
+    (should (equal
+             (delete-dups
+              (mapcar 'xref-location-group
+                      (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))
+             (list
+              (concat xref-tests--data-dir "file1.txt")
+              (concat xref-tests--data-dir "file2.txt"))))))
 
 (ert-deftest xref--xref-file-name-display-is-nondirectory ()
   (let ((xref-file-name-display 'nondirectory))
           (file-name-directory (directory-file-name xref-tests--data-dir)))
          (project-find-functions
           (lambda (_) (cons 'transient data-parent-dir)))
-         (xref-file-name-display 'project-relative)
-         ;; Some older BSD find versions can produce '//' in the output.
-         (expected (list
-                    "xref-resources//?file1.txt"
-                    "xref-resources//?file2.txt"))
-         (actual (delete-dups
-                  (mapcar 'xref-location-group
-                          (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))))
-    (should (and (= (length expected) (length actual))
-                 (cl-every (lambda (e1 e2)
-                             (string-match-p e1 e2))
-                           expected actual)))))
+         (xref-file-name-display 'project-relative))
+    (should (equal
+             (delete-dups
+              (mapcar 'xref-location-group
+                      (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))
+             (list
+              "xref-resources/file1.txt"
+              "xref-resources/file2.txt")))))
 
 ;;; xref-tests.el ends here