all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Searching text
@ 2024-09-03  7:14 Heime
  2024-09-03 12:44 ` Eli Zaretskii
  2024-09-03 23:39 ` Rudolf Adamkovič
  0 siblings, 2 replies; 3+ messages in thread
From: Heime @ 2024-09-03  7:14 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I need to search for phrases like 'others contend' within a buffer, even
when they span across multiple lines. What steps should I take to
achieve this with an elisp function ? 

For example, consider the following text where the phrase 'sees the human 
mind' is split between two lines, yet I need to match it in its entirety.

Theories of how the mind/brain works have been dominated
for centuries by two opposing views. One, rationalism, sees the
human mind as coming into this world more or less fully formed -
preprogrammed, in modern terms. The other, empiricism, sees the
mind of the newborn as largely unstructured, a blank slate.

 





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

* Re: Searching text
  2024-09-03  7:14 Searching text Heime
@ 2024-09-03 12:44 ` Eli Zaretskii
  2024-09-03 23:39 ` Rudolf Adamkovič
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2024-09-03 12:44 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 03 Sep 2024 07:14:42 +0000
> From: Heime <heimeborgia@protonmail.com>
> 
> I need to search for phrases like 'others contend' within a buffer, even
> when they span across multiple lines. What steps should I take to
> achieve this with an elisp function ? 
> 
> For example, consider the following text where the phrase 'sees the human 
> mind' is split between two lines, yet I need to match it in its entirety.

This is already supported, but you need to let-bind
search-whitespace-regexp to a value that matches newlines.  See the
description in the node "Lax Search" in the Emacs user manual.



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

* Re: Searching text
  2024-09-03  7:14 Searching text Heime
  2024-09-03 12:44 ` Eli Zaretskii
@ 2024-09-03 23:39 ` Rudolf Adamkovič
  1 sibling, 0 replies; 3+ messages in thread
From: Rudolf Adamkovič @ 2024-09-03 23:39 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> I need to search for phrases like 'others contend' within a buffer, even
> when they span across multiple lines.

Me too.  From my Emacs config:

  Search across spaces, tabs, and newlines.

  #+BEGIN_SRC emacs-lisp :results none
  (with-eval-after-load 'isearch
    (setq isearch-lax-whitespace t
          isearch-regexp-lax-whitespace t
          search-whitespace-regexp "[ \t\r\n]+"))
  #+END_SRC

Works well.  Enjoy!

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."  --- Alfred North
Whitehead, 1861-1947

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org



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

end of thread, other threads:[~2024-09-03 23:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03  7:14 Searching text Heime
2024-09-03 12:44 ` Eli Zaretskii
2024-09-03 23:39 ` Rudolf Adamkovič

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.