From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.devel Subject: Re: isearch-yank-word-at-point (was Re: Key map translations) Date: Wed, 27 Apr 2011 23:05:34 +0530 Message-ID: <81zknbegwp.fsf@gmail.com> References: <4DA3AB97.4070805@gmail.com> <87tye4ywdj.fsf@gmail.com> <4DA50369.8080103@gmail.com> <87mxjuzwta.fsf@gmail.com> <4DA51578.4010301@gmail.com> <4DA62C59.4040707@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1303925765 23351 80.91.229.12 (27 Apr 2011 17:36:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 27 Apr 2011 17:36:05 +0000 (UTC) Cc: emacs-devel@gnu.org, Deniz Dogan To: Christoph Scholtes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 27 19:36:01 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 1QF8ed-0005VE-O6 for ged-emacs-devel@m.gmane.org; Wed, 27 Apr 2011 19:36:00 +0200 Original-Received: from localhost ([::1]:45042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF8ed-0002hr-6t for ged-emacs-devel@m.gmane.org; Wed, 27 Apr 2011 13:35:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF8ea-0002ha-Np for emacs-devel@gnu.org; Wed, 27 Apr 2011 13:35:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QF8eZ-0005tF-Pt for emacs-devel@gnu.org; Wed, 27 Apr 2011 13:35:56 -0400 Original-Received: from mail-pz0-f41.google.com ([209.85.210.41]:45439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF8eZ-0005t8-LC for emacs-devel@gnu.org; Wed, 27 Apr 2011 13:35:55 -0400 Original-Received: by pzk4 with SMTP id 4so1655603pzk.0 for ; Wed, 27 Apr 2011 10:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:mail-followup-to :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=rgapD8RQDcsR26I25qkcnqAVlcVBXyXH0ETtZ3dgdqY=; b=Ehe6h4JU6Fxd32CcOsHXCtWmf6CWQaIsTv09O8FOp58Bpo0e9ueu7um8KjZ4XM/Vij KG7hio7TTiqN8g8dbAGz0F8PsHWQcakzz1+By0tM7iMYTwOm+ylbUlNJwXLNFiL0P3+Z kmi4nJuDE+rMiqzTVvC5/dbDa87hoPy0X7000= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; b=dcvD2O6/LcZ+40ZcM/l6c5P4GbYEai/X7FbSrpOiabkh7E4GAwqOXZmEFpQBPrLoMJ 0nwTsDXttwTATbBpULNKVWp7TiunZDTg/YyqYC+FoG4pKaiMA976rH4rFlRedM79lwJP V5vW+FDd9gcjzIXmqE5vNnupgBaX6FafzSYr4= Original-Received: by 10.68.7.230 with SMTP id m6mr2615183pba.9.1303925754094; Wed, 27 Apr 2011 10:35:54 -0700 (PDT) Original-Received: from JAMBU-NETBOOK ([115.184.40.41]) by mx.google.com with ESMTPS id k2sm675830pbj.47.2011.04.27.10.35.49 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Apr 2011 10:35:52 -0700 (PDT) Mail-Followup-To: Christoph Scholtes , Deniz Dogan , emacs-devel@gnu.org In-Reply-To: <4DA62C59.4040707@gmail.com> (Christoph Scholtes's message of "Wed, 13 Apr 2011 17:06:01 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.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:138851 Archived-At: Christoph Scholtes writes: > 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. I usually do C-s (C-w)+ while searching for symbols. This is what I cooked up: (define-key isearch-mode-map "\C-_" 'isearch-yank-symbol) (defun isearch-yank-symbol () (interactive) (isearch-yank-internal (lambda () (require 'thingatpt) (forward-symbol 1) (point)))) I chose '_' (underscore) as it stands for symbols in much the same way as 'w' stands for word. Searching for symbols is something that I do often and I find it convenient if some such functionality comes by default with emacs. Jambunathan K. --