unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10771: TAB completion for info-display-manual
@ 2012-02-09  6:36 Glenn Morris
  2012-02-09  9:28 ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2012-02-09  6:36 UTC (permalink / raw)
  To: 10771

Package: emacs
Version: 24.0.93
Severity: wishlist

emacs -Q 
M-x info-display-manual RET em TAB

I hoped this would offer completion over the manuals in my INFOPATH, but
it just inserts a literal tab.





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

* bug#10771: TAB completion for info-display-manual
  2012-02-09  6:36 bug#10771: TAB completion for info-display-manual Glenn Morris
@ 2012-02-09  9:28 ` Juri Linkov
  2012-02-09 18:42   ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-02-09  9:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 10771

tags 10771 patch
thanks

> M-x info-display-manual RET em TAB
>
> I hoped this would offer completion over the manuals in my INFOPATH, but
> it just inserts a literal tab.

This patch offers completion:

=== modified file 'lisp/info.el'
--- lisp/info.el	2012-01-25 17:54:01 +0000
+++ lisp/info.el	2012-02-09 09:27:10 +0000
@@ -4984,7 +4984,13 @@ (defun Info-bookmark-jump (bmk)
 ;;;###autoload
 (defun info-display-manual (manual)
   "Go to Info buffer that displays MANUAL, creating it if none already exists."
-  (interactive "sManual name: ")
+  (interactive
+   (list
+    (completing-read "Manual name: "
+		     (apply-partially 'Info-read-node-name-2
+				      Info-directory-list
+				      (mapcar 'car Info-suffix-list))
+		     nil t)))
   (let ((blist (buffer-list))
 	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
 	(case-fold-search t)






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

* bug#10771: TAB completion for info-display-manual
  2012-02-09  9:28 ` Juri Linkov
@ 2012-02-09 18:42   ` Eli Zaretskii
  2012-02-10 10:17     ` Juri Linkov
  2012-12-02  6:44     ` Chong Yidong
  0 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2012-02-09 18:42 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10771

> From: Juri Linkov <juri@jurta.org>
> Date: Thu, 09 Feb 2012 11:28:18 +0200
> Cc: 10771@debbugs.gnu.org
> 
> > M-x info-display-manual RET em TAB
> >
> > I hoped this would offer completion over the manuals in my INFOPATH, but
> > it just inserts a literal tab.
> 
> This patch offers completion:
> 
> === modified file 'lisp/info.el'
> --- lisp/info.el	2012-01-25 17:54:01 +0000
> +++ lisp/info.el	2012-02-09 09:27:10 +0000
> @@ -4984,7 +4984,13 @@ (defun Info-bookmark-jump (bmk)
>  ;;;###autoload
>  (defun info-display-manual (manual)
>    "Go to Info buffer that displays MANUAL, creating it if none already exists."
> -  (interactive "sManual name: ")
> +  (interactive
> +   (list
> +    (completing-read "Manual name: "
> +		     (apply-partially 'Info-read-node-name-2
> +				      Info-directory-list
> +				      (mapcar 'car Info-suffix-list))
> +		     nil t)))
>    (let ((blist (buffer-list))
>  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
>  	(case-fold-search t)

Thanks, but this is wrong: it should offer completion only on Info
buffers that already exist in the current session.  Completion on
manuals installed on the system is perhaps for "C-u C-h i" or some
variation of it.

The purpose of this command is to assist with switching between
manuals that are already loaded, not in adding others.





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

* bug#10771: TAB completion for info-display-manual
  2012-02-09 18:42   ` Eli Zaretskii
@ 2012-02-10 10:17     ` Juri Linkov
  2012-12-02  6:44     ` Chong Yidong
  1 sibling, 0 replies; 12+ messages in thread
From: Juri Linkov @ 2012-02-10 10:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 10771

> The purpose of this command is to assist with switching between
> manuals that are already loaded, not in adding others.

If you often switch between loaded manuals, then this is easy to do
using the minibuffer history commands, e.g. after visiting two manuals:

M-x info-display-manual RET gnus RET
M-x info-display-manual RET emacs RET

switching between these two manuals:

