[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative occur
From: |
address@hidden |
Subject: |
Re: Negative occur |
Date: |
Thu, 29 Nov 2007 03:44:23 -0800 (PST) |
User-agent: |
G2/1.0 |
On Nov 28, 11:53 am, "spamfilteracco...@gmail.com"
<spamfilteracco...@gmail.com> wrote:
> On Nov 28, 11:21 am, David Kastrup <d...@gnu.org> wrote:
>
> > "spamfilteracco...@gmail.com" <spamfilteracco...@gmail.com> writes:
> > > Is there a command like occur which shows non-matching lines? It would
> > > come in handy for me for the work I'm doing.
>
> > > It's a useful a feature and not hard to implement, so I'm sure it's
> > > already in Emacs in some form only I'm overlooking it.
>
> > You could try running "occur" with the pattern "^" (which matches
> > every line), then prune the results with M-x delete-matching-lines RET
>
> Yep, there are workarounds. :)
Here's a naive implementation of noccur I made for myself:
(defun noccur ()
(interactive)
(let ((orig-re-search-forward (symbol-function 're-search-forward)))
(fset 're-search-forward 'noccur-re-search-forward)
(unwind-protect
(call-interactively 'occur)
(fset 're-search-forward orig-re-search-forward))))
(defun noccur-re-search-forward (regexp bound noerror &optional count)
(unless (eq (aref regexp 0) ?^)
(setq regexp (concat ".*" regexp)))
(while (and (not (eobp))
(looking-at regexp))
(forward-line 1))
(if (eobp)
nil
(set-match-data (list (line-beginning-position)
(line-end-position)))
(line-end-position)))
(provide 'nocccur)