From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: binding c-h in isearch Date: Thu, 17 Apr 2008 00:35:08 +0200 Message-ID: <48067F1C.1050600@gmail.com> References: <4805FF86.3080400@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010209090607000005080704" X-Trace: ger.gmane.org 1208385363 30904 80.91.229.12 (16 Apr 2008 22:36:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Apr 2008 22:36:03 +0000 (UTC) Cc: Stefan Monnier , Drew Adams , emacs-devel@gnu.org To: joakim@verona.se Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 17 00:36:27 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JmGEf-0002va-Fc for ged-emacs-devel@m.gmane.org; Thu, 17 Apr 2008 00:36:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmGE0-0007di-Kr for ged-emacs-devel@m.gmane.org; Wed, 16 Apr 2008 18:35:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JmGDw-0007dQ-4S for emacs-devel@gnu.org; Wed, 16 Apr 2008 18:35:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JmGDu-0007dD-Q1 for emacs-devel@gnu.org; Wed, 16 Apr 2008 18:35:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmGDu-0007dA-J4 for emacs-devel@gnu.org; Wed, 16 Apr 2008 18:35:26 -0400 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JmGDt-0003F7-TX for emacs-devel@gnu.org; Wed, 16 Apr 2008 18:35:26 -0400 Original-Received: from c83-254-150-27.bredband.comhem.se ([83.254.150.27]:63599 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1JmGDr-0000rp-62; Thu, 17 Apr 2008 00:35:24 +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 In-Reply-To: <4805FF86.3080400@gmail.com> X-Antivirus: avast! (VPS 080416-0, 2008-04-16), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.150.27 X-Scan-Result: No virus found in message 1JmGDr-0000rp-62. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1JmGDr-0000rp-62 c527bb41973e22802f5563b5fb0d483a X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95372 Archived-At: This is a multi-part message in MIME format. --------------010209090607000005080704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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). --------------010209090607000005080704 Content-Type: text/plain; name="isearch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="isearch.diff" 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" "") --------------010209090607000005080704--