M-x info-display-manual RET M-p M-p RET
M-x info-display-manual RET M-p M-p RET

BTW, do you know that an easy way to switch between manuals is using

`C-1 C-h i'
`C-2 C-h i'
`C-3 C-h i'
etc.

This is similar to switching between numbered frames
with e.g. `C-2 C-x 5 o'.

Do you switch them using frame numbers or frame names
with the command `select-frame-by-name'?

Maybe then `info-display-manual' should be renamed to
`info-select-manual-by-name'?





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

* bug#10771: TAB completion for info-display-manual
  2012-02-09 18:42   ` Eli Zaretskii
  2012-02-10 10:17     ` Juri Linkov
@ 2012-12-02  6:44     ` Chong Yidong
  2012-12-02 17:25       ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2012-12-02  6:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 10771

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, but this is wrong: it should offer completion only on Info
> buffers that already exist in the current session.  Completion on
> manuals installed on the system is perhaps for "C-u C-h i" or some
> variation of it.
>
> The purpose of this command is to assist with switching between
> manuals that are already loaded, not in adding others.

I disagree; completion should be provided for any value that the command
accepts as an argument, so Juri's patch does the right thing.  I've
committed it to trunk (with a minor fix).

(If one wishes to get fancy, I suppose one could define a completion
category override to cause completion to favor manuals in existing Info
buffers.  Not sure if that would produce confusing results, though.)





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

* bug#10771: TAB completion for info-display-manual
  2012-12-02  6:44     ` Chong Yidong
@ 2012-12-02 17:25       ` Eli Zaretskii
  2012-12-02 21:12         ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2012-12-02 17:25 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 10771

> From: Chong Yidong <cyd@gnu.org>
> Cc: Juri Linkov <juri@jurta.org>,  10771@debbugs.gnu.org,  rgm@gnu.org
> Date: Sun, 02 Dec 2012 14:44:45 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Thanks, but this is wrong: it should offer completion only on Info
> > buffers that already exist in the current session.  Completion on
> > manuals installed on the system is perhaps for "C-u C-h i" or some
> > variation of it.
> >
> > The purpose of this command is to assist with switching between
> > manuals that are already loaded, not in adding others.
> 
> I disagree; completion should be provided for any value that the command
> accepts as an argument, so Juri's patch does the right thing.

No, it doesn't.  The command looks up its argument among Info
_buffers_ first, and only if not found, falls back to searching the
manuals installed on the system.  So at the very least, the completion
should include in the collection the manuals loaded into Info buffers
in the current session.  Because manuals loaded into my Info buffers
do not necessarily reflect Info files on my disk.

> If one wishes to get fancy, I suppose one could define a completion
> category override to cause completion to favor manuals in existing Info
> buffers.

There's no need to favor existing buffers, but there is a need to
include them in the completion.





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

* bug#10771: TAB completion for info-display-manual
  2012-12-02 17:25       ` Eli Zaretskii
@ 2012-12-02 21:12         ` Juri Linkov
  2012-12-02 21:32           ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-12-02 21:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 10771, Chong Yidong

> Because manuals loaded into my Info buffers do not necessarily reflect
> Info files on my disk.

Is this because you delete Info files from the disk leaving open
their Info buffers?  I'm not sure whether additional complexity
is necessary to handle completion for such rare cases, but at least
the minibuffer should allow you to enter such manual names.
I mean changing the REQUIRE-MATCH arg of `completing-read' from t to nil,
so you can still enter these manual names like at the time when
this command accepted a plain string before the latest change.

=== modified file 'lisp/info.el'
--- lisp/info.el	2012-12-02 20:07:04 +0000
+++ lisp/info.el	2012-12-02 21:11:17 +0000
@@ -5138,7 +5138,7 @@ (defun info-display-manual (manual)
 		       (apply-partially 'Info-read-node-name-2
 					Info-directory-list
 					(mapcar 'car Info-suffix-list))
-		       nil t))))
+		       nil nil))))
   (let ((blist (buffer-list))
 	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
 	(case-fold-search t)






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

* bug#10771: TAB completion for info-display-manual
  2012-12-02 21:12         ` Juri Linkov
