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

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

RE: [External] : How can i search for lines which wrap?


From: Drew Adams
Subject: RE: [External] : How can i search for lines which wrap?
Date: Mon, 12 Jul 2021 17:16:09 +0000

I said:

> 2. You can set `isearch-filter-predicate' to a function that
>    returns non-nil only for a single-line search hit that ends
>    past column 79.  Then regexp-search for a regexp such as `.$'.
> 
>    (defun line>79-p (beg end)
>      "Return non-nil if END is past column 79."
>      (save-excursion (goto-char end) (> (current-column) 79)))
>
> Note that you can't just regexp-search for `$', because
> `isearch-filter-predicate' isn't used for empty matches.

The unnecessary restriction of that last Note is no
longer true.  I've fixed Isearch+ so that filter
predicates can now be used also for empty matches
(such as regexp-searching for just `$').  And I filed
bug #49534, for vanilla Emacs to do likewise.

For example, with the above function `line>79-p', you
can use this command to search for lines of 80 chars
or longer using just `$' (no need to use `.$' etc.):

 (defun foo ()
   (interactive)
   (let ((isearch-filter-predicate  #'line>79-p))
     (isearch-forward 4)))

___

Of course, when a match is empty, as they all are in
this case, it can be difficult to see just where the
current search hit is, as you bounce around among hits.

For that, you can add a predefined filter predicate
named `crosshairs' (if you have library `crosshairs.el').
To do that, just use `C-z &' during Isearch, and enter
`crosshairs' (with completion) at the prompt.

That highlights the line and column of point at each
search hit.

`C-z &' is an example of a dynamic filtering key.
Dynamic filtering let you add, remove, and combine
Isearch filter predicates on the fly.  More info:

https://www.emacswiki.org/emacs/DynamicIsearchFiltering

___

More about library `crosshairs.el':

https://www.emacswiki.org/emacs/CrosshairHighlighting

reply via email to

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