emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Isearch: yanking before point


From: Johannes Weiner
Subject: [PATCH] Isearch: yanking before point
Date: Tue, 21 Aug 2007 17:59:43 +0200
User-agent: Mutt/1.5.16 (2007-06-11)

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
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]