Mercurial > hg > xemacs-beta
comparison lisp/isearch-mode.el @ 5371:6f10ac29bf40
Be better about searching for chars typed via XIM and x-compose.el, isearch
lisp/ChangeLog addition:
2011-03-12 Aidan Kehoe <kehoea@parhasard.net>
* isearch-mode.el (isearch-mode-map):
Document why we bind the ASCII characters to isearch-printing-char
in more detail.
* isearch-mode.el (isearch-maybe-frob-keyboard-macros):
If `this-command' is nil and the keys typed would normally be
bound to `self-insert-command' in the global map, force
`isearch-printing-char' to be called with an appropriate value for
last-command-event. Addresses an issue where searching for
characters generated from x-compose.el and XIM threw errors for me
in dired.
src/ChangeLog addition:
2011-03-12 Aidan Kehoe <kehoea@parhasard.net>
* event-stream.c (Fdispatch_event):
As documented, allow pre-command-hook to usefully modify
this-command even when this-command is nil (that is, we would
normally throw an undefined-keystroke-sequence error). Don't throw
that error if this-command was modified, instead try to execute
the new value.
Allow pre-command-hook to modify last-command-event in this
specific context. Don't document this, for the moment.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 12 Mar 2011 13:11:31 +0000 |
parents | f00192e1cd49 |
children | ac37a5f7e5be |
comparison
equal
deleted
inserted
replaced
5370:4c4b96b13f70 | 5371:6f10ac29bf40 |
---|---|
237 | 237 |
238 (defvar isearch-mode-map | 238 (defvar isearch-mode-map |
239 (let ((map (make-keymap))) | 239 (let ((map (make-keymap))) |
240 (set-keymap-name map 'isearch-mode-map) | 240 (set-keymap-name map 'isearch-mode-map) |
241 | 241 |
242 ;; Bind all printing characters to `isearch-printing-char'. | 242 ;; Bind ASCII printing characters to `isearch-printing-char'. This |
243 ;; This isn't normally necessary, but if a printing character were | 243 ;; isn't normally necessary, but if a printing character were bound to |
244 ;; bound to something other than self-insert-command in global-map, | 244 ;; something other than self-insert-command in global-map, then it would |
245 ;; then it would terminate the search and be executed without this. | 245 ;; terminate the search and be executed without this. |
246 | |
247 ;; This is also relevant when other modes (notably dired and gnus) call | |
248 ;; `suppress-keymap' on their major mode maps; this means that | |
249 ;; `isearch-maybe-frob-keyboard-macros' won't pick up that the command | |
250 ;; that would normally be executed is `self-insert-command' and do its | |
251 ;; thing of transforming that to `isearch-printing-char'. This is less | |
252 ;; of an issue for the non-ASCII characters, because they rarely have | |
253 ;; specific bindings in major modes. | |
246 (let ((i 32) | 254 (let ((i 32) |
247 (str (make-string 1 0))) | 255 (str (make-string 1 0))) |
248 (while (< i 127) | 256 (while (< i 127) |
249 (aset str 0 i) | 257 (aset str 0 i) |
250 (define-key map str 'isearch-printing-char) | 258 (define-key map str 'isearch-printing-char) |
1607 (eq (key-binding this-command) 'self-insert-command)) | 1615 (eq (key-binding this-command) 'self-insert-command)) |
1608 (setq last-command-event (character-to-event (aref this-command 0)) | 1616 (setq last-command-event (character-to-event (aref this-command 0)) |
1609 last-command-char (and (stringp this-command) | 1617 last-command-char (and (stringp this-command) |
1610 (aref this-command 0)) | 1618 (aref this-command 0)) |
1611 this-command 'isearch-printing-char)) | 1619 this-command 'isearch-printing-char)) |
1612 )) | 1620 ((and (null this-command) |
1613 | 1621 (eq 'key-press (event-type last-command-event)) |
1622 (current-local-map) | |
1623 (let* ((this-command-keys (this-command-keys)) | |
1624 (this-command-keys (or (lookup-key function-key-map | |
1625 this-command-keys) | |
1626 this-command-keys)) | |
1627 (lookup-key (lookup-key global-map this-command-keys))) | |
1628 (and (eq 'self-insert-command lookup-key) | |
1629 ;; The feature here that a modification of | |
1630 ;; last-command-event is respected is undocumented, and | |
1631 ;; only applies when this-command is nil. The design | |
1632 ;; isn't reat, and I welcome suggestions for a better | |
1633 ;; one. | |
1634 (setq last-command-event | |
1635 (find-if 'key-press-event-p this-command-keys | |
1636 :from-end t) | |
1637 last-command-char | |
1638 (event-to-character last-command-event) | |
1639 this-command 'isearch-printing-char))))))) | |
1640 | |
1614 | 1641 |
1615 ;;;======================================================== | 1642 ;;;======================================================== |
1616 ;;; Highlighting | 1643 ;;; Highlighting |
1617 | 1644 |
1618 (defvar isearch-extent nil) | 1645 (defvar isearch-extent nil) |