[Top][All Lists]

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

Re: Search for selected tex

From: Thierry Volpiatto
Subject: Re: Search for selected tex
Date: Sat, 14 Jun 2008 19:00:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Lennart Borgman (gmail)" <address@hidden> writes:

> Lorenzo Isella wrote:
>> Dear All,
>> I would like to be able to select some text with C-space and then
>> look for it inside the buffer.
>> I found some functions online which I modified to get:
>> ;; a function to search the selected text
>> (defun my-search-forward (begin end)
>>  (interactive (list (point) (mark)))
>>  (let ((text (filter-buffer-substring begin end nil t)))
>>    (goto-char (max begin end))
>>    (let ((found-pos (search-forward text nil t)))
>>      (if (not found-pos)
>>          (progn
>>            (goto-char begin)
>>            (error "not found"))
>>          (progn
>>            (goto-char found-pos)
>>            (set-mark (- found-pos (length text))))))))
>> (define-key global-map [(control q )] 'my-search-forward)
>> It is almost there but not yet...
>> If I highlight some text, I can look for it with C-q, but once at
>> the end of the buffer, it stops searching (whereas I would like it
>> to search from the beginning of the buffer).
>> If then I move to the beginning of the buffer, not everything above
>> my last position is selected, but also the function loses memory of
>> what I was looking for...
>> Anybody can give me some help? Apologies if there is already and
>> emacs command for that, but my online search was not fruitful.
>> Cheers
> There is some code for similar wishes in

You can also use isearch-forward like that:
put the point at begining of text and then hit C-s C-w C-w C-w ....
until you are at the end of text and then C-s C-s ...etc...
A + Thierry
Pub key:

reply via email to

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