From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christoph Scholtes Newsgroups: gmane.emacs.devel Subject: isearch-yank-word-at-point (was Re: Key map translations) Date: Wed, 13 Apr 2011 17:06:01 -0600 Message-ID: <4DA62C59.4040707@gmail.com> References: <4DA3AB97.4070805@gmail.com> <87tye4ywdj.fsf@gmail.com> <4DA50369.8080103@gmail.com> <87mxjuzwta.fsf@gmail.com> <4DA51578.4010301@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1302735988 22068 80.91.229.12 (13 Apr 2011 23:06:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 13 Apr 2011 23:06:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Deniz Dogan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 14 01:06:25 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QA98g-0004uj-7Z for ged-emacs-devel@m.gmane.org; Thu, 14 Apr 2011 01:06:22 +0200 Original-Received: from localhost ([::1]:37738 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA98d-0001TE-CX for ged-emacs-devel@m.gmane.org; Wed, 13 Apr 2011 19:06:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:51718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA98a-0001T8-7O for emacs-devel@gnu.org; Wed, 13 Apr 2011 19:06:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QA98Y-00047R-Vs for emacs-devel@gnu.org; Wed, 13 Apr 2011 19:06:16 -0400 Original-Received: from mail-gw0-f41.google.com ([74.125.83.41]:59523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA98Y-00047G-Nt for emacs-devel@gnu.org; Wed, 13 Apr 2011 19:06:14 -0400 Original-Received: by gwaa12 with SMTP id a12so602748gwa.0 for ; Wed, 13 Apr 2011 16:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=pn6Bt2ICMigOl9FYyUuAONMKlblfTB/ljc6WEdBNzxg=; b=lvd5qsSod3lFbuDp6jIiYdS/ofDgCljSve2AVFEcAB4yvErXCV9qa4s0Odzb8rdDJS 4S3vsgFqlIkUNfLoZ9sz0Jq9V2oiSOMjIhtNSTVXMfQIWTvC5qqkL7dG0EjuzVCBLoiK xUx7SH3C4GuxJ+OhWl8cGqqGE8m/zsiExCIAY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=Qxz4dgSTi0m0fxSzNI8lKzWvTWS5bGFMOjeyi51X8LPC1QJK4UDr3lNuf2sxKuPbj/ sdJC2eCJM28tkd1YUIgbRFU3CFN76RetyHl9Iaw/aZFUJs+Lj7M2C34mUZwkbFfB0Ehp Sp73mlPlTUNY0OE6fZ6AaJLwCu9v02WDF4KbA= Original-Received: by 10.150.240.8 with SMTP id n8mr1050786ybh.24.1302735973900; Wed, 13 Apr 2011 16:06:13 -0700 (PDT) Original-Received: from [192.168.1.2] (70-59-6-97.hlrn.qwest.net [70.59.6.97]) by mx.google.com with ESMTPS id r18sm555577yba.26.2011.04.13.16.06.09 (version=SSLv3 cipher=OTHER); Wed, 13 Apr 2011 16:06:12 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138467 Archived-At: On 4/13/2011 1:07 AM, Deniz Dogan wrote: > This is something I've been wanting for a long time but never really > realized it. Is there really nothing similar in isearch already? Maybe > we could add it? I reworked my function a little and the interface is slightly different. You press `C-s' to enter isearch mode and then `C-a' to select the entire word at point, much like `C-w' would select the word from point on. `Word' is in this case defined as a sequence of word and symbol constituents. Here is the code: (defun isearch-yank-word-at-point () "Pull word at point into the search string." (interactive) ;; Only yank if point is on a word constituent or ;; symbol constituent per the syntax table. (when (or (= (char-syntax (or (char-after) 0)) ?w) (= (char-syntax (or (char-after) 0)) ?_)) ;; If part of the string has been yanked to the search string ;; already, unwind the isearch state stack to the beginning to ;; start over. (while (not (string= isearch-string "")) (isearch-pop-state)) ;; Go to beginning of word at point (skip-syntax-backward "w_") ;; and yank entire word into search string. (isearch-yank-internal (lambda () (skip-syntax-forward "w_") (point))))) I bind the command as follows: (define-key isearch-mode-map (kbd "C-a") 'isearch-yank-word-at-point) Feedback welcome. I would be happy to add this to isearch.el if people find it useful. Christoph