[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch: terminating isearch with shifted control character
From: |
Ben North |
Subject: |
Patch: terminating isearch with shifted control character |
Date: |
Wed, 15 Mar 2006 12:58:11 +0000 |
User-agent: |
Internet Messaging Program (IMP) 3.2.8 |
I think there's a bug in the behaviour of isearch, when you try to
terminate it by pressing a shifted control character. For example, I
have the standard binding "C-a" as `beginning-of-line', and the
non-standard binding "C-A" as `back-to-indentation'. Trying to
terminate an isearch with "C-A" leaves isearch, but does
`beginning-of-line' rather than `back-to-indentation'.
I think the problem is in the following code in `isearch-other-meta-char':
;; Handle an undefined shifted control character
;; by downshifting it if that makes it defined.
;; (As read-key-sequence would normally do,
;; if we didn't have a default definition.)
(let ((mods (event-modifiers main-event)))
(and (integerp main-event)
(memq 'shift mods)
(memq 'control mods)
(lookup-key isearch-mode-map
(let ((copy (copy-sequence key)))
(aset copy 0
(- main-event (- ?\C-\S-a ?\C-a)))
copy)
nil)))
Because the defvar of `isearch-mode-map' explicitly sets up bindings for
control characters:
;; Control chars, by default, end isearch mode transparently.
;; We need these explicit definitions because, in a dense keymap,
;; the binding for t does not affect characters.
;; We use a dense keymap to save space.
(while (< i ?\s)
(define-key map (make-string 1 i) 'isearch-other-control-char)
(setq i (1+ i)))
the (lookup-key) in `isearch-other-meta-char' succeeds, finding
'isearch-other-control-char. It then unreads a C-a.
The patch below, against current (20060315) CVS, catches this case. I
don't think we also need to check for 'isearch-other-meta-char in the
(not (memq ...)) because the code is only triggered on control keys.
With the patch, pressing C-A runs `back-to-indentation' as desired, but
also C-S runs `isearch-repeat-forward' as was the correct old behaviour.
Ben.
--- CVS--isearch.el 2006-03-15 11:47:11.141512000 +0000
+++ isearch.el 2006-03-15 12:47:57.835925000 +0000
@@ -1689,26 +1689,29 @@
(setq keylist nil)))))
(
;; Handle an undefined shifted control character
;; by downshifting it if that makes it defined.
;; (As read-key-sequence would normally do,
;; if we didn't have a default definition.)
(let ((mods (event-modifiers main-event)))
(and (integerp main-event)
(memq 'shift mods)
(memq 'control mods)
- (lookup-key isearch-mode-map
- (let ((copy (copy-sequence key)))
- (aset copy 0
- (- main-event (- ?\C-\S-a ?\C-a)))
- copy)
- nil)))
+ (not (memq (lookup-key isearch-mode-map
+ (let ((copy (copy-sequence key)))
+ (aset copy 0
+ (- main-event
+ (- ?\C-\S-a ?\C-a)))
+ copy)
+ nil)
+ '(nil
+ isearch-other-control-char)))))
(setcar keylist (- main-event (- ?\C-\S-a ?\C-a)))
(cancel-kbd-macro-events)
(apply 'isearch-unread keylist))
((eq search-exit-option 'edit)
(apply 'isearch-unread keylist)
(isearch-edit-string))
;; Handle a scrolling function.
((and isearch-allow-scroll
(progn (setq key (isearch-reread-key-sequence-naturally
keylist))
(setq keylist (listify-key-sequence key))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patch: terminating isearch with shifted control character,
Ben North <=