help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tweaking grep-regexp-alist


From: troelskn
Subject: Tweaking grep-regexp-alist
Date: Fri, 27 Jul 2007 05:13:57 -0700
User-agent: G2/1.0

Hi

I have an external program, which analyses a file, and returns a list
of line-numbers for matches. I've written a wrapper-function in elisp,
which runs the program and loads the result into a buffer, and sets it
in grep-mode. So far, so good, but the format of the results doesn't
follow the standard grep. I nailed it down to modifying grep-regexp-
alist, but there is one thing I can't figure out. Since the results
are all from one file, there is no filename listed on each line, only
a linenumber. So I need to make grep always jump to the same file
(Which I know at the time, I create the buffer, and put it into grep-
mode). Any ideas?

Just in case, I didn't explain myself clearly, here's the code, I have
already:

(defun php-mode-list-tokens ()
  "Lists tokens for a PHP-file"
  (interactive)
  (let* ((buffername "*php-mode-tokens*")
        (filename (buffer-file-name)))
    (when (get-buffer buffername)
      (kill-buffer buffername))
    (save-excursion
      (pop-to-buffer buffername)
      (shell-command (format "php %s %s"
                             (shell-quote-argument "~/scripts/
tokens.php")
                             (shell-quote-argument filename))
buffername buffername)
      (grep-mode)
      (setq grep-regexp-alist
            '(("^\\([0-9]+\\)[ ]+" nil 1))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]