all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: "Daniel Martín" <mardani29@yahoo.es>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: [PATCH] Fix some failing tests in BSD systems
Date: Wed, 6 Jan 2021 03:38:04 +0200	[thread overview]
Message-ID: <a9fd5602-d08c-471d-6fa6-c027d3739d1e@yandex.ru> (raw)
In-Reply-To: <m1czykmja7.fsf@yahoo.es>

[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]

On 05.01.2021 00:25, Daniel Martín wrote:
> Thanks, it fixes the test failures for me.  However, I still see the
> extra '/' if I follow these steps:
> 
> - make TAGS
> - emacs -Q
> - Visit src/xdisp.c
> - M-? in redisplay_internal
> 
> Perhaps there are more places that need that patch.

Thanks, that's the third place, and probably the final one.

In the meantime, plot thickens: as pointed out privately by Davis 
Herring, using 'find' on a directory without a trailing slash will fail 
if the directory is a symlink (it will only list the symlink itself).

At this point we could double down on this approach and use the '-H' 
argument (though grep-find-template doesn't make this easy), or return 
to your original patch. Or yet alternatively, paper over this inside the 
xref-location-group defmethod. The two alternatives attached.

So I guess I should ask: was the particular behavior annoying by itself, 
or is it only a problem because of the failing test?

I also wonder whether all macOS users see this, or whether it's maybe 
fixed in some latest version of BSD find. Because it's apparently 
(arguably) a bug: https://unix.stackexchange.com/a/320440/166215

[-- Attachment #2: find-no-doubleslash-h.diff --]
[-- Type: text/x-patch, Size: 2953 bytes --]

diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el
index 5f9a3fa352..21f075041c 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -119,12 +119,15 @@ semantic-symref-grep-use-template
                    ;; it to the user.  By contrast, here we don't show
                    ;; the output, and the SGR escapes get in the way
                    ;; of parsing the output.
-                   (replace-regexp-in-string "--color=always" ""
-                                             grep-find-template t t)
+                   (replace-regexp-in-string
+                    "<D>" "-H <D>"
+                    (replace-regexp-in-string "--color=always" ""
+                                              grep-find-template t t)
+                    t t)
                  grep-find-template)
                pattern
                filepattern
-               rootdir)))
+               (directory-file-name rootdir))))
     cmd))
 
 (defcustom semantic-symref-grep-shell shell-file-name
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d417382c0d..04546d1e4d 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -289,9 +289,9 @@ project--files-in-directory
          ;; expanded and not left for the shell command
          ;; to interpret.
          (localdir (file-local-name (expand-file-name dir)))
-         (command (format "%s %s %s -type f %s -print0"
+         (command (format "%s -H %s %s -type f %s -print0"
                           find-program
-                          localdir
+                          (directory-file-name localdir)
                           (xref--find-ignores-arguments ignores localdir)
                           (if files
                               (concat (shell-quote-argument "(")
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index d2b5acd555..13fc2f09c7 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1374,7 +1374,8 @@ xref-matches-in-directory
        ;; do that reliably enough, without creating false negatives?
        (command (xref--rgrep-command (xref--regexp-to-extended regexp)
                                      files
-                                     (file-local-name (expand-file-name dir))
+                                     (directory-file-name
+                                      (file-local-name (expand-file-name dir)))
                                      ignores))
        (def default-directory)
        (buf (get-buffer-create " *xref-grep*"))
@@ -1543,7 +1544,10 @@ xref--rgrep-command
   ;; `shell-quote-argument' quotes the tilde as well.
   (cl-assert (not (string-match-p "\\`~" dir)))
   (grep-expand-template
-   grep-find-template
+   (replace-regexp-in-string
+    "<D>" "-H <D>"
+    grep-find-template
+    t t)
    regexp
    (concat (shell-quote-argument "(")
            " " find-name-arg " "

[-- Attachment #3: find-no-doubleslash-postprocess.diff --]
[-- Type: text/x-patch, Size: 3355 bytes --]

diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el
index 5f9a3fa352..9f0ac38ec7 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -168,7 +168,8 @@ semantic-symref-perform-search
       (erase-buffer)
       (setq default-directory rootdir)
       (let ((cmd (semantic-symref-grep-use-template
-                  (file-local-name rootdir) filepattern grepflags greppat)))
+                  (file-name-as-directory (file-local-name rootdir))
+                  filepattern grepflags greppat)))
         (process-file semantic-symref-grep-shell nil b nil
                       shell-command-switch cmd)))
     (setq ans (semantic-symref-parse-tool-output tool b))
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d417382c0d..f91246a885 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -291,7 +291,7 @@ project--files-in-directory
          (localdir (file-local-name (expand-file-name dir)))
          (command (format "%s %s %s -type f %s -print0"
                           find-program
-                          localdir
+                          (file-name-as-directory localdir)
                           (xref--find-ignores-arguments ignores localdir)
                           (if files
                               (concat (shell-quote-argument "(")
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index d2b5acd555..bacc5e6f1c 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -161,11 +161,13 @@ xref--project-root-memo
   "Cons mapping `default-directory' value to the search root.")
 
 (cl-defmethod xref-location-group ((l xref-file-location))
+  (let ((file (oref l file)))
+    (unless (eq xref-file-name-display 'abs)
+      (setq file (replace-regexp-in-string "//" "/" file t t)))
   (cl-ecase xref-file-name-display
-    (abs
-     (oref l file))
+    (abs file)
     (nondirectory
-     (file-name-nondirectory (oref l file)))
+     (file-name-nondirectory file))
     (project-relative
      (unless (and xref--project-root-memo
                   (equal (car xref--project-root-memo)
@@ -176,12 +178,12 @@ xref-location-group
                           (let ((pr (project-current)))
                             (and pr (xref--project-root pr)))))
                      (and root (expand-file-name root))))))
-     (let ((file (oref l file))
+     (let ((file file)
            (search-root (cdr xref--project-root-memo)))
        (if (and search-root
                 (string-prefix-p search-root file))
            (substring file (length search-root))
-         file)))))
+         file))))))
 
 (defclass xref-buffer-location (xref-location)
   ((buffer :type buffer :initarg :buffer)
@@ -1374,7 +1376,8 @@ xref-matches-in-directory
        ;; do that reliably enough, without creating false negatives?
        (command (xref--rgrep-command (xref--regexp-to-extended regexp)
                                      files
-                                     (file-local-name (expand-file-name dir))
+                                     (file-name-as-directory
+                                      (file-local-name (expand-file-name dir)))
                                      ignores))
        (def default-directory)
        (buf (get-buffer-create " *xref-grep*"))

  reply	other threads:[~2021-01-06  1:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m1sg7i7xfl.fsf.ref@yahoo.es>
2021-01-03 17:16 ` [PATCH] Fix some failing tests in BSD systems Daniel Martín
2021-01-03 17:35   ` Eli Zaretskii
2021-01-03 21:08     ` Daniel Martín
2021-01-04  1:41     ` Dmitry Gutov
2021-01-04  3:30       ` Eli Zaretskii
2021-01-04 13:10         ` Dmitry Gutov
2021-01-04 15:52           ` Eli Zaretskii
2021-01-04 17:10             ` Dmitry Gutov
2021-01-04 22:25               ` Daniel Martín
2021-01-06  1:38                 ` Dmitry Gutov [this message]
2021-01-06  9:41                   ` Daniel Martín
2021-01-06 17:17                     ` Dmitry Gutov
2021-01-06 18:48                       ` Stefan Monnier
2021-01-06 21:17                         ` Dmitry Gutov
2021-01-04  1:43   ` Dmitry Gutov
2021-01-04  3:48     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9fd5602-d08c-471d-6fa6-c027d3739d1e@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=mardani29@yahoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.