[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: binding c-h in isearch
From: |
Lennart Borgman (gmail) |
Subject: |
Re: binding c-h in isearch |
Date: |
Thu, 17 Apr 2008 00:35:08 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
Lennart Borgman (gmail) wrote:
address@hidden wrote:
It is difficult to remmeber all nice features of isearch.
Would it be possible to bind c-h to isearch-mode-help in isearch?
This is done in isearch+.el by Drew Adams.
I think you are right. Beside what Drew have I have a patch for this
(which is part of my patches in the patched version of Emacs+EmacsW32).
However I have began to rethink how such help could be implemented.
There are other rather similar cases. In tabkey2.el (see EmacsWiki) I
also needed to implement some specific help. This is what I did there:
- When the user hits the help key (f1/C-h) a message saying:
"Type a char for Emacs help. Or, wait for Tab completion help"
- If the response is k or c then specific keybindings valid during tab
completion is shown.
This way the user can have access to both a specific help and the usual
Emacs help.
I have attached a quick port of the idea above from tabkey2.el to
isearch.el. There are two versions of help here:
- f1: is the suggestion above.
- C-h: just shows the isearch-mode help
In the f1 version I do not know what to do with the messages in the echo
area after entering c or k (isearch is still active).
Index: isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.315
diff -u -b -r1.315 isearch.el
--- isearch.el 16 Mar 2008 17:44:11 -0000 1.315
+++ isearch.el 16 Apr 2008 22:26:43 -0000
@@ -391,6 +391,8 @@
;; Turned off because I find I expect to get the global definition--rms.
;; ;; Instead bind C-h to special help command for isearch-mode.
;; (define-key map "\C-h" 'isearch-mode-help)
+ (define-key map "\C-h" 'isearch-mode-help)
+ (define-key map [(f1)] 'isearch-maybe-mode-help)
(define-key map "\M-n" 'isearch-ring-advance)
(define-key map "\M-p" 'isearch-ring-retreat)
@@ -629,10 +631,46 @@
(defun isearch-mode-help ()
+ "Show isearch mode help."
(interactive)
(describe-function 'isearch-forward)
+ (with-current-buffer (help-buffer)
+ (let ((inhibit-read-only t))
+ (insert (substitute-command-keys
+ "To scroll help use \\[scroll-other-window-down] and
\\[scroll-other-window].\n\n"))))
(isearch-update))
+(defun isearch-maybe-mode-help ()
+ "Maybe show isearch mode help."
+ (interactive)
+ (let ((invoked-by-f1 (equal (this-command-keys-vector) [f1]))
+ normal-help
+ (wait-time 4))
+ (when invoked-by-f1
+ (with-timeout (wait-time (setq normal-help nil))
+ (setq normal-help
+ (read-char
+ (propertize
+ (format
+ (concat "Type a char for Emacs help."
+ " Or, wait %.0d seconds for isearch help: ")
+ wait-time)
+ 'face 'highlight)
+ nil))))
+ (case normal-help
+ ((nil)
+ ;;(message "Tab completion state help")
+ ;;(describe-function 'tabkey2-show-completion-state-help)
+ (isearch-mode-help)
+ )
+ (?c
+ (call-interactively 'describe-key-briefly))
+ (?k
+ (call-interactively 'describe-key))
+ (t
+ (isearch-mode -1)
+ (setq unread-command-events (append (this-command-keys) nil))))))
+
;; isearch-mode only sets up incremental search for the minor mode.
;; All the work is done by the isearch-mode commands.
@@ -1758,6 +1796,18 @@
((eq search-exit-option 'edit)
(apply 'isearch-unread keylist)
(isearch-edit-string))
+ ;; Always scroll other window if help buffer
+ ((let ((binding (key-binding key))
+ other-buffer-is-help)
+ (when (or (eq binding 'scroll-other-window-down)
+ (eq binding 'scroll-other-window))
+ (save-selected-window
+ (other-window 1)
+ (setq other-buffer-is-help (equal (buffer-name) "*Help*")))
+ (when other-buffer-is-help
+ (command-execute binding)
+ (isearch-update)
+ t))))
;; Handle a scrolling function.
((and isearch-allow-scroll
(progn (setq key (isearch-reread-key-sequence-naturally
keylist))
@@ -2027,10 +2077,12 @@
(if isearch-forward "" " backward")
(if current-input-method
(concat " [" current-input-method-title "]: ")
- ": ")
- )))
- (propertize (concat (upcase (substring m 0 1)) (substring m 1))
- 'face 'minibuffer-prompt)))
+ ": ")))
+ m2)
+ (setq m2 (apply 'propertize
+ (concat (upcase (substring m 0 1)) (substring m 1))
+ minibuffer-prompt-properties))
+ (propertize m2 'read-only nil)))
(defun isearch-message-suffix (&optional c-q-hack ellipsis)
(concat (if c-q-hack "^Q" "")
- binding c-h in isearch, joakim, 2008/04/16
- Re: binding c-h in isearch, Lennart Borgman (gmail), 2008/04/16
- Re: binding c-h in isearch,
Lennart Borgman (gmail) <=
- Re: binding c-h in isearch, Stefan Monnier, 2008/04/16
- Re: binding c-h in isearch, Paul R, 2008/04/16
- Re: binding c-h in isearch, joakim, 2008/04/17
- Re: binding c-h in isearch, Juri Linkov, 2008/04/17
- Re: binding c-h in isearch, Stefan Monnier, 2008/04/17
- Re: binding c-h in isearch, Juri Linkov, 2008/04/19
- Re: binding c-h in isearch, Lennart Borgman (gmail), 2008/04/19
- Re: binding c-h in isearch, Juri Linkov, 2008/04/19
- Re: binding c-h in isearch, Lennart Borgman (gmail), 2008/04/19
- Re: binding c-h in isearch, Juri Linkov, 2008/04/20