unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: troelskn <troelskn@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Tweaking grep-regexp-alist
Date: Wed, 01 Aug 2007 21:42:45 -0000	[thread overview]
Message-ID: <1186004565.385601.258600@w3g2000hsg.googlegroups.com> (raw)
In-Reply-To: <mailman.4150.1185862211.32220.help-gnu-emacs@gnu.org>

On Jul 31, 8:07 am, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
> troelskn wrote:
> > 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))))))
>
> Change your PHP script to include the file name in its output, or
> pipe its output through sed to insert the file name into the output.

That would obviously work, but I'd rather not, since it would make the
output unreadable.

I basically need to replace the following prompt with a default value:
Find this grep hit in (default *unknown*):

I have tried to dissect the code of grep.el, but to no avail.

      parent reply	other threads:[~2007-08-01 21:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27 12:13 Tweaking grep-regexp-alist troelskn
2007-07-28 13:23 ` Peter Dyballa
     [not found] ` <mailman.4079.1185629031.32220.help-gnu-emacs@gnu.org>
2007-07-28 15:56   ` troelskn
2007-07-31  6:07 ` Kevin Rodgers
     [not found] ` <mailman.4150.1185862211.32220.help-gnu-emacs@gnu.org>
2007-08-01 21:42   ` troelskn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1186004565.385601.258600@w3g2000hsg.googlegroups.com \
    --to=troelskn@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).