branch: externals/gtags-mode
commit 87245a0bb075f37b9e82fd2a5f799e4636392a1e
Author: Aymeric Agon-Rambosson <aymeric.a...@yandex.com>
Commit: Aymeric Agon-Rambosson <aymeric.a...@yandex.com>

    Correct path to file when definition is found in GTAGSLIBPATH
    
    --path-style=through always prints the path as it is found in the GPATH 
file,
    which is not necessarily equivalent to "relative from the project root".
    
    See https://lists.gnu.org/archive/html/bug-global/2025-05/msg00000.html and
    https://lists.gnu.org/archive/html/bug-global/2025-05/msg00001.html
    
    If you want to always print the path as relative to the root of the 
project, it
    is better to use --path-style=relative (which can be omitted, being 
default) in
    conjunction with -C or --directory pointing to the project root.
---
 gtags-mode.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gtags-mode.el b/gtags-mode.el
index 0c253f173f..a6b969d9b1 100644
--- a/gtags-mode.el
+++ b/gtags-mode.el
@@ -104,7 +104,7 @@ The address is absolute for remote hosts.")
   "Regex to filter the output with `gtags-mode--output-format-options'.")
 
 (defconst gtags-mode--output-format-options
-  '("--result=cscope" "--path-style=through" "--color=never")
+  '("--result=cscope" "--path-style=relative" "--color=never")
   "Command line options to use with `gtags-mode--output-format-regex'.")
 
 (defsubst gtags-mode--message (level format-string &rest args)
@@ -278,11 +278,11 @@ name, code, file, line."
                       (funcall creator
                                (match-string-no-properties 2 line)   ;; name
                                (match-string-no-properties 4 line)   ;; code
-                               (concat root (substring-no-properties
-                                             line (1+ (match-beginning 1)) 
(match-end 1))) ;; file
+                               (concat root (match-string-no-properties 1 
line)) ;; file
                                (string-to-number (match-string-no-properties 3 
line))))) ;; line
                   (apply #'gtags-mode--exec-sync
-                   (append gtags-mode--output-format-options args `(,symbol)) 
)))
+                         (append '("--directory") `(,(file-local-name root))
+                                 gtags-mode--output-format-options args 
`(,symbol)))))
     (error "Calling gtags-mode--filter-find-symbol without GTAGSROOT")
     nil))
 

Reply via email to