[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 05/09: Remove side-effect from ggtags-with-process-environment
From: |
Leo Liu |
Subject: |
[elpa] 05/09: Remove side-effect from ggtags-with-process-environment |
Date: |
Tue, 18 Feb 2014 02:56:16 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 493a7a3cd5224e61cece7db5d382aabd5879d7e5
Author: Leo Liu <address@hidden>
Date: Sat Feb 15 12:57:07 2014 +0800
Remove side-effect from ggtags-with-process-environment
Make ggtags-ensure-project generate an error if project not found.
---
ggtags.el | 44 +++++++++++++++++++++++++-------------------
1 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 1b64973..94e9374 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -244,22 +244,6 @@ properly update `ggtags-mode-map'."
(error "No global buffer found"))
(with-current-buffer ggtags-global-last-buffer ,@body)))
-(defmacro ggtags-with-process-environment (&rest body)
- (declare (debug t))
- (let ((gtagsroot (make-symbol "-gtagsroot-")))
- `(let* ((,gtagsroot (when (ggtags-find-project)
- (directory-file-name (ggtags-current-project-root))))
- (process-environment
- (append (let ((process-environment process-environment))
- (and ,gtagsroot (setenv "GTAGSROOT" ,gtagsroot))
- (mapcar #'substitute-env-vars
ggtags-process-environment))
- process-environment
- (and ,gtagsroot (list (concat "GTAGSROOT=" ,gtagsroot)))
- (and (ggtags-find-project)
- (not (ggtags-project-has-rtags
(ggtags-find-project)))
- (list "GTAGSLABEL=ctags")))))
- ,@body)))
-
(defun ggtags-list-of-string-p (xs)
"Return non-nil if XS is a list of strings."
(if (null xs)
@@ -347,7 +331,7 @@ properly update `ggtags-mode-map'."
;; let's help it out.
(when-let (gtags (locate-dominating-file
default-directory "GTAGS"))
- (file-truename gtags)))))
+ (file-truename gtags)))))
(setq ggtags-project
(and root (or (gethash root ggtags-projects)
(ggtags-make-project root))))
@@ -365,7 +349,9 @@ properly update `ggtags-mode-map'."
(when (or (yes-or-no-p "File GTAGS not found; run gtags? ")
(user-error "Aborted"))
(call-interactively #'ggtags-create-tags)
- (ggtags-find-project))))
+ ;; Need checking because `ggtags-create-tags' can create tags
+ ;; in any directory.
+ (ggtags-check-project))))
(defun ggtags-save-project-settings (&optional noconfirm)
"Save Gnu Global's specific environment variables."
@@ -420,6 +406,25 @@ properly update `ggtags-mode-map'."
(message "Project read-only-mode is %s" (if val "on" "off")))
val))
+(defmacro ggtags-with-process-environment (&rest body)
+ (declare (debug t))
+ (let ((gtagsroot (make-symbol "-gtagsroot-"))
+ (ggproj (make-symbol "-ggtags-project-")))
+ `(let* ((,ggproj ggtags-project)
+ (,gtagsroot (when (ggtags-find-project)
+ (directory-file-name (ggtags-current-project-root))))
+ (process-environment
+ (append (let ((process-environment process-environment))
+ (and ,gtagsroot (setenv "GTAGSROOT" ,gtagsroot))
+ (mapcar #'substitute-env-vars
ggtags-process-environment))
+ process-environment
+ (and ,gtagsroot (list (concat "GTAGSROOT=" ,gtagsroot)))
+ (and (ggtags-find-project)
+ (not (ggtags-project-has-rtags
(ggtags-find-project)))
+ (list "GTAGSLABEL=ctags")))))
+ (unwind-protect (save-current-buffer ,@body)
+ (setq ggtags-project ,ggproj)))))
+
(defun ggtags-create-tags (root)
"Run `gtags' in directory ROOT to create tag files."
(interactive "DRoot directory: ")
@@ -565,6 +570,7 @@ non-nil."
If point is at a definition tag, find references, and vice versa.
With a prefix arg (non-nil DEFINITION) always find definitions."
(interactive (list (ggtags-read-tag) current-prefix-arg))
+ (ggtags-check-project) ; for `ggtags-current-project-root' below
(if (or definition
(not buffer-file-name)
(and (ggtags-find-project)
@@ -673,7 +679,7 @@ Global and Emacs."
(defun ggtags-delete-tag-files ()
"Delete the tag files generated by gtags."
- (interactive)
+ (interactive (ignore (ggtags-check-project)))
(when (ggtags-current-project-root)
(let ((files (directory-files
(ggtags-current-project-root) t
- [elpa] branch master updated (29cc746 -> 2e6b4f6), Leo Liu, 2014/02/17
- [elpa] 02/09: Fix misuse of display-buffer-overriding-action, Leo Liu, 2014/02/17
- [elpa] 01/09: Force ggtags-update-tags when called interactively, Leo Liu, 2014/02/17
- [elpa] 03/09: Fix #31: Avoid `-d' switch for compatibility, Leo Liu, 2014/02/17
- [elpa] 06/09: Fix last change, Leo Liu, 2014/02/17
- [elpa] 04/09: Expire project info in ggtags-update-tags, Leo Liu, 2014/02/17
- [elpa] 05/09: Remove side-effect from ggtags-with-process-environment,
Leo Liu <=
- [elpa] 07/09: Rename ggtags-with-process-environment, Leo Liu, 2014/02/17
- [elpa] 08/09: Fix #32: handle upstream change in query-replace-read-args, Leo Liu, 2014/02/17
- [elpa] 09/09: Merge remote-tracking branch 'ggtags/master', Leo Liu, 2014/02/17