unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* binding c-h in isearch
@ 2008-04-16 12:10 joakim
  2008-04-16 13:30 ` Lennart Borgman (gmail)
  2008-04-16 15:28 ` Stefan Monnier
  0 siblings, 2 replies; 22+ messages in thread
From: joakim @ 2008-04-16 12:10 UTC (permalink / raw)
  To: emacs-devel

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.
-- 
Joakim Verona




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  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)
  2008-04-16 15:28 ` Stefan Monnier
  1 sibling, 1 reply; 22+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-16 13:30 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

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.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-16 12:10 binding c-h in isearch joakim
  2008-04-16 13:30 ` Lennart Borgman (gmail)
@ 2008-04-16 15:28 ` Stefan Monnier
  2008-04-16 17:44   ` Paul R
                     ` (3 more replies)
  1 sibling, 4 replies; 22+ messages in thread
From: Stefan Monnier @ 2008-04-16 15:28 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

> It is difficult to remmeber all nice features of isearch.
> Would it be possible to bind c-h to isearch-mode-help in isearch?

There's the following code in isearch.el:

    ;; 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)

So it seems that Richard found it inconvenient.  Could someone try and
work out some clever way to reconcile the two functionalities?

E.g. provide the generic help on C-h but the isearch-specific help on
C-h C-h, or vice versa?


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-16 15:28 ` Stefan Monnier
@ 2008-04-16 17:44   ` Paul R
  2008-04-17 19:25   ` joakim
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Paul R @ 2008-04-16 17:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joakim, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>     ;; 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)
>
> So it seems that Richard found it inconvenient.  Could someone try and
> work out some clever way to reconcile the two functionalities?

Here, C-h during isearch will exit current isearch session, just like
C-x or C-c. IOW, this keystroke will trigger global definition, with
first the *side effect* of leaving current isearch session. So I mean,
it is not like if we could, for example, *temporarily* check what
command is bound to C-w is isearch-mode-map, by typing, in an isearch
session, C-h c C-w. It will just return 'kill-region'.

My personal point of view : 
 - isearch-mode-help explains how to exit an isearch session, namely
   C-g to go back to starting point and C-m to leave the point at
   location found. Any other way to exit has no reason to be
   supported, or should be mentionned as a feature somewhere.
 - isearch already rebinds many control caracters, C-h would be one
   more and quiet an intuitive one

So, +1 for C-h bound in isearch-mode-map.

>
> E.g. provide the generic help on C-h but the isearch-specific help on
> C-h C-h, or vice versa?

generic help on C-m C-h or C-g C-h ... well, that's not isearch
business, is it ? :)

-- 
      Paul




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-16 13:30 ` Lennart Borgman (gmail)
@ 2008-04-16 22:35   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 22+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-16 22:35 UTC (permalink / raw)
  To: joakim; +Cc: Stefan Monnier, Drew Adams, emacs-devel

[-- 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" "")

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  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-19 21:20   ` Drew Adams
  3 siblings, 0 replies; 22+ messages in thread
From: joakim @ 2008-04-17 19:25 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It is difficult to remmeber all nice features of isearch.
>> Would it be possible to bind c-h to isearch-mode-help in isearch?
>
> There's the following code in isearch.el:
>
>     ;; 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)
>
> So it seems that Richard found it inconvenient.  Could someone try and
> work out some clever way to reconcile the two functionalities?
>
> E.g. provide the generic help on C-h but the isearch-specific help on
> C-h C-h, or vice versa?

For instance checkdoc, included in emacs, uses c-h as a local help key.
calc uses "h" or "?" for local help. isearch has a local help function
but no binding.

Would it be possible to find some consistent convention for local-help
keybindings? Maybe "c-h q" for quick-help?


>
>         Stefan
-- 
Joakim Verona




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  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-18 10:59     ` Johan Bockgård
  2008-04-19 21:20   ` Drew Adams
  3 siblings, 2 replies; 22+ messages in thread
From: Juri Linkov @ 2008-04-17 23:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joakim, emacs-devel

> There's the following code in isearch.el:
>
>     ;; 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)
>
> So it seems that Richard found it inconvenient.  Could someone try and
> work out some clever way to reconcile the two functionalities?

I think a good binding for C-h in isearch-mode would be the following:

    (define-key isearch-mode-map "\C-h" help-map)

I gives what Richard wants since it uses the global definition of C-h,
and still it is intuitive to use just like its global definition when
a minor mode is active:

C-h m describes the isearch mode among other minor modes,

C-h b displays all isearch keybindings at the beginning of a list of all
      global keybindings (since it lists keys of minor modes first),

C-h k describes a key of isearch-mode that is natural to expect
      when C-h k is typed when isearch mode is active, so `C-h k C-w'
      will display:

  C-w runs the command isearch-yank-word-or-char, which is an
  interactive compiled Lisp function in `isearch.el'.

  (isearch-yank-word-or-char)

  Pull next character or word from buffer into search string.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-17 23:14   ` Juri Linkov
@ 2008-04-18  0:42     ` Stefan Monnier
  2008-04-19 20:07       ` Juri Linkov
  2008-04-18 10:59     ` Johan Bockgård
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2008-04-18  0:42 UTC (permalink / raw)
  To: Juri Linkov; +Cc: joakim, emacs-devel

>> There's the following code in isearch.el:
>> 
>> ;; 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)
>> 
>> So it seems that Richard found it inconvenient.  Could someone try and
>> work out some clever way to reconcile the two functionalities?

> I think a good binding for C-h in isearch-mode would be the following:

>     (define-key isearch-mode-map "\C-h" help-map)

> I gives what Richard wants since it uses the global definition of C-h,
> and still it is intuitive to use just like its global definition when
> a minor mode is active:

> C-h m describes the isearch mode among other minor modes,

Sounds good, indeed.

Could we tweak this so it gives an info closer to what
isearch-help-mode gives?  I.e. move the info from isearch-forward's
docstring to isearch-mode's docstring, and tweka C-h m so that
isearch-mode's info comes first.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-17 23:14   ` Juri Linkov
  2008-04-18  0:42     ` Stefan Monnier
@ 2008-04-18 10:59     ` Johan Bockgård
  1 sibling, 0 replies; 22+ messages in thread
From: Johan Bockgård @ 2008-04-18 10:59 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> I think a good binding for C-h in isearch-mode would be the following:
>
>     (define-key isearch-mode-map "\C-h" help-map)
>
> I gives what Richard wants since it uses the global definition of C-h,
> and still it is intuitive to use just like its global definition when
> a minor mode is active:

It does not work well with help commands that read input from the
minibuffer, like C-h v, C-h f, C-h a etc.

-- 
Johan Bockgård





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  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 20:57         ` Stefan Monnier
  0 siblings, 2 replies; 22+ messages in thread
From: Juri Linkov @ 2008-04-19 20:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joakim, emacs-devel

>> I think a good binding for C-h in isearch-mode would be the following:
>
>>     (define-key isearch-mode-map "\C-h" help-map)
>
>> I gives what Richard wants since it uses the global definition of C-h,
>> and still it is intuitive to use just like its global definition when
>> a minor mode is active:
>
>> C-h m describes the isearch mode among other minor modes,
>
> Sounds good, indeed.
>
> Could we tweak this so it gives an info closer to what
> isearch-help-mode gives?  I.e. move the info from isearch-forward's
> docstring to isearch-mode's docstring, and tweak C-h m so that
> isearch-mode's info comes first.

I think it is useful to leave the full info on `isearch-forward' to be
helpful for `C-h k C-s' to get the full info about isearch.  But as
Johan pointed out there are other problems with this approach.

I wrote a patch that cures all there problems by using the proper
treatment of help commands in isearch mode.  It uses `make-help-screen'
to create isearch specific help screen, creates a new map `isearch-help-map'
and binds all characters to `isearch-other-control-char' (exactly as
`isearch-mode-map' binds all characters to this command before redefining
some of them in isearch mode).  This fixes the problem Johan reported, so
any character not redefined will be passed to `isearch-other-control-char'
to treat it normally and to exit isearch before invoking its global
help command.

Also I noticed another problem: when `same-window-buffer-names' or
`same-window-regexps' is redefined to display the *Help* buffer in the
same window, it makes impossible to continue using isearch in the current
window because it continues operating on the *Help* buffer in the same
window.  So it is necessary to bind `same-window-buffer-names' and
`same-window-regexps' to nil temporarily to force displaying the Help
buffer in another window.

