From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Johannes Weiner Newsgroups: gmane.emacs.devel Subject: [PATCH] Isearch: yanking before point Date: Tue, 21 Aug 2007 17:59:43 +0200 Message-ID: <20070821155943.GA19989@saeurebad.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="XsQoSWH+UP9D9v3l" X-Trace: sea.gmane.org 1187712003 15010 80.91.229.12 (21 Aug 2007 16:00:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Aug 2007 16:00:03 +0000 (UTC) To: Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 21 18:00:01 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1INW98-0000G2-Pw for ged-emacs-devel@m.gmane.org; Tue, 21 Aug 2007 17:59:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INW98-00010m-6D for ged-emacs-devel@m.gmane.org; Tue, 21 Aug 2007 11:59:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1INW93-00010J-UL for emacs-devel@gnu.org; Tue, 21 Aug 2007 11:59:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1INW92-0000zh-OH for emacs-devel@gnu.org; Tue, 21 Aug 2007 11:59:53 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INW92-0000zc-FV for emacs-devel@gnu.org; Tue, 21 Aug 2007 11:59:52 -0400 Original-Received: from saeurebad.de ([85.214.36.134]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1INW92-0007lZ-EP for emacs-devel@gnu.org; Tue, 21 Aug 2007 11:59:52 -0400 Original-Received: by saeurebad.de (Postfix, from userid 1000) id DB6552F03B2; Tue, 21 Aug 2007 17:59:43 +0200 (CEST) Mail-Followup-To: Emacs development discussions Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-11) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:76896 Archived-At: --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Emacs-hackers, It happens often enough that I want to search for a word that is *before* the point. Isearch already allows yanking the word/line after the point into the minibuffer, so I extended isearch in the same manner for before-point yanking. Hannes --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="emacs-isearch-yank-before-point.patch" diff -Naur emacs.orig/lisp/isearch.el emacs/lisp/isearch.el --- emacs.orig/lisp/isearch.el 2007-08-21 17:51:40.000000000 +0200 +++ emacs/lisp/isearch.el 2007-08-21 17:52:40.000000000 +0200 @@ -371,9 +371,11 @@ (define-key map [?\S-\ ] 'isearch-printing-char) (define-key map "\C-w" 'isearch-yank-word-or-char) + (define-key map "\C-b" 'isearch-yank-word-before-point) (define-key map "\M-\C-w" 'isearch-del-char) (define-key map "\M-\C-y" 'isearch-yank-char) (define-key map "\C-y" 'isearch-yank-line) + (define-key map "\C-l" 'isearch-yank-line-before-point) ;; Turned off because I find I expect to get the global definition--rms. ;; ;; Instead bind C-h to special help command for isearch-mode. @@ -1371,6 +1373,11 @@ (interactive) (isearch-yank-internal (lambda () (forward-word 1) (point)))) +(defun isearch-yank-word-before-point () + "Pull previous word from buffer into search string." + (interactive) + (isearch-yank-internal (lambda () (backward-word) (point)))) + (defun isearch-yank-line () "Pull rest of line from buffer into search string." (interactive) @@ -1378,6 +1385,13 @@ (lambda () (let ((inhibit-field-text-motion t)) (line-end-position (if (eolp) 2 1)))))) +(defun isearch-yank-line-before-point () + "Pull whole line up to point into search string." + (interactive) + (isearch-yank-internal + (lambda () (let ((inhibit-field-text-motion t)) + (line-beginning-position (if (bolp) 0 1)))))) + (defun isearch-search-and-update () ;; Do the search and update the display. (when (or isearch-success --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --XsQoSWH+UP9D9v3l--