[Top][All Lists]

[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: Sat, 10 Jul 2021 01:20:14 +0000

> So what i was missing was an easy way to search to
> the end of the next line with 80 or more characters.

There are a few ways to do what you request.  Here are a couple.

1. You can make use of command `goto-long-line' from library
   `misc-cmds.el'.  That prompts you for a line length and
   then goes to the next line that's at least that long.

   To do that during Isearch for lines at least 80 chars,
   define a command such as this, which uses `goto-long-line':

   (defun goto-line>79-chars ()
     "Go to next line at least 80 chars long."
     (goto-long-line 80 t))

   Then bind that command to a key in `isearch-mode-map'.
   Use it during Isearch anytime to go to the next line
   that's 80 chars or longer.

   (define-key isearch-mode-map (kbd "C-e") 'goto-line>79-chars)

   Library `misc-cmds.el' is here:

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

   ;; (setq ORIG-isearch-filter-predicate  isearch-filter-predicate)
   (setq isearch-filter-predicate  'line>79-p)
   ;; (setq isearch-filter-predicate  ORIG-isearch-filter-predicate)

(You can use the commented out code to get back to the default filter.)

Note that you can't just regexp-search for `$', because
`isearch-filter-predicate' isn't used for empty matches.

reply via email to

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