all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tweaking grep-regexp-alist
@ 2007-07-27 12:13 troelskn
  2007-07-28 13:23 ` Peter Dyballa
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: troelskn @ 2007-07-27 12:13 UTC (permalink / raw)
  To: help-gnu-emacs

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))))))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking grep-regexp-alist
  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>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Dyballa @ 2007-07-28 13:23 UTC (permalink / raw)
  To: troelskn; +Cc: help-gnu-emacs


Am 27.07.2007 um 14:13 schrieb troelskn:

> Any ideas?

I actually did not understand why your grep jumps (of joy?). If the  
problem is the missing file name, then serve grep two file names:  
that of the file to search and that of /dev/null!

--
Greetings

   Pete

A blizzard is when it snows sideways.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking grep-regexp-alist
       [not found] ` <mailman.4079.1185629031.32220.help-gnu-emacs@gnu.org>
@ 2007-07-28 15:56   ` troelskn
  0 siblings, 0 replies; 5+ messages in thread
From: troelskn @ 2007-07-28 15:56 UTC (permalink / raw)
  To: help-gnu-emacs

On Jul 28, 3:23 pm, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
> Am 27.07.2007 um 14:13 schrieb troelskn:
>
> > Any ideas?
>
> I actually did not understand why your grep jumps (of joy?). If the  
> problem is the missing file name, then serve grep two file names:  
> that of the file to search and that of /dev/null!

I'm not using grep -- I'm using a different tool, but putting the
buffer into grep-mode

--
troels

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking grep-regexp-alist
  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-31  6:07 ` Kevin Rodgers
       [not found] ` <mailman.4150.1185862211.32220.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2007-07-31  6:07 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
Kevin Rodgers
Denver, Colorado, USA

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tweaking grep-regexp-alist
       [not found] ` <mailman.4150.1185862211.32220.help-gnu-emacs@gnu.org>
@ 2007-08-01 21:42   ` troelskn
  0 siblings, 0 replies; 5+ messages in thread
From: troelskn @ 2007-08-01 21:42 UTC (permalink / raw)
  To: help-gnu-emacs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-01 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.