(compilation-find-buffer): Return current buffer immediately if suitable.
authorRichard M. Stallman <rms@gnu.org>
Thu, 2 Aug 2007 17:40:54 +0000 (17:40 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 2 Aug 2007 17:40:54 +0000 (17:40 +0000)
(compile, compilation-buffer-name, compilation-start): Doc fixes.

lisp/ChangeLog
lisp/progmodes/compile.el

index 66f1618..cdb89b3 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-02  Richard Stallman  <rms@gnu.org>
+
+       * progmodes/compile.el (compilation-find-buffer): Return current
+       buffer immediately if suitable.
+       (compile, compilation-buffer-name, compilation-start): Doc fixes.
+
 2007-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * vc-bzr.el (vc-bzr-admin-dirstate): Rename from `...-dirname'.
@@ -10,7 +16,7 @@
 
        * ibuf-ext.el (ibuffer-mark-old-buffers): Docstring fix.
 
-2007-07-31  Drew Adams  <drew.adams@oracle.com>  (tiny change)
+2007-07-31  Drew Adams  <drew.adams@oracle.com>
 
        * cus-edit.el (custom-group-value-create, custom-goto-parent):
        Fix parent groups link.
        (name, size, mode) <define-ibuffer-column>: Add a header-mouse-map
        property.
 
-2006-04-02  Drew Adams  <drew.adams@oracle.com>  (tiny change)
+2006-04-02  Drew Adams  <drew.adams@oracle.com>
 
        * speedbar.el (speedbar-after-create-hook): Doc fix.
 
index 13e4e40..529194f 100644 (file)
@@ -888,11 +888,13 @@ non-nil; otherwise uses `compile-command'.  With prefix arg, always prompts.
 Additionally, with universal prefix arg, compilation buffer will be in
 comint mode, i.e. interactive.
 
-To run more than one compilation at once, start one and rename
+To run more than one compilation at once, start one then rename
 the \`*compilation*' buffer to some other name with
-\\[rename-buffer].  Then start the next one.  On most systems,
-termination of the main compilation process kills its
-subprocesses.
+\\[rename-buffer].  Then _switch buffers_ and start the new compilation.
+It will create a new \`*compilation*' buffer.
+
+On most systems, termination of the main compilation process
+kills its subprocesses.
 
 The name used for the buffer is actually whatever is returned by
 the function in `compilation-buffer-name-function', so you can set that
@@ -944,7 +946,7 @@ visible rather than the beginning."
 If NAME-FUNCTION is non-nil, call it with one argument MODE-NAME
 to determine the buffer name.
 Likewise if `compilation-buffer-name-function' is non-nil.
-If current buffer is the mode MODE-COMMAND,
+If current buffer has the major mode MODE-COMMAND,
 return the name of the current buffer, so that it gets reused.
 Otherwise, construct a buffer name from MODE-NAME."
   (cond (name-function
@@ -983,8 +985,11 @@ The rest of the arguments are optional; for them, nil means use the default.
 
 MODE is the major mode to set in the compilation buffer.  Mode
 may also be t meaning use `compilation-shell-minor-mode' under `comint-mode'.
+
 If NAME-FUNCTION is non-nil, call it with one argument (the mode name)
-to determine the buffer name.
+to determine the buffer name.  Otherwise, the default is to
+reuses the current buffer if it has the proper major mode,
+else use or create a buffer with name based on the major mode.
 
 If HIGHLIGHT-REGEXP is non-nil, `next-error' will temporarily highlight
 the matching section of the visited source line; the default is to use the
@@ -1604,12 +1609,16 @@ Use this command in a compilation log buffer.  Sets the mark at point there."
     (setq compilation-current-error (point))
     (next-error-internal)))
 
-;; Return a compilation buffer.
-;; If the current buffer is a compilation buffer, return it.
-;; Otherwise, look for a compilation buffer and signal an error
-;; if there are none.
 (defun compilation-find-buffer (&optional avoid-current)
-  (next-error-find-buffer avoid-current 'compilation-buffer-internal-p))
+  "Return a compilation buffer.
+If AVOID-CURRENT is nil, and
+the current buffer is a compilation buffer, return it.
+If AVOID-CURRENT is non-nil, return the current buffer
+only as a last resort."
+  (if (and (compilation-buffer-internal-p (current-buffer))
+          (not avoid-current))
+      (current-buffer)
+    (next-error-find-buffer avoid-current 'compilation-buffer-internal-p)))
 
 ;;;###autoload
 (defun compilation-next-error-function (n &optional reset)