(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)
(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)
))
;; 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.
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
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))
(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))
(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))
"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 ()
(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)))))
;; 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))))
;; 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.