From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: isearch and yank word doubt Date: Fri, 31 May 2013 09:32:34 +0200 Organization: Sebastien Vauban Message-ID: <86k3mf61v1.fsf@somewhere.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369985789 22482 80.91.229.3 (31 May 2013 07:36:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 May 2013 07:36:29 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Fri May 31 09:36:30 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UiJsz-0006ce-MD for geh-help-gnu-emacs@m.gmane.org; Fri, 31 May 2013 09:36:29 +0200 Original-Received: from localhost ([::1]:33047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiJsz-0006Fm-BK for geh-help-gnu-emacs@m.gmane.org; Fri, 31 May 2013 03:36:29 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Injection-Info: mx05.eternal-september.org; posting-host="56267169612f95d5ad2eeba965a549c1"; logging-data="21754"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX19a2f/k/sm/tQKecbTFu0do" User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:7m3MVE0++NdqHNgOqVtnl6fvzxY= sha1:5GiiQ3CqiWQeQ9fqexGk6n1GtW0= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:198933 X-Mailman-Approved-At: Fri, 31 May 2013 03:35:54 -0400 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:91199 Archived-At: Hi Kevin, Kevin Rodgers wrote: > On 5/30/13 12:42 AM, Luca Ferrari wrote: >> Hi all, >> according to the manual the C-s C-w yanks the next word the cursor is >> on as the string to search with isearch. Often I found myself having >> the cursor in the middle of a word, so I have to go back to the >> beginning and then do the yank, is there a better way to instrument >> C-s C-w to get the word the cursor is in? > > I like it! > > (defun isearch-yank-word-at-point () > "Pull the word around point from buffer into search string." > (interactive) > ;; see isearch-yank-word-or-char and isearch-yank-internal: > (isearch-yank-string > (save-excursion > (when (and (not isearch-forward) isearch-other-end) > (goto-char isearch-other-end)) > (when (= (char-syntax (or (char-after (1- (point))) 0)) ?w) > (forward-word -1)) > (buffer-substring-no-properties (point) > (progn (forward-word 1) (point)))))) > > (define-key isearch-mode-map "\C-w" 'isearch-yank-word-at-point) One detail I don't like in the above: when C-s C-w'ing, it directly jumps to the next occurrence of the searched string. I find it'd be better if it'd stay on the current word, highlighting it completely. Best regards, Seb -- Sebastien Vauban