unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: joakim@verona.se
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Drew Adams <drew.adams@oracle.com>,
	emacs-devel@gnu.org
Subject: Re: binding c-h in isearch
Date: Thu, 17 Apr 2008 00:35:08 +0200	[thread overview]
Message-ID: <48067F1C.1050600@gmail.com> (raw)
In-Reply-To: <4805FF86.3080400@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]

Lennart Borgman (gmail) wrote:
> joakim@verona.se 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).

[-- Attachment #2: isearch.diff --]
[-- Type: text/plain, Size: 3691 bytes --]

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))))))
+
 \f
 ;; 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" "")

  reply	other threads:[~2008-04-16 22:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-16 12:10 binding c-h in isearch joakim
2008-04-16 13:30 ` Lennart Borgman (gmail)
2008-04-16 22:35   ` Lennart Borgman (gmail) [this message]
2008-04-16 15:28 ` Stefan Monnier
2008-04-16 17:44   ` Paul R
2008-04-17 19:25   ` joakim
2008-04-17 23:14   ` Juri Linkov
2008-04-18  0:42     ` Stefan Monnier
2008-04-19 20:07       ` Juri Linkov
2008-04-19 20:49         ` Lennart Borgman (gmail)
2008-04-19 22:52           ` Juri Linkov
2008-04-20  0:53             ` Lennart Borgman (gmail)
2008-04-20 23:51               ` Juri Linkov
2008-04-21  0:13                 ` Lennart Borgman (gmail)
2008-04-19 20:57         ` Stefan Monnier
2008-04-19 22:49           ` Juri Linkov
2008-04-18 10:59     ` Johan Bockgård
2008-04-19 21:20   ` Drew Adams
2008-04-19 21:49     ` Stefan Monnier
2008-04-19 22:39       ` Drew Adams
2008-04-19 22:59     ` Juri Linkov
2008-04-19 23:39       ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48067F1C.1050600@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=joakim@verona.se \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).