From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.devel Subject: Re: isearch-yank-word-at-point (was Re: Key map translations) Date: Thu, 14 Apr 2011 07:21:01 +0200 Message-ID: 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; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1302758500 16888 80.91.229.12 (14 Apr 2011 05:21:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Apr 2011 05:21:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: Christoph Scholtes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 14 07:21:29 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 1QAEzf-0006nk-0r for ged-emacs-devel@m.gmane.org; Thu, 14 Apr 2011 07:21:27 +0200 Original-Received: from localhost ([::1]:40037 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAEze-0004Vr-Cd for ged-emacs-devel@m.gmane.org; Thu, 14 Apr 2011 01:21:26 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAEzb-0004Vm-Bp for emacs-devel@gnu.org; Thu, 14 Apr 2011 01:21:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAEzZ-0000WA-St for emacs-devel@gnu.org; Thu, 14 Apr 2011 01:21:23 -0400 Original-Received: from mail-gy0-f169.google.com ([209.85.160.169]:59851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAEzZ-0000W6-PD for emacs-devel@gnu.org; Thu, 14 Apr 2011 01:21:21 -0400 Original-Received: by gyd8 with SMTP id 8so405607gyd.0 for ; Wed, 13 Apr 2011 22:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=TCxuIqoR0SPw6mDeZxrY1Rnx1a+7kbkq0u3Cxev9mx8=; b=rL/RM1WURIxSpJRLkS+qo72amVy7Eic4Yqew0WzDH39nJIIaskvn/vCGHQjtqgwNUI AN9vfqoJMEapFB38HqmZrV9tmGhy0QxVroYz9qgsne3UeputVmGQ2R/ewUNuMlLmN5/m BnSqqN8qF9iYbJsCQ5WcqNy7dwNDbLb9TN6vs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=QzHif8Uu8uEPqCzELycf/K3rfGBkdJ6Xu0t7VfjhZjtEeYdwqHY14cnZE9C+AdpyA+ QU+tPEoAflvjpDoklXsKM0PaUAu59KYq9DgFwIGTS64cK20kOdpNzJ4LABEoIupiIYGg BA8fsazgSvPzJrFHYsWL5OvdiKKnRpIQiuer0= Original-Received: by 10.151.86.4 with SMTP id o4mr1228305ybl.339.1302758481068; Wed, 13 Apr 2011 22:21:21 -0700 (PDT) Original-Received: by 10.151.153.17 with HTTP; Wed, 13 Apr 2011 22:21:01 -0700 (PDT) In-Reply-To: <4DA62C59.4040707@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.169 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:138471 Archived-At: 2011/4/14 Christoph Scholtes : > 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 wor= d > 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 () > =A0"Pull word at point into the search string." > =A0(interactive) > =A0;; Only yank if point is on a word constituent or > =A0;; symbol constituent per the syntax table. > =A0(when (or (=3D (char-syntax (or (char-after) 0)) ?w) > =A0 =A0 =A0 =A0 =A0 =A0(=3D (char-syntax (or (char-after) 0)) ?_)) > =A0 =A0;; If part of the string has been yanked to the search string > =A0 =A0;; already, unwind the isearch state stack to the beginning to > =A0 =A0;; start over. > =A0 =A0(while (not (string=3D isearch-string "")) > =A0 =A0 =A0(isearch-pop-state)) > > =A0 =A0;; Go to beginning of word at point > =A0 =A0(skip-syntax-backward "w_") > =A0 =A0;; and yank entire word into search string. > =A0 =A0(isearch-yank-internal > =A0 =A0 (lambda () > =A0 =A0 =A0 (skip-syntax-forward "w_") > =A0 =A0 =A0 (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 fi= nd > it useful. > > Christoph > I think it looks pretty good. However, I'd like it to do something useful when standing on non-word/symbol constituent characters such as (. I'd also like to be able to C-a C-a to search for the current word and the following word. Thoughts on this? --=20 Deniz Dogan