Re: Using a newline character in the newstring in M-x replace-regexp
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Using a newline character in the newstring in M-x replace-regexp         

Group: gnu.emacs.help · Group Profile
Author: Kevin Rodgers
Date: Sep 10, 2008 22:12

David Combs wrote:
> In article <804f53f5-8387-4b20-a4d5-2a2b4708d529@k30g2000hse.googlegroups.com>,
> harven wrote:
>>> It works for me and should work in any emacs 22. For interactive use,
>>> i think C-q C-j is actually the only way to insert newlines.
>> C-o or C-012 RET also work for a query-replace.
>> C-o does not work by default for an incremental search.
>> The following code adds this shortcut to the incremental commands.
>>
>> (define-key isearch-mode-map "\C-o"
>> (lambda () (interactive)
>> (isearch-process-search-char ?\n)))
>
> Looks nifty -- but what does it do?
>
> 1: what's the purpose of defining C-o?

It's shorter and perhaps easier to remember than C-q C-j.
> 2: what does that function/lambda-expr actually *do*
> when it gets called>
> (like, how does it get a newline inserted?)
>
> Unfortunately:
>
> | isearch-process-search-char is a compiled Lisp function in `isearch'.
> | (isearch-process-search-char CHAR)
> |
> | Not documented.
> |
> | [back]

If you follow the link to isearch, you'll see its definition, which has
this comment:

;; Append the char to the search string, update the message and
re-search.

--
Kevin Rodgers
Denver, Colorado, USA
no comments
diggit! del.icio.us! reddit!