[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gtags-mode c2e13cc742 33/61: Use a better name gtags-mo
From: |
ELPA Syncer |
Subject: |
[elpa] externals/gtags-mode c2e13cc742 33/61: Use a better name gtags-mode is free. |
Date: |
Thu, 28 Apr 2022 10:57:40 -0400 (EDT) |
branch: externals/gtags-mode
commit c2e13cc74200f8968038f7474c18a52f25aef6c5
Author: Jimmy Aguilar Mena <kratsbinovish@gmail.com>
Commit: Jimmy Aguilar Mena <kratsbinovish@gmail.com>
Use a better name gtags-mode is free.
---
gtags-xref.el => gtags-mode.el | 226 ++++++++++++++++++++---------------------
1 file changed, 113 insertions(+), 113 deletions(-)
diff --git a/gtags-xref.el b/gtags-mode.el
similarity index 55%
rename from gtags-xref.el
rename to gtags-mode.el
index c5e00bfca0..15b4c1f23f 100644
--- a/gtags-xref.el
+++ b/gtags-mode.el
@@ -1,9 +1,9 @@
-;;; gtags-xref.el --- GNU Global integration with xref, project and imenu. -*-
lexical-binding: t; -*-
+;;; gtags-mode.el --- GNU Global integration with xref, project and imenu. -*-
lexical-binding: t; -*-
;; Copyright (C) 2022 Jimmy Aguilar Mena
;; Author: Jimmy Aguilar Mena
-;; URL: https://github.com/Ergus/gtags-xref
+;; URL: https://github.com/Ergus/gtags-mode
;; Keywords: xref, project, imenu, gtags, global
;; Version: 1.0 alpha
;; Package-Requires: ((emacs "28"))
@@ -31,72 +31,72 @@
(require 'cl-generic)
(require 'files-x)
-(defgroup gtags-xref nil
- "GNU Global grup for xref."
+(defgroup gtags-mode nil
+ "GNU Global group for xref."
:group 'xref)
-(defcustom gtags-xref-global "global"
+(defcustom gtags-mode-global-executable "global"
"GNU Global executable."
:type 'string
:local t)
-(defcustom gtags-xref-gtags "gtags"
- "Gtags executable."
+(defcustom gtags-mode-gtags-executable "gtags"
+ "GNU Gtags executable."
:type 'string
:local t)
-(defcustom gtags-xref-lighter "Gtags-Xref"
+(defcustom gtags-mode-lighter "Gtags"
"Gtags executable."
:type 'string
:risky t)
-(defvar gtags-xref--roots-list nil
+(defvar gtags-mode--roots-list nil
"Full list of Global roots.
The address is absolute for remote hosts.")
-(put 'gtags-xref--roots-list 'risky-local-variable t)
+(put 'gtags-mode--roots-list 'risky-local-variable t)
-(defvar-local gtags-xref--global (executable-find gtags-xref-global))
-(defvar-local gtags-xref--gtags (executable-find gtags-xref-gtags))
-(defvar-local gtags-xref--project-root nil
+(defvar-local gtags-mode--global (executable-find
gtags-mode-global-executable))
+(defvar-local gtags-mode--gtags (executable-find gtags-mode-gtags-executable))
+(defvar-local gtags-mode--root nil
"Project Global root for this buffer.
the address is relative on remote hosts.")
-(defconst gtags-xref--output-format-regex
+(defconst gtags-mode--output-format-regex
"^\\([^[:blank:]]+\\)[[:blank:]]+\\([[:digit:]]+\\)[[:blank:]]+\\([^[:blank:]]+\\)[[:blank:]]+\\(.*\\)"
- "Regex to filter the output with `gtags-xref--output-format-options'.")
+ "Regex to filter the output with `gtags-mode--output-format-options'.")
-(defconst gtags-xref--output-format-options
+(defconst gtags-mode--output-format-options
'("--result=ctags-x" "--path-style=absolute")
- "Command line options to use with `gtags-xref--output-format-regex'.")
+ "Command line options to use with `gtags-mode--output-format-regex'.")
;; Connection functions
-(defun gtags-xref--set-connection-locals ()
+(defun gtags-mode--set-connection-locals ()
"Set GLOBAL connection local variables when possible and needed."
(when-let* ((remote (file-remote-p default-directory))
(criteria (connection-local-criteria-for-default-directory))
- ((not (and (local-variable-p 'gtags-xref--global)
- (local-variable-p 'gtags-xref--gtags))))
- (symvars (intern (concat "gtags-xref--" remote "-vars")))
+ ((not (and (local-variable-p 'gtags-mode--global)
+ (local-variable-p 'gtags-mode--gtags))))
+ (symvars (intern (concat "gtags-mode--" remote "-vars")))
(enable-connection-local-variables t))
(unless (alist-get symvars connection-local-profile-alist)
(with-connection-local-variables
- (let ((xref-global (if (local-variable-p 'gtags-xref-global)
- gtags-xref-global
- (file-name-nondirectory gtags-xref-global)))
- (xref-gtags (if (local-variable-p 'gtags-xref-global)
- gtags-xref-gtags
- (file-name-nondirectory gtags-xref-gtags))))
+ (let ((global (if (local-variable-p 'gtags-mode-global-executable)
+ gtags-mode-global-executable
+ (file-name-nondirectory gtags-mode-global-executable)))
+ (gtags (if (local-variable-p 'gtags-mode-gtags-executable)
+ gtags-mode-gtags-executable
+ (file-name-nondirectory gtags-mode-gtags-executable))))
(connection-local-set-profile-variables
symvars
- `((gtags-xref--global . ,(executable-find xref-global t))
- (gtags-xref--gtags . ,(executable-find xref-gtags t))))
+ `((gtags-mode--global . ,(executable-find global t))
+ (gtags-mode--gtags . ,(executable-find gtags t))))
(connection-local-set-profiles criteria symvars))))
(hack-connection-local-variables-apply criteria)))
;; Async functions
-(defun gtags-xref--exec-async-sentinel (process event)
+(defun gtags-mode--exec-async-sentinel (process event)
"Sentinel to run when PROCESS emits EVENT.
-This is the sentinel set in `gtags-xref--exec-async'."
+This is the sentinel set in `gtags-mode--exec-async'."
(let ((temp-buffer (process-buffer process)))
(if (and (eq (process-status process) 'exit)
(eq (process-exit-status process) 0))
@@ -107,22 +107,22 @@ This is the sentinel set in `gtags-xref--exec-async'."
(message "Global error output:\n%s" (buffer-string)))))
(message "Async %s: %s" (process-command process) event))
-(defun gtags-xref--exec-async (cmd args)
+(defun gtags-mode--exec-async (cmd args)
"Run CMD with ARGS asynchronously and set SENTINEL to process.
Starts an asynchronous process and sets
-`gtags-xref--exec-async-sentinel' as the process sentinel if
+`gtags-mode--exec-async-sentinel' as the process sentinel if
SENTINEL is nil or not specified. Returns the process object."
(when cmd
(make-process :name (format "%s-async" cmd)
:buffer (generate-new-buffer " *temp*" t)
:command (append (list cmd) args)
- :sentinel #'gtags-xref--exec-async-sentinel
+ :sentinel #'gtags-mode--exec-async-sentinel
:file-handler t)))
-(defun gtags-xref--exec-sync (cmd args)
+(defun gtags-mode--exec-sync (cmd args)
"Run CMD with ARGS synchronously, on success call SENTINEL.
Starts a sync process; on success call SENTINEL or
-`gtags-xref--sync-sentinel' if SENTINEL is not specified or nil.
+`gtags-mode--sync-sentinel' if SENTINEL is not specified or nil.
Returns the output of SENTINEL or nil if any error occurred."
(when cmd
(with-temp-buffer ;; When sync
@@ -134,75 +134,75 @@ Returns the output of SENTINEL or nil if any error
occurred."
nil)))))
;; Api functions
-(defun gtags-xref--find-root ()
+(defun gtags-mode--find-root ()
"Return the GLOBAL project root. Return nil if none."
- (when-let ((root (car (gtags-xref--exec-sync gtags-xref--global
+ (when-let ((root (car (gtags-mode--exec-sync gtags-mode--global
'("--print-dbpath")))))
(setq root (concat (file-remote-p default-directory)
(file-truename root)))
- (add-to-list 'gtags-xref--roots-list root)
+ (add-to-list 'gtags-mode--roots-list root)
root))
-(defun gtags-xref--filter-find-symbol (args symbol creator)
- "Run `gtags-xref--exec-sync' with ARGS on SYMBOL and filter output with
CREATOR.
+(defun gtags-mode--filter-find-symbol (args symbol creator)
+ "Run `gtags-mode--exec-sync' with ARGS on SYMBOL and filter output with
CREATOR.
Returns the results as a list of CREATORS outputs similar to
`mapcar'. Creator should be a function with 4 input arguments:
name, code, file, line."
(delete nil
(mapcar
(lambda (line)
- (when (string-match gtags-xref--output-format-regex line)
+ (when (string-match gtags-mode--output-format-regex line)
(funcall creator
(match-string 1 line) ;; name
(match-string 4 line) ;; code
(match-string 3 line) ;; file
(string-to-number (match-string 2 line))))) ;; line
- (gtags-xref--exec-sync
- gtags-xref--global
- (append args gtags-xref--output-format-options
+ (gtags-mode--exec-sync
+ gtags-mode--global
+ (append args gtags-mode--output-format-options
(unless (string-blank-p symbol)
(list (shell-quote-argument symbol))))))))
;; Interactive commands ==============================================
-(defun gtags-xref-create (root-dir)
+(defun gtags-mode-create (root-dir)
"Create a GLOBAL GTAGS file in ROOT-DIR asynchronously."
(interactive "DCreate db in directory: ")
(let ((default-directory root-dir))
- (gtags-xref--exec-async gtags-xref--gtags nil)))
+ (gtags-mode--exec-async gtags-mode--gtags nil)))
-(defun gtags-xref-update ()
+(defun gtags-mode-update ()
"Update GLOBAL project database."
(interactive)
- (if gtags-xref--project-root
- (gtags-xref--exec-async gtags-xref--global '("--update"))
+ (if gtags-mode--root
+ (gtags-mode--exec-async gtags-mode--global '("--update"))
(error "Not under a GLOBAL project")))
-(defun gtags-xref--after-save-hook ()
+(defun gtags-mode--after-save-hook ()
"After save hook to update GLOBAL database with changed data."
- (when (and buffer-file-name gtags-xref--project-root)
- (gtags-xref--exec-async
- gtags-xref--global
+ (when (and buffer-file-name gtags-mode--root)
+ (gtags-mode--exec-async
+ gtags-mode--global
(list "--single-update"
(file-name-nondirectory buffer-file-name)))))
-(defun gtags-xref--has-open-root (file)
- "Check for a known prefix for FILE in `gtags-xref--roots-list'."
+(defun gtags-mode--has-open-root (file)
+ "Check for a known prefix for FILE in `gtags-mode--roots-list'."
(let ((truename (file-truename file)))
(catch 'found
(mapc (lambda (root)
(when (string-prefix-p root truename)
(throw 'found root)))
- gtags-xref--roots-list)
+ gtags-mode--roots-list)
nil)))
-(defun gtags-xref--find-file-hook ()
- "Try to enable `gtags-xref' when opening a file.
-Check the roots and enable `gtags-xref' if the found-file is in
+(defun gtags-mode--find-file-hook ()
+ "Try to enable `gtags' when opening a file.
+Check the roots and enable `gtags' if the found-file is in
one of them."
- (when (gtags-xref--has-open-root buffer-file-name)
- (gtags-xref-mode 1)))
+ (when (gtags-mode--has-open-root buffer-file-name)
+ (gtags-mode 1)))
-(defun gtags-xref--buffers-in-root (root)
+(defun gtags-mode--buffers-in-root (root)
"Return a list of buffers which variable `buffer-file-name' is inside ROOT."
(mapcan (lambda (buf)
(when-let* ((bname (buffer-local-value 'buffer-file-name buf))
@@ -212,108 +212,108 @@ one of them."
(buffer-list)))
;; xref integration ==================================================
-(defun gtags-xref--find-symbol (args symbol)
+(defun gtags-mode--xref-find-symbol (args symbol)
"Run GNU Global to create xref input list with ARGS on SYMBOL.
Return the results as a list of xref location objects. ARGS are
any additional command line arguments to pass to GNU Global."
- (gtags-xref--filter-find-symbol
+ (gtags-mode--filter-find-symbol
args symbol
(lambda (_name code file line)
(xref-make code (xref-make-file-location
(concat (file-remote-p default-directory) file)
line 0)))))
-(defun gtags-xref-xref-backend ()
- "Gtags-Xref backend for Xref."
- (and gtags-xref--project-root 'gtags-xref))
+(defun gtags-xref-backend ()
+ "Gtags backend for Xref."
+ (and gtags-mode--root 'gtags))
-(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql
gtags-xref)))
+(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql gtags)))
"List all symbols."
- (gtags-xref--exec-sync gtags-xref--global '("--completion")))
+ (gtags-mode--exec-sync gtags-mode--global '("--completion")))
-(cl-defmethod xref-backend-definitions ((_backend (eql gtags-xref)) symbol)
+(cl-defmethod xref-backend-definitions ((_backend (eql gtags)) symbol)
"List all definitions for SYMBOL."
- (gtags-xref--find-symbol '("--definition") symbol))
+ (gtags-mode--xref-find-symbol '("--definition") symbol))
-(cl-defmethod xref-backend-references ((_backend (eql gtags-xref)) symbol)
+(cl-defmethod xref-backend-references ((_backend (eql gtags)) symbol)
"List all referenced for SYMBOL."
- (gtags-xref--find-symbol '("--reference") symbol))
+ (gtags-mode--xref-find-symbol '("--reference") symbol))
-(cl-defmethod xref-backend-apropos ((_backend (eql gtags-xref)) symbol)
+(cl-defmethod xref-backend-apropos ((_backend (eql gtags)) symbol)
"List grepped list of candidates SYMBOL."
- (gtags-xref--find-symbol '("--grep") symbol))
+ (gtags-mode--xref-find-symbol '("--grep") symbol))
;; imenu integration =================================================
-(defvar-local gtags-xref--imenu-default-function nil)
+(defvar-local gtags-mode--imenu-default-function nil)
-(defun gtags-xref--imenu-goto-function (_name line)
+(defun gtags-mode--imenu-goto-function (_name line)
"Function to goto with imenu when LINE info."
(funcall-interactively #'goto-line line))
-(defun gtags-xref-imenu-create-index-function ()
+(defun gtags-mode-imenu-create-index-function ()
"Make imenu use Global."
(when buffer-file-name
- (gtags-xref--filter-find-symbol
+ (gtags-mode--filter-find-symbol
'("--file") (file-name-nondirectory buffer-file-name)
(lambda (name _code _file line)
- (list name line #'gtags-xref--imenu-goto-function)))))
+ (list name line #'gtags-mode--imenu-goto-function)))))
;; project integration ===============================================
-(defun gtags-xref-project-backend (dir)
+(defun gtags-mode-project-backend (dir)
"Return the project for DIR as an array."
- (when-let ((root (gtags-xref--has-open-root dir)))
- (list 'gtags-xref root)))
+ (when-let ((root (gtags-mode--has-open-root dir)))
+ (list 'gtags root)))
-(cl-defmethod project-root ((project (head gtags-xref)))
+(cl-defmethod project-root ((project (head gtags)))
"Root for PROJECT."
(cadr project))
-(cl-defmethod project-files ((project (head gtags-xref)) &optional dirs)
+(cl-defmethod project-files ((project (head gtags)) &optional dirs)
"Root for PROJECT."
(let* ((root (project-root project))
(remote (file-remote-p root)))
(mapcan (lambda (dir)
(when-let* ((tdir (file-truename dir))
((string-prefix-p root tdir)))
- (gtags-xref--filter-find-symbol
+ (gtags-mode--filter-find-symbol
'("--path") (string-remove-prefix root tdir)
(lambda (_name _code file _line)
(concat remote file)))))
(or dirs (list root)))))
-(cl-defmethod project-buffers ((project (head gtags-xref)))
+(cl-defmethod project-buffers ((project (head gtags)))
"Return the list of all live buffers that belong to PROJECT."
- (gtags-xref--buffers-in-root (project-root project)))
+ (gtags-mode--buffers-in-root (project-root project)))
;;;###autoload
-(define-minor-mode gtags-xref-mode
+(define-minor-mode gtags-mode
"Use GNU Global as backend for several Emacs features in this buffer."
:global nil
- :lighter gtags-xref-lighter
+ :lighter gtags-mode-lighter
(cond
- (gtags-xref-mode
- (gtags-xref--set-connection-locals)
- (setq gtags-xref--project-root (gtags-xref--find-root))
- (add-hook 'find-file-hook #'gtags-xref--find-file-hook)
- (add-hook 'project-find-functions #'gtags-xref-project-backend)
- (add-hook 'xref-backend-functions #'gtags-xref-xref-backend nil t)
- (add-hook 'after-save-hook #'gtags-xref--after-save-hook nil t)
- (setq gtags-xref--imenu-default-function imenu-create-index-function)
- (setq imenu-create-index-function #'gtags-xref-imenu-create-index-function)
- ;; Enable the mode in all the files inside `gtags-xref--project-root'
+ (gtags-mode
+ (gtags-mode--set-connection-locals)
+ (setq gtags-mode--root (gtags-mode--find-root))
+ (add-hook 'find-file-hook #'gtags-mode--find-file-hook)
+ (add-hook 'project-find-functions #'gtags-mode-project-backend)
+ (add-hook 'xref-backend-functions #'gtags-xref-backend nil t)
+ (add-hook 'after-save-hook #'gtags-mode--after-save-hook nil t)
+ (setq gtags-mode--imenu-default-function imenu-create-index-function)
+ (setq imenu-create-index-function #'gtags-mode-imenu-create-index-function)
+ ;; Enable the mode in all the files inside `gtags-mode--root'
(when (called-interactively-p 'all)
(mapc (lambda (buff)
- (unless (buffer-local-value 'gtags-xref-mode buff)
+ (unless (buffer-local-value 'gtags-mode buff)
(with-current-buffer buff
- (gtags-xref-mode 1))))
- (gtags-xref--buffers-in-root gtags-xref--project-root))))
+ (gtags-mode 1))))
+ (gtags-mode--buffers-in-root gtags-mode--root))))
(t
- (setq gtags-xref--project-root nil)
- (remove-hook 'find-file-hook #'gtags-xref--find-file-hook)
- (remove-hook 'project-find-functions #'gtags-xref-project-backend)
- (remove-hook 'xref-backend-functions #'gtags-xref-xref-backend t)
- (remove-hook 'after-save-hook #'gtags-xref--after-save-hook t)
- (setq imenu-create-index-function gtags-xref--imenu-default-function))))
-
-(provide 'gtags-xref)
-;;; gtags-xref-mode.el ends here
+ (setq gtags-mode--root nil)
+ (remove-hook 'find-file-hook #'gtags-mode--find-file-hook)
+ (remove-hook 'project-find-functions #'gtags-mode-project-backend)
+ (remove-hook 'xref-backend-functions #'gtags-xref-backend t)
+ (remove-hook 'after-save-hook #'gtags-mode--after-save-hook t)
+ (setq imenu-create-index-function gtags-mode--imenu-default-function))))
+
+(provide 'gtags-mode)
+;;; gtags-mode.el ends here
- [elpa] externals/gtags-mode 7dc81cbae2 56/61: Small simplifies, (continued)
- [elpa] externals/gtags-mode 7dc81cbae2 56/61: Small simplifies, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 5445a63b79 21/61: Small fixes., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 33938b17e7 41/61: New function, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode d1195ca318 40/61: Use memoization function, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 65c2da145a 11/61: Reorder code a but and simplify., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 9b67043bcf 44/61: Use a workaround to pint proper information, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 2e5ecb8042 39/61: Add check on mode enable., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 19f827a1d7 15/61: Use delq instead of remove., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 688f1e8886 16/61: Break long lines., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode ea16b9d8c7 23/61: global-xref-project-backend shouldn't call global-xref--find-root., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode c2e13cc742 33/61: Use a better name gtags-mode is free.,
ELPA Syncer <=
- [elpa] externals/gtags-mode cd79d73561 26/61: Fix following Michael Albinus recommendations., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 75aef71741 19/61: Fix messages., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 13a0afbefd 31/61: Renamed to gtags-xref-mode., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 3f43b6056d 47/61: ;; Fix typo, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode ce6a4a6201 60/61: Merge pull request #1 from jangid/master, ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode f312adbbab 43/61: Use match-string-no-properties is better., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode a3b99b9aa6 25/61: Enable the mode in all the already opened buffers sharing root., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 777c51d630 53/61: Convert the mode in a global mode., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 1aaac5fead 10/61: Simplify code to so only the needed., ELPA Syncer, 2022/04/28
- [elpa] externals/gtags-mode 70b6c217d5 20/61: Add support for project.el., ELPA Syncer, 2022/04/28