@ 2012-12-02 21:32           ` Eli Zaretskii
  2012-12-02 21:57             ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2012-12-02 21:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10771, cyd

> From: Juri Linkov <juri@jurta.org>
> Cc: Chong Yidong <cyd@gnu.org>,  10771@debbugs.gnu.org,  rgm@gnu.org
> Date: Sun, 02 Dec 2012 23:12:35 +0200
> 
> > Because manuals loaded into my Info buffers do not necessarily reflect
> > Info files on my disk.
> 
> Is this because you delete Info files from the disk leaving open
> their Info buffers?

No, it's because I don't want to be restricted to manuals found in
directories that are mentioned in Info-directory-list.

In general, the Info buffers in the session should not be restricted
to what "M-x info" can find, because we have "C-u C-h i" and other
methods of loading manuals by their exact file name.

> I'm not sure whether additional complexity is necessary to handle
> completion for such rare cases

Well, _I_ wrote this command, and I needed it precisely because I have
dozens of Info manuals loaded in my usual Emacs session.  This case is
not rare for me.


> but at least
> the minibuffer should allow you to enter such manual names.
> I mean changing the REQUIRE-MATCH arg of `completing-read' from t to nil,
> so you can still enter these manual names like at the time when
> this command accepted a plain string before the latest change.
> 
> === modified file 'lisp/info.el'
> --- lisp/info.el	2012-12-02 20:07:04 +0000
> +++ lisp/info.el	2012-12-02 21:11:17 +0000
> @@ -5138,7 +5138,7 @@ (defun info-display-manual (manual)
>  		       (apply-partially 'Info-read-node-name-2
>  					Info-directory-list
>  					(mapcar 'car Info-suffix-list))
> -		       nil t))))
> +		       nil nil))))
>    (let ((blist (buffer-list))
>  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
>  	(case-fold-search t)

How is this better than the original command against which this bug
was filed?





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

* bug#10771: TAB completion for info-display-manual
  2012-12-02 21:32           ` Eli Zaretskii
@ 2012-12-02 21:57             ` Juri Linkov
  2012-12-03  3:37               ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-12-02 21:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 10771, cyd

>> @@ -5138,7 +5138,7 @@ (defun info-display-manual (manual)
>>  		       (apply-partially 'Info-read-node-name-2
>>  					Info-directory-list
>>  					(mapcar 'car Info-suffix-list))
>> -		       nil t))))
>> +		       nil nil))))
>>    (let ((blist (buffer-list))
>>  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
>>  	(case-fold-search t)
>
> How is this better than the original command against which this bug
> was filed?

At least this is not worse than the original command that reads a manual name
without completion.  Completion is useful to read a manual name that is
not already visited.  So when you want to visit a new manual, you can use
completion, when a manual is already visited, you can type its name
and get it from the history with M-p.

BTW, there is another problem with selecting an Info buffer
by its Info file name: what if there are two Info buffers
visiting a manual with the same name.  Which one of them
should be preferred by this command?  Also which manual should be
preferred in completion when one manual is already visited
and another manual with the same name is available in Info-directory-list?





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

* bug#10771: TAB completion for info-display-manual
  2012-12-02 21:57             ` Juri Linkov
@ 2012-12-03  3:37               ` Eli Zaretskii
  2012-12-03  6:57                 ` Chong Yidong
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2012-12-03  3:37 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10771, cyd

> From: Juri Linkov <juri@jurta.org>
> Cc: cyd@gnu.org,  10771@debbugs.gnu.org,  rgm@gnu.org
> Date: Sun, 02 Dec 2012 23:57:52 +0200
> 
> >> @@ -5138,7 +5138,7 @@ (defun info-display-manual (manual)
> >>  		       (apply-partially 'Info-read-node-name-2
> >>  					Info-directory-list
> >>  					(mapcar 'car Info-suffix-list))
> >> -		       nil t))))
> >> +		       nil nil))))
> >>    (let ((blist (buffer-list))
> >>  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
> >>  	(case-fold-search t)
> >
> > How is this better than the original command against which this bug
> > was filed?
> 
> At least this is not worse than the original command that reads a manual name
> without completion.

I didn't say it was worse.  I asked how it was better.

> BTW, there is another problem with selecting an Info buffer
> by its Info file name: what if there are two Info buffers
> visiting a manual with the same name.

Then the command finds one of them, and if you repeat the same
command, it finds the second, etc.  Which is fine with me, and I do
have such multiple manuals by the same name loaded in the same
session.

> Which one of them should be preferred by this command?

I don't need any preference.  All I need is a reasonable way of
finding each one of them.

> Also which manual should be preferred in completion when one manual
> is already visited and another manual with the same name is
> available in Info-directory-list?

The visited one, of course.





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

* bug#10771: TAB completion for info-display-manual
  2012-12-03  3:37               ` Eli Zaretskii
@ 2012-12-03  6:57                 ` Chong Yidong
  2012-12-03 16:31                   ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2012-12-03  6:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 10771

Eli Zaretskii <eliz@gnu.org> writes:

>> At least this is not worse than the original command that reads a
>> manual name without completion.
>
> I didn't say it was worse.  I asked how it was better.

How about adding existing Info buffers' manual names to the completion
table too, like the following?

=== modified file 'lisp/info.el'
*** lisp/info.el	2012-12-02 06:41:22 +0000
--- lisp/info.el	2012-12-03 06:55:15 +0000
***************
*** 5105,5113 ****
      (progn
        (info-initialize)
        (completing-read "Manual name: "
! 		       (apply-partially 'Info-read-node-name-2
! 					Info-directory-list
! 					(mapcar 'car Info-suffix-list))
  		       nil t))))
    (let ((blist (buffer-list))
  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
--- 5105,5111 ----
      (progn
        (info-initialize)
        (completing-read "Manual name: "
! 		       (info--manual-names)
  		       nil t))))
    (let ((blist (buffer-list))
  	(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
***************
*** 5126,5131 ****
--- 5124,5143 ----
        (info (Info-find-file manual)
  	    (generate-new-buffer-name "*info*")))))
  
+ (defun info--manual-names ()
+   (let (names)
+     (dolist (buffer (buffer-list))
+       (with-current-buffer buffer
+ 	(when (and (eq major-mode 'Info-mode)
+ 		   (stringp Info-current-file))
+ 	  (push (file-name-sans-extension
+ 		 (file-name-nondirectory Info-current-file))
+ 		names))))
+     (delete-dups (append names
+ 			 (apply-partially 'Info-read-node-name-2
+ 					  Info-directory-list
+ 					  (mapcar 'car Info-suffix-list))))))
+ 
  (provide 'info)
  
  ;;; info.el ends here






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

* bug#10771: TAB completion for info-display-manual
  2012-12-03  6:57                 ` Chong Yidong
@ 2012-12-03 16:31                   ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2012-12-03 16:31 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 10771

> From: Chong Yidong <cyd@gnu.org>
> Cc: Juri Linkov <juri@jurta.org>,  10771@debbugs.gnu.org,  rgm@gnu.org
> Date: Mon, 03 Dec 2012 14:57:14 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> At least this is not worse than the original command that reads a
> >> manual name without completion.
> >
> > I didn't say it was worse.  I asked how it was better.
> 
> How about adding existing Info buffers' manual names to the completion
> table too, like the following?

Fine with me, but please nreverse the list returned by
info--manual-names, so that it is in the order of buffer-list.  This
is important because that is the order in which the command examines
the buffers.

Thanks.





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

end of thread, other threads:[~2012-12-03 16:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09  6:36 bug#10771: TAB completion for info-display-manual Glenn Morris
2012-02-09  9:28 ` Juri Linkov
2012-02-09 18:42   ` Eli Zaretskii
2012-02-10 10:17     ` Juri Linkov
2012-12-02  6:44     ` Chong Yidong
2012-12-02 17:25       ` Eli Zaretskii
2012-12-02 21:12         ` Juri Linkov
2012-12-02 21:32           ` Eli Zaretskii
2012-12-02 21:57             ` Juri Linkov
2012-12-03  3:37               ` Eli Zaretskii
2012-12-03  6:57                 ` Chong Yidong
2012-12-03 16:31                   ` Eli Zaretskii

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