summaryrefslogtreecommitdiffstats
path: root/gid.el
blob: 01f855fc48396ff4cddd4be04f4035a09217e555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;;; put this in your GNU emacs startup file  '~/.emacs' .
;;; or byte-compile it and autoload from somewhere else.

(require 'compile)
(provide 'gid)

(defvar gid-command "gid" "The command run by the gid function.")

(defun gid (args)
  "Run gid, with user-specified ARGS, and collect output in a buffer.
While gid runs asynchronously, you can use the \\[next-error] command to
find the text that gid hits refer to. The command actually run is
defined by the gid-command variable."
  (interactive (list (read-input
     (concat "Run " gid-command " (with args): ") (word-around-point))))
  (let (compile-command
	(compilation-error-regexp-alist grep-regexp-alist)
	(compilation-buffer-name-function (lambda (mode)
					    (concat "*" gid-command " " args "*"))))
    ;; For portability to v19, use compile rather than compile-internal.
    (compile (concat gid-command " " args))))

(defun word-around-point ()
  "Return the word around the point as a string."
  (save-excursion
    (if (not (eobp))
	(forward-char 1))
    (forward-word -1)
    (forward-word 1)
    (forward-sexp -1)
    (buffer-substring (point) (progn
				(forward-sexp 1)
				(point)))))