[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 01f5d10 38/46: Fix company-gtags to work with t
From: |
Dmitry Gutov |
Subject: |
[elpa] externals/company 01f5d10 38/46: Fix company-gtags to work with tramp and multiple locations. |
Date: |
Wed, 30 Dec 2020 18:33:11 -0500 (EST) |
branch: externals/company
commit 01f5d101df3258d575591a65e7cb0974eec129cb
Author: Jimmy Aguilar Mena <kratsbinovish@gmail.com>
Commit: Jimmy Aguilar Mena <kratsbinovish@gmail.com>
Fix company-gtags to work with tramp and multiple locations.
* company-gtags.el (company-gtags-executable) : Now default to nil
because the search is made locally if not set.
(company-gtags--executable-p) : Function to search and cache the global
executable locally in the buffer.
(company-gtags--annotation) : Use the new function
company-gtags--executable-p instead of the custom variable
(company-gtags--fetch-tags) : Use the new function
company-gtags--executable-p but execute the process-file from the caller
buffer to have all the context. The output is written back to the
temporal buffer.
---
company-gtags.el | 63 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 26 deletions(-)
diff --git a/company-gtags.el b/company-gtags.el
index 598ba60..ff84d29 100644
--- a/company-gtags.el
+++ b/company-gtags.el
@@ -37,8 +37,7 @@
'company-gtags-gnu-global-program-name
'company-gtags-executable "earlier")
-(defcustom company-gtags-executable
- (executable-find "global")
+(defcustom company-gtags-executable nil
"Location of GNU global executable."
:type 'string)
@@ -48,6 +47,7 @@
:package-version '(company . "0.8.1"))
(defvar-local company-gtags--tags-available-p 'unknown)
+(defvar-local company-gtags--executable 'unknown)
(defcustom company-gtags-modes '(prog-mode jde-mode)
"Modes that use `company-gtags'.
@@ -62,30 +62,41 @@ completion."
(locate-dominating-file buffer-file-name "GTAGS"))
company-gtags--tags-available-p))
+(defun company-gtags--executable-p ()
+ (cond
+ (company-gtags-executable)
+ ((eq company-gtags--executable 'unknown)
+ (setq-local company-gtags--executable (if (version<= "27" emacs-version)
+ (executable-find "global" t)
+ (executable-find "global"))))
+ (t company-gtags--executable)))
+
(defun company-gtags--fetch-tags (prefix)
- (with-temp-buffer
- (let (tags)
- ;; For some reason Global v 6.6.3 is prone to returning exit status 1
- ;; even on successful searches when '-T' is used.
- (when (/= 3 (process-file company-gtags-executable nil
- ;; "-T" goes through all the tag files listed
in GTAGSLIBPATH
- (list (current-buffer) nil) nil "-xGqT" (concat
"^" prefix)))
- (goto-char (point-min))
- (cl-loop while
- (re-search-forward (concat
- "^"
- "\\([^ ]*\\)" ;; completion
- "[ \t]+\\([[:digit:]]+\\)" ;; linum
- "[ \t]+\\([^ \t]+\\)" ;; file
- "[ \t]+\\(.*\\)" ;; definition
- "$"
- ) nil t)
- collect
- (propertize (match-string 1)
- 'meta (match-string 4)
- 'location (cons (expand-file-name (match-string
3))
- (string-to-number (match-string
2)))
- ))))))
+ "Call global executable "
+ (let ((caller-buffer (current-buffer)))
+ (with-temp-buffer
+ (let ((temp-buffer (current-buffer)))
+ (when (with-current-buffer caller-buffer
+ ;; Execute the command in the local buffer but output in the
temporal one.
+ (/= 3 (process-file (company-gtags--executable-p) nil
+ ;; "-T" goes through all the tag files
listed in GTAGSLIBPATH
+ temp-buffer nil "-xGqT" (concat "^"
prefix))))
+ (goto-char (point-min))
+ (cl-loop while
+ (re-search-forward (concat
+ "^"
+ "\\([^ ]*\\)" ;; completion
+ "[ \t]+\\([[:digit:]]+\\)" ;; linum
+ "[ \t]+\\([^ \t]+\\)" ;; file
+ "[ \t]+\\(.*\\)" ;; definition
+ "$"
+ ) nil t)
+ collect
+ (propertize (match-string 1)
+ 'meta (match-string 4)
+ 'location (cons (expand-file-name (match-string
3))
+ (string-to-number (match-string
2)))
+ )))))))
(defun company-gtags--annotation (arg)
(let ((meta (get-text-property 0 'meta arg)))
@@ -98,7 +109,7 @@ completion."
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-gtags))
- (prefix (and company-gtags-executable
+ (prefix (and (company-gtags--executable-p)
buffer-file-name
(apply #'derived-mode-p company-gtags-modes)
(not (company-in-string-or-comment))
- [elpa] externals/company 97cfbc3 37/46: Merge pull request #1033 from edwargix/master, (continued)
- [elpa] externals/company 97cfbc3 37/46: Merge pull request #1033 from edwargix/master, Dmitry Gutov, 2020/12/30
- [elpa] externals/company e1726c4 22/46: Typo, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 4462e7d 16/46: Merge pull request #1004 from jcs-PR/fix-badge, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 18b7b79 29/46: Fix company--face-attribute helper, Dmitry Gutov, 2020/12/30
- [elpa] externals/company bea3195 36/46: Implement `company-select-first' and `company-select-last', Dmitry Gutov, 2020/12/30
- [elpa] externals/company 13e2ada 39/46: Avoid calling executable-find for local buffers., Dmitry Gutov, 2020/12/30
- [elpa] externals/company 0edc87d 23/46: Fix a couple of warnings, Dmitry Gutov, 2020/12/30
- [elpa] externals/company c4d205a 31/46: Fix company--face-attribute for text-scaled faces, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 7c25cf4 34/46: company-set-selection: adding offset internally instead of via caller, Dmitry Gutov, 2020/12/30
- [elpa] externals/company e6fa6c0 40/46: Add connection-local caching for gtags executable., Dmitry Gutov, 2020/12/30
- [elpa] externals/company 01f5d10 38/46: Fix company-gtags to work with tramp and multiple locations.,
Dmitry Gutov <=
- [elpa] externals/company 056d19d 42/46: Rename a function and add NEWS entry, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 3644a59 45/46: company-gtags--executable: Make sure to return the detected value, Dmitry Gutov, 2020/12/30
- [elpa] externals/company fb9db07 19/46: Merge pull request #999 from kiennq/bug/company-selection-default, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 569ff3e 20/46: Copy edits, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 2de0d9a 21/46: More copy edits, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 053c50d 30/46: Merge pull request #1023 from hlissner/fix-face-helper, Dmitry Gutov, 2020/12/30
- [elpa] externals/company b16b236 32/46: Fall back to unremapped 'default face :background, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 123b604 46/46: Merge branch 'master' of https://github.com/company-mode/company-mode into externals/company, Dmitry Gutov, 2020/12/30
- [elpa] externals/company dccd04b 44/46: company-gtags--fetch-tags: Revert an earlier change, Dmitry Gutov, 2020/12/30
- [elpa] externals/company 3a27fd9 43/46: company-gtags--executable: Don't create local values unnecessarily, Dmitry Gutov, 2020/12/30