Skip to content

Instantly share code, notes, and snippets.

@mechairoi
Created December 6, 2010 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechairoi/730486 to your computer and use it in GitHub Desktop.
Save mechairoi/730486 to your computer and use it in GitHub Desktop.
anything-c-source-gtags-select with GTAGSROOT
(require 'anything-gtags)
(defmacro my-let-env (environments &rest body)
`(let ((process-environment process-environment))
,@(mapcar (lambda (env) `(setenv ,@env)) environments)
(progn ,@body)))
(defun anything-c-source-gtags-select-with-root (name gtagsroot)
(lexical-let ((gtagsroot (expand-file-name gtagsroot)))
`((name . ,name)
(init
. ,(lambda ()
(my-let-env
(("GTAGSROOT" gtagsroot))
(call-process-shell-command
"global -c" nil (anything-candidate-buffer 'global)))))
(candidates-in-buffer)
(action
("Goto the location"
. ,(lambda (candidate)
(my-let-env
(("GTAGSROOT" gtagsroot))
(gtags-push-context)
(gtags-goto-tag candidate ""))))
("Goto the location (other-window)"
. ,(lambda (candidate)
(my-let-env
(("GTAGSROOT" gtagsroot))
(gtags-push-context)
(gtags-goto-tag candidate "" t))))
("Move to the referenced point"
. ,(lambda (candidate)
(my-let-env
(("GTAGSROOT" gtagsroot))
(gtags-push-context)
(gtags-goto-tag candidate "r"))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment