comparison lisp/isearch-mode.el @ 5473:ac37a5f7e5be

Merge with trunk.
author Mats Lidell <matsl@xemacs.org>
date Thu, 17 Mar 2011 23:42:59 +0100
parents 308d34e9f07d 6f10ac29bf40
children b7ae5f44b950
comparison
equal deleted inserted replaced
5472:e79980ee5efe 5473:ac37a5f7e5be
235 235
236 (defvar isearch-mode-map 236 (defvar isearch-mode-map
237 (let ((map (make-keymap))) 237 (let ((map (make-keymap)))
238 (set-keymap-name map 'isearch-mode-map) 238 (set-keymap-name map 'isearch-mode-map)
239 239
240 ;; Bind all printing characters to `isearch-printing-char'. 240 ;; Bind ASCII printing characters to `isearch-printing-char'. This
241 ;; This isn't normally necessary, but if a printing character were 241 ;; isn't normally necessary, but if a printing character were bound to
242 ;; bound to something other than self-insert-command in global-map, 242 ;; something other than self-insert-command in global-map, then it would
243 ;; then it would terminate the search and be executed without this. 243 ;; terminate the search and be executed without this.
244
245 ;; This is also relevant when other modes (notably dired and gnus) call
246 ;; `suppress-keymap' on their major mode maps; this means that
247 ;; `isearch-maybe-frob-keyboard-macros' won't pick up that the command
248 ;; that would normally be executed is `self-insert-command' and do its
249 ;; thing of transforming that to `isearch-printing-char'. This is less
250 ;; of an issue for the non-ASCII characters, because they rarely have
251 ;; specific bindings in major modes.
244 (let ((i 32) 252 (let ((i 32)
245 (str (make-string 1 0))) 253 (str (make-string 1 0)))
246 (while (< i 127) 254 (while (< i 127)
247 (aset str 0 i) 255 (aset str 0 i)
248 (define-key map str 'isearch-printing-char) 256 (define-key map str 'isearch-printing-char)
709 However, if this is the first command after starting incremental 717 However, if this is the first command after starting incremental
710 search and `search-nonincremental-instead' is non-nil, do a 718 search and `search-nonincremental-instead' is non-nil, do a
711 nonincremental search instead via `isearch-edit-string'." 719 nonincremental search instead via `isearch-edit-string'."
712 (interactive) 720 (interactive)
713 (if (and (or search-nonincremental-instead executing-kbd-macro) 721 (if (and (or search-nonincremental-instead executing-kbd-macro)
714 (= 0 (length isearch-string))) 722 (eql 0 (length isearch-string)))
715 (let ((isearch-nonincremental t) 723 (let ((isearch-nonincremental t)
716 ;; Highlighting only gets in the way of nonincremental 724 ;; Highlighting only gets in the way of nonincremental
717 ;; search. 725 ;; search.
718 (search-highlight nil) 726 (search-highlight nil)
719 (isearch-highlight-all-matches nil)) 727 (isearch-highlight-all-matches nil))
823 isearch-message isearch-new-message 831 isearch-message isearch-new-message
824 isearch-forward isearch-new-forward 832 isearch-forward isearch-new-forward
825 isearch-word isearch-new-word)) 833 isearch-word isearch-new-word))
826 834
827 ;; Empty isearch-string means use default. 835 ;; Empty isearch-string means use default.
828 (if (= 0 (length isearch-string)) 836 (if (eql 0 (length isearch-string))
829 (setq isearch-string (or (car (if isearch-regexp 837 (setq isearch-string (or (car (if isearch-regexp
830 regexp-search-ring 838 regexp-search-ring
831 search-ring)) 839 search-ring))
832 "")))) 840 ""))))
833 841
1120 (if isearch-regexp 1128 (if isearch-regexp
1121 (let ((idx (length isearch-string))) 1129 (let ((idx (length isearch-string)))
1122 (while (and (> idx 0) 1130 (while (and (> idx 0)
1123 (eq (aref isearch-string (1- idx)) ?\\)) 1131 (eq (aref isearch-string (1- idx)) ?\\))
1124 (setq idx (1- idx))) 1132 (setq idx (1- idx)))
1125 (when (= (mod (- (length isearch-string) idx) 2) 0) 1133 (when (eql (mod (- (length isearch-string) idx) 2) 0)
1126 (setq isearch-adjusted t) 1134 (setq isearch-adjusted t)
1127 ;; Get the isearch-other-end from before the last search. 1135 ;; Get the isearch-other-end from before the last search.
1128 ;; We want to start from there, 1136 ;; We want to start from there,
1129 ;; so that we don't retreat farther than that. 1137 ;; so that we don't retreat farther than that.
1130 ;; (car isearch-cmds) is after last search; 1138 ;; (car isearch-cmds) is after last search;
1312 (cond 1320 (cond
1313 ((eq completion t) 1321 ((eq completion t)
1314 ;; isearch-string stays the same 1322 ;; isearch-string stays the same
1315 t) 1323 t)
1316 ((or completion ; not nil, must be a string 1324 ((or completion ; not nil, must be a string
1317 (= 0 (length isearch-string))) ; shouldn't have to say this 1325 (eql 0 (length isearch-string))) ; shouldn't have to say this
1318 (if (equal completion isearch-string) ;; no extension? 1326 (if (equal completion isearch-string) ;; no extension?
1319 (progn 1327 (progn
1320 (if completion-auto-help 1328 (if completion-auto-help
1321 (with-output-to-temp-buffer "*Isearch completions*" 1329 (with-output-to-temp-buffer "*Isearch completions*"
1322 (display-completion-list 1330 (display-completion-list
1605 (eq (key-binding this-command) 'self-insert-command)) 1613 (eq (key-binding this-command) 'self-insert-command))
1606 (setq last-command-event (character-to-event (aref this-command 0)) 1614 (setq last-command-event (character-to-event (aref this-command 0))
1607 last-command-char (and (stringp this-command) 1615 last-command-char (and (stringp this-command)
1608 (aref this-command 0)) 1616 (aref this-command 0))
1609 this-command 'isearch-printing-char)) 1617 this-command 'isearch-printing-char))
1610 )) 1618 ((and (null this-command)
1611 1619 (eq 'key-press (event-type last-command-event))
1620 (current-local-map)
1621 (let* ((this-command-keys (this-command-keys))
1622 (this-command-keys (or (lookup-key function-key-map
1623 this-command-keys)
1624 this-command-keys))
1625 (lookup-key (lookup-key global-map this-command-keys)))
1626 (and (eq 'self-insert-command lookup-key)
1627 ;; The feature here that a modification of
1628 ;; last-command-event is respected is undocumented, and
1629 ;; only applies when this-command is nil. The design
1630 ;; isn't reat, and I welcome suggestions for a better
1631 ;; one.
1632 (setq last-command-event
1633 (find-if 'key-press-event-p this-command-keys
1634 :from-end t)
1635 last-command-char
1636 (event-to-character last-command-event)
1637 this-command 'isearch-printing-char)))))))
1638
1612 1639
1613 ;;;======================================================== 1640 ;;;========================================================
1614 ;;; Highlighting 1641 ;;; Highlighting
1615 1642
1616 (defvar isearch-extent nil) 1643 (defvar isearch-extent nil)