all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Negative occur
Date: Thu, 29 Nov 2007 03:44:23 -0800 (PST)	[thread overview]
Message-ID: <92d9aaa7-250c-4e3a-a573-70ac97e3612b@s12g2000prg.googlegroups.com> (raw)
In-Reply-To: 205e9241-c824-46b0-af01-26ad3fcd0d97@y20g2000hsy.googlegroups.com

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)

  parent reply	other threads:[~2007-11-29 11:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-28 10:15 Negative occur spamfilteraccount
2007-11-28 10:21 ` David Kastrup
2007-11-28 10:53   ` spamfilteraccount
2007-11-28 17:03     ` Drew Adams
2007-11-29 11:44     ` spamfilteraccount [this message]
     [not found] <mailman.4263.1196269422.18990.help-gnu-emacs@gnu.org>
2007-11-28 18:54 ` Ted Zlatanov
2007-11-28 22:52   ` Drew Adams
     [not found] <mailman.4275.1196290389.18990.help-gnu-emacs@gnu.org>
2007-11-29 15:58 ` Ted Zlatanov
2007-11-29 17:25   ` Drew Adams
     [not found] <mailman.4315.1196357177.18990.help-gnu-emacs@gnu.org>
2007-11-29 18:27 ` spamfilteraccount
2007-12-05 17:44   ` Mathias Dahl

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

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

  git send-email \
    --in-reply-to=92d9aaa7-250c-4e3a-a573-70ac97e3612b@s12g2000prg.googlegroups.com \
    --to=spamfilteraccount@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.
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.