From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: Search for selected tex Date: Sat, 14 Jun 2008 19:00:00 +0200 Message-ID: <87d4mk9ckv.fsf@thievol.homelinux.org> References: <4853F20B.5030802@gmail.com> <4853F593.2040009@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213462523 14839 80.91.229.12 (14 Jun 2008 16:55:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Jun 2008 16:55:23 +0000 (UTC) Cc: Lorenzo Isella , help-gnu-emacs@gnu.org To: "Lennart Borgman \(gmail\)" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 14 18:56:03 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K7Z2p-0002eo-0d for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2008 18:56:03 +0200 Original-Received: from localhost ([127.0.0.1]:50335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7Z20-0003oC-Hi for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2008 12:55:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7Z1c-0003lf-Vd for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:54:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7Z1b-0003l1-QW for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:54:48 -0400 Original-Received: from [199.232.76.173] (port=51343 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7Z1b-0003ks-Je for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:54:47 -0400 Original-Received: from fg-out-1718.google.com ([72.14.220.154]:4882) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K7Z1a-00023I-Ll for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:54:47 -0400 Original-Received: by fg-out-1718.google.com with SMTP id l26so3587619fgb.30 for ; Sat, 14 Jun 2008 09:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=6PhFsuBQcpu+dULBCJIIZ2PsAl9TeMkt1kNm3Rea7/s=; b=ujB9gh/s5hJ21tle4OTYrwxT22qj3IPZAdMeyrT1MBbkDLW4e1QfqxiuEWjSRpCDSb xZ0RhI1VLwPRvGb8PNJOod8vkYpF1dvoyupWKo0bMqjC/OiJqXEwZV9Z9cs6eXB5Sdun saK2jrmekbT27x+RLSOHNiWk1Jgy3gK9GUfB8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=TNfZipwzpslhU10rt9F0TdxjzJTicLgebFJYp1W5KzY5/R+LLnqVdfBhnEHGn+BGfx fPd1Z5cdnXPdkFEslswHwRo8h/oHf1S9j1kN28nX1gVCz7vAfC/VRlIJYckF90MIB4We woyvMQgVD8WVd/dFafA9pGtTabbCz7MGRo0o0= Original-Received: by 10.86.84.5 with SMTP id h5mr5982858fgb.58.1213462479194; Sat, 14 Jun 2008 09:54:39 -0700 (PDT) Original-Received: from thievol.homelinux.org ( [77.197.77.55]) by mx.google.com with ESMTPS id d4sm7886144fga.8.2008.06.14.09.54.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 14 Jun 2008 09:54:38 -0700 (PDT) In-Reply-To: <4853F593.2040009@gmail.com> (Lennart Borgman's message of "Sat, 14 Jun 2008 18:45:07 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54840 Archived-At: "Lennart Borgman (gmail)" 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 > > http://www.emacswiki.org/cgi-bin/wiki/SearchAtPoint > > 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: http://pgp.mit.edu