From 29e53a0ae9fb469bdc874026a43e049c9b57671e Mon Sep 17 00:00:00 2001 From: Karl Fogel Date: Wed, 28 Nov 2001 22:34:20 +0000 Subject: [PATCH] (isearch-yank-internal): New helper function. (isearch-yank-char): New function. (isearch-yank-word, isearch-yank-line): Rewrite to use isearch-yank-internal. --- lisp/ChangeLog | 7 +++++++ lisp/isearch.el | 28 ++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index af7972964b9..3eef5436502 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2001-11-28 Karl Fogel + + * isearch.el (isearch-yank-internal): New helper function. + (isearch-yank-char): New function. + (isearch-yank-word, isearch-yank-line): Rewrite to use + isearch-yank-internal. + 2001-11-28 Eli Zaretskii * mouse.el (mouse-set-font): Make it a no-op if multiple fonts diff --git a/lisp/isearch.el b/lisp/isearch.el index a11783473bd..4777b49b629 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1073,24 +1073,32 @@ Otherwise invoke whatever mouse-2 is bound to outside of Isearch." (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 () -- 2.39.2