(makefile-gnumake-functions-alist): Add `addprefix'.
[bpt/emacs.git] / lisp / simple.el
index 5617efa..aba6583 100644 (file)
@@ -894,7 +894,7 @@ In either case, the output is inserted after point (leaving mark after it)."
              ;; then replace that region with the output.
              (progn (setq buffer-read-only nil)
                     (delete-region (max start end) (point-max))
-                    (delete-region (point-min) (max start end))
+                    (delete-region (point-min) (min start end))
                     (call-process-region (point-min) (point-max)
                                          shell-file-name t t nil
                                          shell-command-switch command)
@@ -926,7 +926,10 @@ In either case, the output is inserted after point (leaving mark after it)."
                            (buffer-substring (point)
                                              (progn (end-of-line) (point))))))
                (t 
-                (set-window-start (display-buffer buffer) 1))))))))
+                (save-excursion
+                  (set-buffer buffer)
+                  (goto-char (point-min)))
+                (display-buffer buffer))))))))
 \f
 (defconst universal-argument-map
   (let ((map (make-sparse-keymap)))
@@ -1557,7 +1560,7 @@ In Transient Mark mode, this does not activate the mark."
          (move-marker (car (nthcdr global-mark-ring-max global-mark-ring))
                       nil)
          (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil))))
-  (or nomsg executing-macro (> (minibuffer-depth) 0)
+  (or nomsg executing-kbd-macro (> (minibuffer-depth) 0)
       (message "Mark set"))
   (if (or activate (not transient-mark-mode))
       (set-mark (mark t)))
@@ -2330,6 +2333,9 @@ Setting this variable automatically makes it local to the current buffer.")
 (defconst auto-fill-inhibit-regexp nil
   "*Regexp to match lines which should not be auto-filled.")
 
+;; This function is the auto-fill-function of a buffer
+;; when Auto-Fill mode is enabled.
+;; It returns t if it really did any work.
 (defun do-auto-fill ()
   (let (fc justify bol give-up
           (fill-prefix fill-prefix))
@@ -2419,7 +2425,8 @@ Setting this variable automatically makes it local to the current buffer.")
            ;; No place to break => stop trying.
            (setq give-up t))))
       ;; justify last line
-      (justify-current-line justify t t)))) 
+      (justify-current-line justify t t)
+      t))) 
 
 (defun auto-fill-mode (&optional arg)
   "Toggle auto-fill mode.
@@ -2445,10 +2452,16 @@ automatically breaks the line at a previous space."
   (auto-fill-mode 1))
 
 (defun set-fill-column (arg)
-  "Set `fill-column' to current column, or to argument if given.
-The variable `fill-column' has a separate value for each buffer."
+  "Set `fill-column' to specified argument.
+Just \\[universal-argument] as argument means to use the current column."
   (interactive "P")
-  (setq fill-column (if (integerp arg) arg (current-column)))
+  (cond ((integerp arg)
+        (setq fill-column arg))
+       ((consp arg)
+        (setq fill-column (current-column)))
+       ;; Disallow missing argument; it's probably a typo for C-x C-f.
+       (t
+        (error "set-fill-column requires an explicit argument")))
   (message "fill-column set to %d" fill-column))
 \f
 (defconst comment-multi-line nil
@@ -2917,6 +2930,9 @@ With prefix argument N, move N items (negative N means move backward)."
 ;; Switch to BUFFER and insert the completion choice CHOICE.
 ;; BASE-SIZE, if non-nil, says how many characters of BUFFER's text
 ;; to keep.  If it is nil, use choose-completion-delete-max-match instead.
+
+;; If BUFFER is the minibuffer, exit the minibuffer
+;; unless it is reading a file name and CHOICE is a directory.
 (defun choose-completion-string (choice &optional buffer base-size)
   (let ((buffer (or buffer completion-reference-buffer)))
     ;; If BUFFER is a minibuffer, barf unless it's the currently
@@ -2940,7 +2956,12 @@ With prefix argument N, move N items (negative N means move backward)."
       ;; If completing for the minibuffer, exit it with this choice.
       (and (equal buffer (window-buffer (minibuffer-window)))
           minibuffer-completion-table
-          (exit-minibuffer)))))
+          ;; If this is reading a file name, and the file name chosen
+          ;; is a directory, don't exit the minibuffer.
+          (if (and (eq minibuffer-completion-table 'read-file-name-internal)
+                   (file-directory-p (buffer-string)))
+              (select-window (active-minibuffer-window))
+            (exit-minibuffer))))))
 
 (defun completion-list-mode ()
   "Major mode for buffers showing lists of possible completions.