[Top][All Lists]

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

Re: [PATCH] better isearch support for complex input methods

From: Karl Fogel
Subject: Re: [PATCH] better isearch support for complex input methods
Date: 04 Apr 2001 14:54:36 -0500
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Based on the feedback so far, here's a summary:

   1. It would be useful if forward-word understood enough about the
      language environment to move forward by one "semantic word
      unit", even when that behavior would be the same as
      forward-char.  If forward-word did this perfectly, then isearch
      would need no changes to grab a character at a time in Chinese
      text (for example) -- you'd just use C-w.

   2. Independently of the above, it would be useful to have a binding
      in isearch-mode that grabs one letter at a time into one's
      search string (at least, Miles Bader <address@hidden> has
      concurred that he's wanted this before too).

      Furthermore, if one had this binding, it would be a handy
      workaround solution for isearch in Chinese and Japanese (and
      possibly other) languages.  Of course, the best solution is
      still to have forward-word know what is a word and what isn't,
      but until we can teach it that, those of us who have to edit
      such text today will at least have an improvement over the
      current situation.

So, both #1 and #2 are useful.  We currently have a patch for #2, but
not yet for #1.  There is no reason for #2 to wait on #1, but maybe #2
should wait on the feature freeze.

Gerd, assuming there is consensus that #2 is a Good Thing, should it
be committed now, or after feature freeze?

Here is the patch for it:

2001-04-02  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.188
diff -u -r1.188 isearch.el
--- isearch.el  2001/02/05 17:13:28     1.188
+++ isearch.el  2001/04/04 19:52:03
@@ -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)
@@ -1057,24 +1058,32 @@
       (mouse-yank-at-click click arg))))
-(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."
      (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."
-  (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]