emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Documentation for "Clone Buffers" (corrected version)


From: Juri Linkov
Subject: Re: Documentation for "Clone Buffers" (corrected version)
Date: Sun, 25 Apr 2004 07:32:09 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Kai Grossjohann <address@hidden> writes:
> Alex Schroeder <address@hidden> writes:
>> Heh.  :)  Many have complained about similar functionality in M-x
>> shell, for example (and written code where M-x shell starts *another*
>> shell instead of switching to the existing shell buffer).
>
> On a tangent, I like fshell.el which has functionality not provided by
> M-x shell RET plus clone-buffer:
>
> C-u 42 M-x fshell RET goes to the *shell*<42> buffer, creating it if
> it doesn't exist, yet.
>
> For some reason or other, I like this much better than using some
> switch-to-buffer interface for selecting the right buffer.

This is a very good idea!  How about the following implementation?
It works by appending the numeric prefix argument to the *info*
buffer name:

C-u 15 C-h i goes to the *info*<15> buffer, creating it
             with the top-level Info directory if it doesn't exist.

I think that adding this feature will make the FORK argument obsolete
because with the FORK argument a forked Info buffer contains the name
of the target node which is too misleading when the user goes to
another Info node in the same Info buffer.  OTOH, the naming scheme
with the numeric suffix is more convenient: the user has three choices
to create a new Info buffer by adding a number to its name:

1. clone the Info buffer by M-n;
2. rename the Info buffer by rename-uniquely;
3. create a new Info buffer by giving the numeric prefix argument to C-h i

And in all cases jumping to the existing Info buffer is the same:
by giving the numeric prefix argument to C-h i with the number in
the existing buffer name.

Index: lisp/info.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
retrieving revision 1.390
diff -u -r1.390 info.el
--- lisp/info.el        22 Apr 2004 19:49:11 -0000      1.390
+++ lisp/info.el        25 Apr 2004 03:17:16 -0000
@@ -449,28 +450,38 @@
   "Like `info' but show the Info buffer in another window."
   (interactive (if current-prefix-arg
                   (list (read-file-name "Info file name: " nil nil t))))
-  (let (same-window-buffer-names)
+  (let (same-window-buffer-names same-window-regexps)
     (info file)))
 
-;;;###autoload (add-hook 'same-window-buffer-names "*info*")
+;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
 
 ;;;###autoload
-(defun info (&optional file)
+(defun info (&optional file buffer)
   "Enter Info, the documentation browser.
 Optional argument FILE specifies the file to examine;
 the default is the top-level directory of Info.
 Called from a program, FILE may specify an Info node of the form
 `(FILENAME)NODENAME'.
-
-In interactive use, a prefix argument directs this command
-to read a file name from the minibuffer.
+Optional argument BUFFER specifies the Info buffer name;
+the default buffer name is *info*.  If BUFFER exists,
+just switch to BUFFER.  Otherwise, create a new buffer
+with the top-level Info directory.
+
+In interactive use, a non-numeric prefix argument directs
+this command to read a file name from the minibuffer.
+A numeric prefix argument appends the number to the buffer name.
 
 The search path for Info files is in the variable `Info-directory-list'.
 The top-level Info directory is made by combining all the files named `dir'
 in all the directories in that path."
-  (interactive (if current-prefix-arg
-                  (list (read-file-name "Info file name: " nil nil t))))
-  (pop-to-buffer "*info*")
+  (interactive (list
+                (if (and current-prefix-arg (not (numberp current-prefix-arg)))
+                    (read-file-name "Info file name: " nil nil t))
+                (if (numberp current-prefix-arg)
+                    (format "*info*<%s>" current-prefix-arg))))
+  (pop-to-buffer (or buffer "*info*"))
+  (if (and buffer (not (eq major-mode 'Info-mode)))
+      (Info-mode))
   (if file
       ;; If argument already contains parentheses, don't add another set
       ;; since the argument will then be parsed improperly.  This also

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]