emacs-devel
[Top][All Lists]
Advanced

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

isearch C-o patch (post-freeze resubmission)


From: Karl Fogel
Subject: isearch C-o patch (post-freeze resubmission)
Date: Sun, 25 Nov 2001 23:21:29 -0600 (CST)

I didn't commit this back in April, due to the feature freeze;
however, we all pretty much agreed it would be a Good Thing.  Now the
freeze is over, but it's been a long time since April, so I'm
reposting for review before committing.

For the full background on this change, you may wish to review the
thread at:

   http://www.red-bean.com/kfogel/isearch-thread.html

(A good summary can be had just by reading last two messages in the
thread.)

-Karl

2001-11-24  Karl Fogel  <address@hidden>

        * isearch.el (isearch-mode-map): Bind C-o in isearch to yank the
        next letter from the buffer into the search string.
        (isearch-yank-internal): New helper function, contains common
        internals of next three.
        (isearch-yank-char): New function.
        (isearch-yank-word): Rewrite to use isearch-yank-internal.
        (isearch-yank-line): Rewrite to use isearch-yank-internal.

Index: isearch.el
===================================================================
RCS file: /cvs/emacs/lisp/isearch.el,v
retrieving revision 1.200
diff -u -r1.200 isearch.el
--- isearch.el  2001/11/19 06:21:29     1.200
+++ isearch.el  2001/11/25 03:34:04
@@ -286,6 +286,7 @@
     (define-key map " " 'isearch-whitespace-chars)
     (define-key map [?\S-\ ] 'isearch-whitespace-chars)
     
+    (define-key map "\C-o" 'isearch-yank-char)
     (define-key map "\C-w" 'isearch-yank-word)
     (define-key map "\C-y" 'isearch-yank-line)
 
@@ -1073,24 +1074,32 @@
          (funcall binding click))))))
 
 
-(defun isearch-yank-word ()
-  "Pull next word from buffer into search string."
-  (interactive)
+(defun isearch-yank-internal (jumpform)
+  "Pull the text from point to the point reached by JUMPFORM.
+JUMPFORM is a lambda expression that takes no arguments and returns a
+buffer position, possibly having moved point to that position.  For
+example, it might move point forward by a word and return point, or it
+might return the position of the end of the line."
   (isearch-yank-string
    (save-excursion
      (and (not isearch-forward) isearch-other-end
          (goto-char isearch-other-end))
-     (buffer-substring-no-properties
-      (point) (progn (forward-word 1) (point))))))
+     (buffer-substring-no-properties (point) (funcall jumpform)))))
 
+(defun isearch-yank-char ()
+  "Pull next letter from buffer into search string."
+  (interactive)
+  (isearch-yank-internal (lambda () (forward-char 1) (point))))
+
+(defun isearch-yank-word ()
+  "Pull next word from buffer into search string."
+  (interactive)
+  (isearch-yank-internal (lambda () (forward-word 1) (point))))
+
 (defun isearch-yank-line ()
   "Pull rest of line from buffer into search string."
   (interactive)
-  (isearch-yank-string
-   (save-excursion
-     (and (not isearch-forward) isearch-other-end
-         (goto-char isearch-other-end))
-     (buffer-substring-no-properties (point) (line-end-position)))))
+  (isearch-yank-internal (lambda () (line-end-position))))
 
 
 (defun isearch-search-and-update ()



reply via email to

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