[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ggtags 4d90000 8/9: Fix #163: properly construct the --
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ggtags 4d90000 8/9: Fix #163: properly construct the --nearness arg to global |
Date: |
Fri, 26 Mar 2021 22:46:21 -0400 (EDT) |
branch: externals/ggtags
commit 4d9000034d352cd983ae6626f560e434d0b3e9ca
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>
Fix #163: properly construct the --nearness arg to global
--nearness=. is useless when the starting directory is the project
root which is the case with ggtags-find-tag.
---
README.rst | 2 ++
ggtags.el | 27 ++++++++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/README.rst b/README.rst
index e8e543b..664eb97 100644
--- a/README.rst
+++ b/README.rst
@@ -318,6 +318,8 @@ NEWS
+++++++
#. Drop support for Emacs < 25.
+#. Integration with ``xref.el``.
+#. Make ``ggtags-sort-by-nearness`` actually work.
[2018-07-25 Wed] 0.8.13
+++++++++++++++++++++++
diff --git a/ggtags.el b/ggtags.el
index 8830679..555873a 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -1,6 +1,6 @@
;;; ggtags.el --- emacs frontend to GNU Global source code tagging system -*-
lexical-binding: t; -*-
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
;; Author: Leo Liu <sdl.web@gmail.com>
;; Version: 0.9.0
@@ -863,9 +863,11 @@ blocking emacs."
(default (substring-no-properties default))
(t (ggtags-read-tag type t prompt require-match default))))))
-(defun ggtags-sort-by-nearness-p ()
+(defun ggtags-sort-by-nearness-p (&optional start-location)
(and ggtags-sort-by-nearness
- (ggtags-process-succeed-p "global" "--nearness=." "--help")))
+ (ggtags-process-succeed-p "global" "--nearness=." "--help")
+ (concat "--nearness="
+ (or start-location buffer-file-name default-directory))))
(defun ggtags-global-build-command (cmd &rest args)
;; CMD can be definition, reference, symbol, grep, idutils
@@ -877,7 +879,6 @@ blocking emacs."
(ggtags-find-project)
(ggtags-project-has-color (ggtags-find-project))
"--color=always")
- (and (ggtags-sort-by-nearness-p) "--nearness=.")
(and (ggtags-find-project)
(ggtags-project-has-path-style
(ggtags-find-project))
"--path-style=shorter")
@@ -940,7 +941,11 @@ blocking emacs."
(defun ggtags-find-tag (cmd &rest args)
(ggtags-check-project)
- (ggtags-global-start (apply #'ggtags-global-build-command cmd args)))
+ (let ((nearness (ggtags-sort-by-nearness-p
+ (ggtags-project-relative-file
+ (or buffer-file-name default-directory)))))
+ (ggtags-global-start
+ (apply #'ggtags-global-build-command cmd nearness args))))
(defun ggtags-include-file ()
"Calculate the include file based on `ggtags-include-pattern'."
@@ -2037,7 +2042,10 @@ If SYNC is non-nil, synchronously run CMDS and call
CALLBACK."
(let* ((re (cadr (assq 'grep ggtags-global-error-regexp-alist-alist)))
(current (current-buffer))
(buffer (get-buffer-create " *ggtags-definition*"))
- (args (list "--result=grep" "--path-style=absolute" name))
+ ;; `.' works here because ggtags-global-output doesn't set
+ ;; default-directory to project root.
+ (args (delq nil (list (ggtags-sort-by-nearness-p ".")
+ "--result=grep" "--path-style=absolute" name)))
;; Need these bindings so that let-binding
;; `ggtags-print-definition-function' can work see
;; `ggtags-eldoc-function'.
@@ -2056,11 +2064,8 @@ If SYNC is non-nil, synchronously run CMDS and call
CALLBACK."
(with-current-buffer current
(funcall print-fn (funcall get-fn defs)))))))
(ggtags-with-current-project
- (ggtags-global-output
- buffer
- (cons (ggtags-program-path "global")
- (if (ggtags-sort-by-nearness-p) (cons "--nearness=." args) args))
- show 100))))
+ (ggtags-global-output buffer (cons (ggtags-program-path "global") args)
+ show 100))))
(defvar ggtags-mode-prefix-map
(let ((m (make-sparse-keymap)))
- [elpa] externals/ggtags updated (17a121a -> 1c43705), Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags a0809f5 1/9: Bump version and require Emacs >= 25, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags c737181 2/9: Fix #158: ggtags-fontify-code improvement suggestion, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 8840213 3/9: Correctly set `process-mark` in `ggtags-global-output`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags c536ec5 5/9: Cache number of lines from previous output in `ggtags-global-output`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 6696764 6/9: Use `count-lines` instead of `line-number-at-pos`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 2f538aa 7/9: Add xref support, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 1c43705 9/9: Update docs to use `universal-ctags` instead of `exuberant-ctags`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 4d90000 8/9: Fix #163: properly construct the --nearness arg to global,
Stefan Monnier <=
- [elpa] externals/ggtags a2906b7 4/9: Allow `ggtags-global-output` to run the process synchronously, Stefan Monnier, 2021/03/26