]> code.delx.au - gnu-emacs/blobdiff - lisp/isearch.el
(Flookup_key, Faccessible_keymaps, describe_vector,
[gnu-emacs] / lisp / isearch.el
index ec1f20abecb17513399aa81241c7705575f3dfda..bb0afebb8ec9b46fdc2b5ea86587e7b38c028994 100644 (file)
@@ -153,7 +153,9 @@ string, and RET terminates editing and does a nonincremental search."
 (defcustom search-whitespace-regexp "\\s-+"
   "*If non-nil, regular expression to match a sequence of whitespace chars.
 This applies to regular expression incremental search.
-You might want to use something like \"[ \\t\\r\\n]+\" instead."
+You might want to use something like \"[ \\t\\r\\n]+\" instead.
+In the Customization buffer, that is `[' followed by a space,
+a tab, a carriage return (control-M), a newline, and `]+'."
   :type 'regexp
   :group 'isearch)
 
@@ -310,6 +312,11 @@ Default value, nil, means edit the string instead."
       (define-key map "\C-\\" 'isearch-toggle-input-method)
       (define-key map "\C-^" 'isearch-toggle-specified-input-method)
 
+;;; I think the normal meaning of Mouse-2 is more natural.
+;;;       ;; People expect to be able to paste with the mouse.
+;;;       (define-key map [mouse-2] #'isearch-yank-kill)
+;;;       (define-key map [down-mouse-2] nil)
+
       (setq isearch-mode-map map)
       ))
 
@@ -387,6 +394,13 @@ Default value, nil, means edit the string instead."
 ;; Accumulate here the overlays opened during searching.
 (defvar isearch-opened-overlays nil)
 
+;; The value of input-method-function when isearch is invoked.
+(defvar isearch-input-method-function nil)
+
+;; A flag to tell if input-method-function is locally bound when
+;; isearch is invoked.
+(defvar isearch-input-method-local-p nil)
+
 ;; Minor-mode-alist changes - kind of redundant with the
 ;; echo area, but if isearching in multiple windows, it can be useful.
 
@@ -424,7 +438,8 @@ Type \\[isearch-yank-word] to yank word from buffer onto end of search\
  string and search for it.
 Type \\[isearch-yank-line] to yank rest of line onto end of search string\
  and search for it.
-Type \\[isearch-yank-kill] to yank the last string of killed text.
+Type \\[isearch-yank-kill] to yank last killed text onto end of search string\
+ and search for it.
 Type \\[isearch-quote-char] to quote control character to search for it.
 \\[isearch-abort] while searching or when search has failed cancels input\
  back to what has
@@ -523,7 +538,17 @@ is treated as a regexp.  See \\[isearch-forward] for more info."
        isearch-opoint (point)
        search-ring-yank-pointer nil
        isearch-opened-overlays nil
+       isearch-input-method-function input-method-function
+       isearch-input-method-local-p (local-variable-p 'input-method-function)
        regexp-search-ring-yank-pointer nil)
+
+  ;; We must bypass input method while reading key.  When a user type
+  ;; printable character, appropriate input method is turned on in
+  ;; minibuffer to read multibyte charactes.
+  (or isearch-input-method-local-p
+      (make-local-variable 'input-method-function))
+  (setq input-method-function nil)
+
   (looking-at "")
   (setq isearch-window-configuration
        (if isearch-slow-terminal-mode (current-window-configuration) nil))
@@ -621,8 +646,23 @@ is treated as a regexp.  See \\[isearch-forward] for more info."
                  (message "Mark saved where search started"))))))
 
   (setq isearch-mode nil)
+  (if isearch-input-method-local-p
+      (setq input-method-function isearch-input-method-function)
+    (kill-local-variable 'input-method-function))
+
   (force-mode-line-update)
 
+  ;; If we ended in the middle of some intangible text,
+  ;; move to the further end of that intangible text.
+  (let ((after (if (eobp) nil
+                (get-text-property (point) 'intangible)))
+       (before (if (bobp) nil
+                 (get-text-property (1- (point)) 'intangible))))
+    (when (and before after (eq before after))
+      (if isearch-forward
+         (goto-char (next-single-property-change (point) 'intangible))
+       (goto-char (previous-single-property-change (point) 'intangible)))))
+
   (if (and (> (length isearch-string) 0) (not nopush))
       ;; Update the ring data.
       (isearch-update-ring isearch-string isearch-regexp))
@@ -1008,6 +1048,9 @@ To do that, evaluate these expressions:
     (if (and (not isearch-forward) (not isearch-adjusted)
             (condition-case ()
                 (let ((case-fold-search isearch-case-fold-search))
+                  (if (and (eq case-fold-search t) search-upper-case)
+                      (setq case-fold-search
+                            (isearch-no-upper-case-p isearch-string isearch-regexp)))
                   (looking-at (if isearch-regexp isearch-string
                                 (regexp-quote isearch-string))))
               (error nil))
@@ -1162,13 +1205,13 @@ and the meta character is unread so that it applies to editing the string."
   "Quote special characters for incremental search."
   (interactive)
   (let ((char (read-quoted-char (isearch-message t))))
-    ;; Assume character codes 0200 - 0377 stand for 
-    ;; European characters in Latin-1, and convert them
-    ;; to Emacs characters.
+    ;; Assume character codes 0200 - 0377 stand for characters in some
+    ;; single-byte character set, and convert them to Emacs
+    ;; characters.
     (and enable-multibyte-characters
         (>= char ?\200)
         (<= char ?\377)
-        (setq char (+ char nonascii-insert-offset)))
+        (setq char (unibyte-char-to-multibyte char)))
     (isearch-process-search-char char)))
 
 (defun isearch-return-char ()
@@ -1186,7 +1229,7 @@ Obsolete."
     (if (and enable-multibyte-characters
             (>= char ?\200)
             (<= char ?\377))
-       (isearch-process-search-char (+ char nonascii-insert-offset))
+       (isearch-process-search-char (unibyte-char-to-multibyte char))
       (if current-input-method
          (isearch-process-search-multibyte-characters char)
        (isearch-process-search-char char)))))
@@ -1211,7 +1254,7 @@ If you want to search for just a space, type C-q SPC."
   ;; Append the char to the search string, update the message and re-search.
   (isearch-process-search-string 
    (isearch-char-to-string char) 
-   (if (>= char 0200)
+   (if (>= char ?\200)
        (char-to-string char)
      (isearch-text-char-description char))))
 
@@ -1586,13 +1629,13 @@ If there is no completion possible, say so and continue searching."
        ;; Check that invisibility runs up to END.
        (save-excursion
         (goto-char beg)
-        (let 
-            ;; can-be-opened keeps track if we can open some overlays.
-            ((can-be-opened (eq search-invisible 'open))
-             ;; the list of overlays that could be opened
-             (crt-overlays nil))
+        (let (
+              ;; can-be-opened keeps track if we can open some overlays.
+              (can-be-opened (eq search-invisible 'open))
+              ;; the list of overlays that could be opened
+              (crt-overlays nil))
           (when (and can-be-opened isearch-hide-immediately) 
-              (isearch-close-unecessary-overlays beg end))
+            (isearch-close-unecessary-overlays beg end))
           ;; If the following character is currently invisible,
           ;; skip all characters with that same `invisible' property value.
           ;; Do that over and over.