leoliu pushed a commit to branch master
in repository elpa.
commit 597c3297caeaf30d03055c2cb782473104dbc158
Author: Leo Liu <[email protected]>
Date: Sat Feb 22 11:25:27 2014 +0800
Fix #33: support running ggtags on remote hosts (via tramp)
Tighten file name checking in ggtags-delete-tag-files.
Mention `enable-remote-dir-locals' in ggtags-process-environment.
---
ggtags.el | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 0938684..df4cf00 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -114,7 +114,9 @@ automatically switches to 'global --single-update'."
Elements are run through `substitute-env-vars' before use.
GTAGSROOT will always be expanded to current project root
directory. This is intended for project-wise ggtags-specific
-process environment settings."
+process environment settings. Note on remote host (e.g. tramp)
+directory local variables is not enabled by default per
+`enable-remote-dir-locals' (which see)."
:safe 'ggtags-list-of-string-p
:type '(repeat string)
:group 'ggtags)
@@ -320,8 +322,9 @@ properly update `ggtags-mode-map'."
project)
(setq ggtags-project-root
(or (ignore-errors (file-name-as-directory
- ;; Resolves symbolic links
- (ggtags-process-string "global" "-pr")))
+ (concat (file-remote-p default-directory)
+ ;; Resolves symbolic links
+ (ggtags-process-string "global"
"-pr"))))
;; 'global -pr' resolves symlinks before checking
;; the GTAGS file which could cause issues such as
;; https://github.com/leoliu/ggtags/issues/22, so
@@ -425,7 +428,8 @@ properly update `ggtags-mode-map'."
(defun ggtags-get-libpath ()
(when-let (path (ggtags-with-current-project (getenv "GTAGSLIBPATH")))
- (split-string path (regexp-quote path-separator) t)))
+ (mapcar (apply-partially #'concat (file-remote-p default-directory))
+ (split-string path (regexp-quote path-separator) t))))
(defun ggtags-create-tags (root)
"Run `gtags' in directory ROOT to create tag files."
@@ -689,11 +693,13 @@ Global and Emacs."
"Delete the tag files generated by gtags."
(interactive (ignore (ggtags-check-project)))
(when (ggtags-current-project-root)
- (let ((files (directory-files
- (ggtags-current-project-root) t
- (concat "\\`" (regexp-opt '("GPATH" "GRTAGS" "GTAGS" "ID"))
- "\\'")))
- (buffer "*GTags File List*"))
+ (let* ((re (concat "\\`" (regexp-opt '("GPATH" "GRTAGS" "GTAGS" "ID"))
"\\'"))
+ (files (loop for file in (directory-files
(ggtags-current-project-root) t re)
+ ;; Don't trust `directory-files'.
+ when (let ((case-fold-search nil))
+ (string-match-p re (file-name-nondirectory
file)))
+ collect file))
+ (buffer "*GTags File List*"))
(or files (user-error "No tag files found"))
(with-output-to-temp-buffer buffer
(princ (mapconcat #'identity files "\n")))
@@ -702,7 +708,7 @@ Global and Emacs."
(progn
(fit-window-to-buffer win)
(when (yes-or-no-p "Remove GNU Global tag files? ")
- (mapc #'delete-file files)
+ (with-demoted-errors (mapc #'delete-file files))
(remhash (ggtags-current-project-root) ggtags-projects)
(and (overlayp ggtags-highlight-tag-overlay)
(delete-overlay ggtags-highlight-tag-overlay))))