If this value is `not-yanks', yanked text is always downcased."
:type '(choice (const :tag "off" nil)
(const not-yanks)
- (sexp :tag "on" :format "%t\n" t))
+ (other :tag "on" t))
:group 'isearch)
(defcustom search-nonincremental-instead t
(defcustom search-whitespace-regexp "\\s-+"
"*If non-nil, regular expression to match a sequence of whitespace chars.
-You might want to use something like \"[ \\t\\r\\n]+\" instead."
+This applies to regular expression incremental search.
+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)
(or (vectorp (nth 1 map))
(char-table-p (nth 1 map))
(error "The initialization of isearch-mode-map must be updated"))
- ;; Make Latin-1, Latin-2, Latin-3 and Latin-4 characters
- ;; search for themselves.
- (aset (nth 1 map) (make-char 'latin-iso8859-1) 'isearch-printing-char)
- (aset (nth 1 map) (make-char 'latin-iso8859-2) 'isearch-printing-char)
- (aset (nth 1 map) (make-char 'latin-iso8859-3) 'isearch-printing-char)
- (aset (nth 1 map) (make-char 'latin-iso8859-4) 'isearch-printing-char)
- (aset (nth 1 map) (make-char 'latin-iso8859-9) 'isearch-printing-char)
+ ;; Make all multibyte characters search for themselves.
+ (let ((l (generic-character-list))
+ (table (nth 1 map)))
+ (while l
+ (set-char-table-default table (car l) 'isearch-printing-char)
+ (setq l (cdr l))))
;; Make function keys, etc, exit the search.
(define-key map [t] 'isearch-other-control-char)
;; Control chars, by default, end isearch mode transparently.
(define-key map (make-string 1 i) 'isearch-other-control-char)
(setq i (1+ i)))
- ;; Printing chars extend the search string by default.
+ ;; Single-byte printing chars extend the search string by default.
(setq i ?\ )
- (while (< i (length (nth 1 map)))
+ (while (< i 256)
(define-key map (vector i) 'isearch-printing-char)
(setq i (1+ i)))
(define-key map "\C-j" 'isearch-printing-char)
(define-key map "\t" 'isearch-printing-char)
(define-key map " " 'isearch-whitespace-chars)
+ (define-key map [?\S-\ ] 'isearch-whitespace-chars)
(define-key map "\C-w" 'isearch-yank-word)
(define-key map "\C-y" 'isearch-yank-line)
;; 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 (and (> (length isearch-string) 0) (not nopush))
(isearch-update))
-(defun isearch-yank (chunk)
- ;; Helper for isearch-yank-word and isearch-yank-line
- ;; CHUNK should be word, line, kill, or x-sel.
- (let ((string (cond
- ((eq chunk 'kill)
- (current-kill 0))
- ((eq chunk 'x-sel)
- (x-get-selection))
- (t
- (save-excursion
- (and (not isearch-forward) isearch-other-end
- (goto-char isearch-other-end))
- (buffer-substring
- (point)
- (save-excursion
- (cond
- ((eq chunk 'word)
- (forward-word 1))
- ((eq chunk 'line)
- (end-of-line)))
- (point))))))))
- ;; Downcase the string if not supposed to case-fold yanked strings.
- (if (and isearch-case-fold-search
- (eq 'not-yanks search-upper-case))
- (setq string (downcase string)))
- (if isearch-regexp (setq string (regexp-quote string)))
- (setq isearch-string (concat isearch-string string)
- isearch-message
- (concat isearch-message
- (mapconcat 'isearch-text-char-description
- string ""))
- ;; Don't move cursor in reverse search.
- isearch-yank-flag t))
+(defun isearch-yank-string (string)
+ "Pull STRING into search string."
+ ;; Downcase the string if not supposed to case-fold yanked strings.
+ (if (and isearch-case-fold-search
+ (eq 'not-yanks search-upper-case))
+ (setq string (downcase string)))
+ (if isearch-regexp (setq string (regexp-quote string)))
+ (setq isearch-string (concat isearch-string string)
+ isearch-message
+ (concat isearch-message
+ (mapconcat 'isearch-text-char-description
+ string ""))
+ ;; Don't move cursor in reverse search.
+ isearch-yank-flag t)
(isearch-search-and-update))
(defun isearch-yank-kill ()
"Pull string from kill ring into search string."
(interactive)
- (isearch-yank 'kill))
+ (isearch-yank-string (current-kill 0)))
+
+(defun isearch-yank-x-selection ()
+ "Pull current X selection into search string.
+Some users like to put this command on Mouse-2.
+To do that, evaluate these expressions:
+ (define-key isearch-mode-map [down-mouse-2] nil)
+ (define-key isearch-mode-map [mouse-2] 'isearch-yank-x-selection)"
+ (interactive)
+ (isearch-yank-string (x-get-selection)))
(defun isearch-yank-word ()
"Pull next word from buffer into search string."
(interactive)
- (isearch-yank 'word))
+ (isearch-yank-string
+ (save-excursion
+ (and (not isearch-forward) isearch-other-end
+ (goto-char isearch-other-end))
+ (buffer-substring (point) (progn (forward-word 1) (point))))))
(defun isearch-yank-line ()
"Pull rest of line from buffer into search string."
(interactive)
- (isearch-yank 'line))
+ (isearch-yank-string
+ (save-excursion
+ (and (not isearch-forward) isearch-other-end
+ (goto-char isearch-other-end))
+ (buffer-substring (point) (line-end-position)))))
(defun isearch-search-and-update ()
(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))
- (or isearch-yank-flag
- (<= (match-end 0)
- (min isearch-opoint isearch-barrier))))
+ (or isearch-yank-flag
+ (<= (match-end 0)
+ (min isearch-opoint isearch-barrier))))
(progn
(setq isearch-success t
isearch-invalid-regexp nil
"Handle * and ? specially in regexps."
(interactive)
(if isearch-regexp
-
- (progn
- (setq isearch-adjusted t)
- ;; Get the isearch-other-end from before the last search.
- ;; We want to start from there,
- ;; so that we don't retreat farther than that.
- ;; (car isearch-cmds) is after last search;
- ;; (car (cdr isearch-cmds)) is from before it.
- (let ((cs (nth 5 (car (cdr isearch-cmds)))))
- (setq cs (or cs isearch-barrier))
- (goto-char
- (if isearch-forward
- (max cs isearch-barrier)
- (min cs isearch-barrier))))))
+ (let ((idx (length isearch-string)))
+ (while (and (> idx 0)
+ (eq (aref isearch-string (1- idx)) ?\\))
+ (setq idx (1- idx)))
+ (when (= (mod (- (length isearch-string) idx) 2) 0)
+ (setq isearch-adjusted t)
+ ;; Get the isearch-other-end from before the last search.
+ ;; We want to start from there,
+ ;; so that we don't retreat farther than that.
+ ;; (car isearch-cmds) is after last search;
+ ;; (car (cdr isearch-cmds)) is from before it.
+ (let ((cs (nth 5 (car (cdr isearch-cmds)))))
+ (setq cs (or cs isearch-barrier))
+ (goto-char
+ (if isearch-forward
+ (max cs isearch-barrier)
+ (min cs isearch-barrier)))))))
(isearch-process-search-char (isearch-last-command-char)))
"Add this ordinary printing character to the search string and search."
(interactive)
(let ((char (isearch-last-command-char)))
+ (if (= char ?\S-\ )
+ (setq char ?\ ))
(if (and enable-multibyte-characters
(>= char ?\200)
(<= char ?\377))
(while overlays
(setq o (car overlays)
invis-prop (overlay-get o 'invisible))
- (if (or (memq invis-prop buffer-invisibility-spec)
- (assq invis-prop buffer-invisibility-spec))
+ (if (if (eq buffer-invisibility-spec t)
+ invis-prop
+ (or (memq invis-prop buffer-invisibility-spec)
+ (assq invis-prop buffer-invisibility-spec)))
(if (overlay-get o 'isearch-open-invisible)
(setq ov-list (cons o ov-list))
;; We found one overlay that cannot be
;; It makes sense to append to the open
;; overlays list only if we know that this is
;; t.
- (setq crt-overlays (append ov-list crt-overlays))))
- (goto-char (next-overlay-change (point))))))
+ (setq crt-overlays (append ov-list crt-overlays)))))
+ (goto-char (next-overlay-change (point)))))
;; See if invisibility reaches up thru END.
(if (>= (point) end)
(if (and (not (null can-be-opened)) (consp crt-overlays))