All these changes provide the following new behavior: in isearch mode
to get isearch specific help, the user types `C-h' and sees the message:

   C-h (Type ? for further options)-

After typing `?' or `C-h' or `f1', the user sees the full help screen
with most important isearch help commands: `b', `k' and `m'.
(`c' is useless because the "I-search: " prompt overwrites the
single line displayed in the echo area by `describe-key-briefly')

These three help commands are important in isearch mode, because it is
impossible to easily get their information outside isearch mode using
global help commands.  All the rest global help commands are not isearch
specific, so e.g. `C-h f isearch-forward' gives the same info in isearch
mode as well as globally.  In isearch mode, these global help commands
will exit isearch mode and invoke their global definitions, as Richard
wants according to his comment in isearch.el.

This patch also removes the full list of all isearch commands from the
docstring of `isearch-mode' because most other modes don't have such
a list in their docstrings, and anyway this list is now available via
`C-h b'.  (Also it leaves a single sentence on its docstring, and prepends
the word "function" before the reference to `isearch-forward' in the
docstring to force this link to lead to the definition of the function,
not the variable).

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.316
diff -c -r1.316 isearch.el
*** lisp/isearch.el	18 Apr 2008 10:29:23 -0000	1.316
--- lisp/isearch.el	19 Apr 2008 20:04:05 -0000
***************
*** 322,327 ****
--- 322,396 ----
                                  'lazy-highlight-face
                                  "22.1")
  \f
+ ;; Define isearch help map.
+ 
+ (eval-when-compile (require 'help-macro))
+ 
+ (make-help-screen isearch-help-for-help-internal
+   "Type a help option: [bkm] or ?"
+   "You have typed %THIS-KEY%, the help character.  Type a Help option:
+ \(Type \\<help-map>\\[help-quit] to exit the Help command.)
+ 
+ b           Display all isearch key bindings.
+ k KEYS      Display the full documentation for the isearch key sequence.
+ m           Display documentation of isearch mode.
+ 
+ You can't type here other help keys available in the global help map,
+ but outise of this help window when you type them in isearch mode,
+ they exit isearch mode before displaying global help."
+   isearch-help-map)
+ 
+ (defvar isearch-help-map
+   (let ((i 0)
+ 	(map (make-sparse-keymap)))
+     (while (< i 256)
+       (define-key map (vector i) 'isearch-other-control-char)
+       (setq i (1+ i)))
+     (define-key map (char-to-string help-char) 'isearch-help-for-help)
+     (define-key map [help] 'isearch-help-for-help)
+     (define-key map [f1] 'isearch-help-for-help)
+     (define-key map "?" 'isearch-help-for-help)
+     (define-key map "b" 'isearch-describe-bindings)
+     (define-key map "k" 'isearch-describe-key)
+     (define-key map "m" 'isearch-describe-mode)
+     (define-key map "q" 'help-quit)
+     map)
+   "Keymap for characters following the Help key for isearch mode.")
+ 
+ (defun isearch-help-for-help ()
+   "Display isearch help menu."
+   (interactive)
+   (let (same-window-buffer-names same-window-regexps)
+     (isearch-help-for-help-internal))
+   (isearch-update))
+ 
+ (defun isearch-describe-bindings ()
+   "Show a list of all keys defined in isearch mode, and their definitions.
+ This is like `describe-bindings', but displays only isearch keys."
+   (interactive)
+   (let (same-window-buffer-names same-window-regexps)
+     (with-help-window "*Help*"
+       (with-current-buffer standard-output
+ 	(princ "Isearch Mode Bindings:\n")
+ 	(princ (substitute-command-keys "\\{isearch-mode-map}"))))))
+ 
+ (defun isearch-describe-key ()
+   "Display documentation of the function invoked by isearch key."
+   (interactive)
+   (let (same-window-buffer-names same-window-regexps)
+     (call-interactively 'describe-key))
+   (isearch-update))
+ 
+ (defun isearch-describe-mode ()
+   "Display documentation of isearch mode."
+   (interactive)
+   (let (same-window-buffer-names same-window-regexps)
+     (describe-function 'isearch-forward))
+   (isearch-update))
+ 
+ (defalias 'isearch-mode-help 'isearch-describe-mode)
+ 
+ \f
  ;; Define isearch-mode keymap.
  
  (defvar isearch-mode-map
***************
*** 391,396 ****
--- 460,466 ----
      ;; 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-help-map)
  
      (define-key map "\M-n" 'isearch-ring-advance)
      (define-key map "\M-p" 'isearch-ring-retreat)
***************
*** 575,580 ****
--- 645,654 ----
   ring.
  Type \\[isearch-complete] to complete the search string using the search ring.
  
+ Type \\[isearch-describe-bindings] to display all isearch key bindings.
+ Type \\[isearch-describe-key] to display documentation of isearch key.
+ Type \\[isearch-describe-mode] to display documentation of isearch mode.
+ 
  If an input method is turned on in the current buffer, that input
  method is also active while you are typing characters to search.  To
  toggle the input method, type \\[isearch-toggle-input-method].  It
***************
*** 627,638 ****
    (interactive "P\np")
    (isearch-mode nil (null not-regexp) nil (not no-recursive-edit)))
  
- 
- (defun isearch-mode-help ()
-   (interactive)
-   (describe-function 'isearch-forward)
-   (isearch-update))
- 
  \f
  ;; isearch-mode only sets up incremental search for the minor mode.
  ;; All the work is done by the isearch-mode commands.
--- 701,706 ----
***************
*** 644,652 ****
  
  
  (defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p)
!   "Start isearch minor mode.  Called by `isearch-forward', etc.
! 
! \\{isearch-mode-map}"
  
    ;; Initialize global vars.
    (setq isearch-forward forward
--- 712,719 ----
  
  
  (defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p)
!   "Start isearch minor mode.
! It is called by the function `isearch-forward' and other related functions."
  
    ;; Initialize global vars.
    (setq isearch-forward forward

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 20:07       ` Juri Linkov
@ 2008-04-19 20:49         ` Lennart Borgman (gmail)
  2008-04-19 22:52           ` Juri Linkov
  2008-04-19 20:57         ` Stefan Monnier
  1 sibling, 1 reply; 22+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-19 20:49 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Stefan Monnier, joakim, emacs-devel

Juri Linkov wrote:
> Also I noticed another problem: when `same-window-buffer-names' or
> `same-window-regexps' is redefined to display the *Help* buffer in the
> same window, it makes impossible to continue using isearch in the current
> window because it continues operating on the *Help* buffer in the same
> window.  So it is necessary to bind `same-window-buffer-names' and
> `same-window-regexps' to nil temporarily to force displaying the Help
> buffer in another window.


Your patch sounds nice. Two small points:

- Shouldn't you allow scroll-other-window-up/down too when the other 
window displays the help buffer?

- Can't you do a sit-for after displaying C-h c help? I think that is 
the way it is treated when you for example do

   M-x and then C-h c

(Though I would prefer a longer default display time there.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 20:07       ` Juri Linkov
  2008-04-19 20:49         ` Lennart Borgman (gmail)
@ 2008-04-19 20:57         ` Stefan Monnier
  2008-04-19 22:49           ` Juri Linkov
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2008-04-19 20:57 UTC (permalink / raw)
  To: Juri Linkov; +Cc: joakim, emacs-devel

> window.  So it is necessary to bind `same-window-buffer-names' and
> `same-window-regexps' to nil temporarily to force displaying the Help
> buffer in another window.

That works around the problem but doesn't fix it.  You can specify
`same-window' in special-display-regexp, for example.  Or you could
encounter similar problems by setting display-buffer-function, etc...
A real fix is to make sure we return to the proper window and buffer
when we get back to the main search loop.

> +     (while (< i 256)
> +       (define-key map (vector i) 'isearch-other-control-char)
> +       (setq i (1+ i)))

This doesn't look right.  You probably just want to use

       (define-key map [t] 'isearch-other-control-char)

instead.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: binding c-h in isearch
  2008-04-16 15:28 ` Stefan Monnier
                     ` (2 preceding siblings ...)
  2008-04-17 23:14   ` Juri Linkov
@ 2008-04-19 21:20   ` Drew Adams
  2008-04-19 21:49     ` Stefan Monnier
  2008-04-19 22:59     ` Juri Linkov
  3 siblings, 2 replies; 22+ messages in thread
From: Drew Adams @ 2008-04-19 21:20 UTC (permalink / raw)
  To: 'Stefan Monnier', joakim; +Cc: emacs-devel

> > It is difficult to remmeber all nice features of isearch.
> > Would it be possible to bind c-h to isearch-mode-help in isearch?
> 
> There's the following code in isearch.el:
> 
>     ;; 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)
> 
> So it seems that Richard found it inconvenient.  Could someone try and
> work out some clever way to reconcile the two functionalities?
> 
> E.g. provide the generic help on C-h but the isearch-specific help on
> C-h C-h, or vice versa?

Since this can of worms has been opened and stirred...

FWIW, I disagree with the approach being considered (Juri's suggestion etc.). It
is complicated for nothing. The simplest approach is the best: C-h during
isearch should give the isearch bindings - bind C-h to `isearch-mode-help'.

That is the convention, and it is a good one. This is like C-h following any
other prefix key. Richard is just wrong about this. Why jump through hoops?

If you are isearching and you want the global help, then (guess what?) you
simply exit isearch: RET or whatever. Nothing hard about that.

Nothing new here. No need for fancy, inconsistent stuff. No need to complicate
the UI. Just C-s...C-h to see the isearch bindings and C-s...RET C-h to see the
global help.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  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
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2008-04-19 21:49 UTC (permalink / raw)
  To: Drew Adams; +Cc: joakim, emacs-devel

> FWIW, I disagree with the approach being considered (Juri's suggestion
> etc.). It is complicated for nothing. The simplest approach is the
> best: C-h during isearch should give the isearch bindings - bind C-h
> to `isearch-mode-help'.

> That is the convention, and it is a good one. This is like C-h following any
> other prefix key. Richard is just wrong about this. Why jump through hoops?

I like the simplicity of it, indeed.  But I also agree that C-h k during
isearch would come in handy sometimes, so it is a good idea to try and
make it work.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: binding c-h in isearch
  2008-04-19 21:49     ` Stefan Monnier
@ 2008-04-19 22:39       ` Drew Adams
  0 siblings, 0 replies; 22+ messages in thread
From: Drew Adams @ 2008-04-19 22:39 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: joakim, emacs-devel

> > bind C-h to `isearch-mode-help'.
> 
> I like the simplicity of it, indeed.  But I also agree that 
> C-h k during isearch would come in handy sometimes, so it is
> a good idea to try and make it work.

That's a very minor advantage. And with the conventional approach, you would
have that info anyway, once you have displayed the isearch-mode help, at the
cost of an extra key hit or two. With the conventional approach, you would see
succinct help about _only_ isearch mode, and you could always drill down for
more detailed info if you want.

The proposed approach, besides making the UI less conventional and so more
complex, will make you wade through the other global C-h crap (either an extra
prompt or the complete C-h C-h display) to get to whatever might be specific to
isearch mode. The same is true even if we show the C-h m display instead of the
C-h C-h display: it contains stuff that is extraneous to isearch.

IOW, either you want (truly) global help (what RMS asked for) or you want
isearch-mode help. The proposed approach gives you something halfway between.
And it's not even obvious (esp. to newbies) that it does that - you might think
that you're seeing vanilla global help, not help tailored for a particular mode.

[Yes, that can be true for other modes too, but isearch-mode is a bit peculiar.
It is not a conventional minor mode. You cannot do M-x isearch-mode to enter
isearch minor mode - isearch-mode is not even a command (and isearch-minor-mode
doesn't even exist). And if you do M-: (isearch-mode t), the top of the help
buffer says "isearch-forward is...", not "isearch-mode is...".]






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 20:57         ` Stefan Monnier
@ 2008-04-19 22:49           ` Juri Linkov
  0 siblings, 0 replies; 22+ messages in thread
From: Juri Linkov @ 2008-04-19 22:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joakim, emacs-devel

>> window.  So it is necessary to bind `same-window-buffer-names' and
>> `same-window-regexps' to nil temporarily to force displaying the Help
>> buffer in another window.
>
> That works around the problem but doesn't fix it.  You can specify
> `same-window' in special-display-regexp, for example.  Or you could
> encounter similar problems by setting display-buffer-function, etc...
> A real fix is to make sure we return to the proper window and buffer
> when we get back to the main search loop.

Currently I see no place in the main search loop to do this,
and implementing this properly would add too much complexity
to already very complex isearch mode.  So if this works in 99%
cases, I think this wourkaround would be ok.

>> +     (while (< i 256)
>> +       (define-key map (vector i) 'isearch-other-control-char)
>> +       (setq i (1+ i)))
>
> This doesn't look right.  You probably just want to use
>
>        (define-key map [t] 'isearch-other-control-char)

I tested this, and it works correctly.  Thanks for the hint.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 20:49         ` Lennart Borgman (gmail)
@ 2008-04-19 22:52           ` Juri Linkov
  2008-04-20  0:53             ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2008-04-19 22:52 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Stefan Monnier, joakim, emacs-devel

> Your patch sounds nice. Two small points:
>
> - Shouldn't you allow scroll-other-window-up/down too when the other
> window displays the help buffer?

There is a special variable `isearch-allow-scroll'.  I think we should
set it to t.

> - Can't you do a sit-for after displaying C-h c help? I think that is the
> way it is treated when you for example do
>
>   M-x and then C-h c

I see nothing when I do `M-x C-h c', so it doesn't work anyway.

But I think `C-h c' is not important in isearch mode when `C-h k'
works correctly.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 21:20   ` Drew Adams
  2008-04-19 21:49     ` Stefan Monnier
@ 2008-04-19 22:59     ` Juri Linkov
  2008-04-19 23:39       ` Drew Adams
  1 sibling, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2008-04-19 22:59 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Stefan Monnier', joakim, emacs-devel

>> > It is difficult to remmeber all nice features of isearch.
>> > Would it be possible to bind c-h to isearch-mode-help in isearch?
>>
>> There's the following code in isearch.el:
>>
>>     ;; 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)
>>
>> So it seems that Richard found it inconvenient.  Could someone try and
>> work out some clever way to reconcile the two functionalities?
>>
>> E.g. provide the generic help on C-h but the isearch-specific help on
>> C-h C-h, or vice versa?
>
> Since this can of worms has been opened and stirred...
>
> FWIW, I disagree with the approach being considered (Juri's suggestion etc.). It
> is complicated for nothing. The simplest approach is the best: C-h during
> isearch should give the isearch bindings - bind C-h to `isearch-mode-help'.
>
> That is the convention, and it is a good one. This is like C-h following any
> other prefix key. Richard is just wrong about this. Why jump through hoops?

Isearch mode is a mode, not a prefix key.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: binding c-h in isearch
  2008-04-19 22:59     ` Juri Linkov
@ 2008-04-19 23:39       ` Drew Adams
  0 siblings, 0 replies; 22+ messages in thread
From: Drew Adams @ 2008-04-19 23:39 UTC (permalink / raw)
  To: 'Juri Linkov'; +Cc: 'Stefan Monnier', joakim, emacs-devel

> Isearch mode is a mode, not a prefix key.

Bof. It's been rebaptized a mode, but a rose by any other name... See my other
mail about its unconventional minor-modeness[*].

To me, the help you want when using isearch is precisely that given by
isearch-mode-help. This is what C-h should give you.

[* Isearch is peculiar in several ways (which doesn't make it bad), starting
with the fact that it uses the echo area, even though users can get the
impression that it uses the minibuffer. (Yes, it uses the minibuffer for
search-string editing and completion, but not to read incremental search-string
input.)]





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-19 22:52           ` Juri Linkov
@ 2008-04-20  0:53             ` Lennart Borgman (gmail)
  2008-04-20 23:51               ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-20  0:53 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Stefan Monnier, joakim, emacs-devel

Juri Linkov wrote:
> I see nothing when I do `M-x C-h c', so it doesn't work anyway.

I see nothing after C-h, but after c I get the usual prompt for C-h c. 
Don't you get that?




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-20  0:53             ` Lennart Borgman (gmail)
@ 2008-04-20 23:51               ` Juri Linkov
  2008-04-21  0:13                 ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2008-04-20 23:51 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Stefan Monnier, joakim, emacs-devel

>> I see nothing when I do `M-x C-h c', so it doesn't work anyway.
>
> I see nothing after C-h, but after c I get the usual prompt for C-h c.
> Don't you get that?

I meant that I don't see the one-line key description after typing a key
on the prompt for `C-h c'.  M-x overwrites the echo area with the key
description.  I think this is not a real problem since there is `C-h k'
that displays a more persistent Help window.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: binding c-h in isearch
  2008-04-20 23:51               ` Juri Linkov
@ 2008-04-21  0:13                 ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 22+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-21  0:13 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Stefan Monnier, joakim, emacs-devel

Juri Linkov wrote:
>>> I see nothing when I do `M-x C-h c', so it doesn't work anyway.
>> I see nothing after C-h, but after c I get the usual prompt for C-h c.
>> Don't you get that?
> 
> I meant that I don't see the one-line key description after typing a key
> on the prompt for `C-h c'.  M-x overwrites the echo area with the key
> description.  I think this is not a real problem since there is `C-h k'
> that displays a more persistent Help window.

I see the one-line description but it is replaced with the M-x prompt 
after a (too) short delay. Don't you see the one-line description at all?




^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2008-04-21  0:13 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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)
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

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).