JimB's changes since January 18th
[bpt/emacs.git] / lisp / simple.el
index 2399733..ee49c57 100644 (file)
@@ -1,6 +1,6 @@
 ;;; simple.el --- basic editing commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -59,7 +59,10 @@ With arg N, insert N newlines."
 (defun quoted-insert (arg)
   "Read next input character and insert it.
 This is useful for inserting control characters.
-You may also type up to 3 octal digits, to insert a character with that code"
+You may also type up to 3 octal digits, to insert a character with that code.
+`quoted-insert' inserts the character even in overstrike mode; if you
+use overstrike as your normal editing mode, you can use this function
+to insert characters when necessary."
   (interactive "*p")
   (let ((char (read-quoted-char)))
     (while (> arg 0)
@@ -425,19 +428,30 @@ contains expressions rather than strings.")
 (defvar minibuffer-history-search-history nil)
 
 (mapcar
- (function (lambda (key-and-command)
-            (mapcar
-             (function (lambda (keymap)
-                         (define-key (symbol-value keymap)
-                           (car key-and-command)
-                           (cdr key-and-command))))
-             '(minibuffer-local-map
-               minibuffer-local-ns-map
-               minibuffer-local-completion-map
-               minibuffer-local-must-match-map
-               read-expression-map))))
- '(("\en" . next-history-element) ([next] . next-history-element)
-   ("\ep" . previous-history-element) ([prior] . previous-history-element)
+ (lambda (key-and-command)
+   (mapcar
+    (lambda (keymap-and-completionp)
+      ;; Arg is (KEYMAP-SYMBOL . COMPLETION-MAP-P).
+      ;; If the cdr of KEY-AND-COMMAND (the command) is a cons,
+      ;; its car is used if COMPLETION-MAP-P is nil, its cdr if it is t.
+      (define-key (symbol-value (car keymap-and-completionp))
+       (car key-and-command)
+       (let ((command (cdr key-and-command)))
+         (if (consp command)
+             (if (cdr keymap-and-completionp)
+                 (cdr command)
+               (car command))
+           command))))
+    '((minibuffer-local-map . nil)
+      (minibuffer-local-ns-map . nil)
+      (minibuffer-local-completion-map . t)
+      (minibuffer-local-must-match-map . t)
+      (read-expression-map . nil))))
+ ;; In completion maps, use the completion-oriented history commands.
+ '(("\en" . (next-history-element . next-complete-history-element))
+   ([next] . (next-history-element . next-complete-history-element))
+   ("\ep" . (previous-history-element . previous-complete-history-element))
+   ([prior] . (previous-history-element . previous-complete-history-element))
    ("\er" . previous-matching-history-element)
    ("\es" . next-matching-history-element)))
 
@@ -520,6 +534,18 @@ If N is negative, find the previous or Nth previous match."
   "Inserts the previous element of the minibuffer history into the minibuffer."
   (interactive "p")
   (next-history-element (- n)))
+
+(defun next-complete-history-element (n)
+  "\
+Get previous element of history which is a completion of minibuffer contents."
+  (interactive "p")
+  (next-matching-history-element
+   (concat "^" (regexp-quote (buffer-substring (point-min) (point)))) n))
+
+(defun previous-complete-history-element (n)
+  "Get next element of history which is a completion of minibuffer contents."
+  (interactive "p")
+  (next-complete-history-element (- n)))
 \f
 (defun goto-line (arg)
   "Goto line ARG, counting from line 1 at beginning of buffer."
@@ -766,13 +792,7 @@ Repeating \\[universal-argument] without digits or minus sign
        (progn
          (describe-arg value sign)
          (setq key (read-key-sequence nil t))))
-    (if (= (length key) 1)
-       ;; Make sure self-insert-command finds the proper character;
-       ;; unread the character and let the command loop process it.
-       (setq unread-command-char (string-to-char key))
-      ;; We can't push back a longer string, so we'll emulate the
-      ;; command loop ourselves.
-      (command-execute (key-binding key)))))
+    (setq unread-command-events (append key '()))))
 
 (defun describe-arg (value sign)
   (cond ((numberp value)
@@ -896,7 +916,7 @@ If `interprogram-cut-function' is non-nil, apply it to STRING."
 (defun kill-append (string before-p)
   "Append STRING to the end of the latest kill in the kill ring.
 If BEFORE-P is non-nil, prepend STRING to the kill.
-If 'interprogram-cut-function' is set, pass the resulting kill to
+If `interprogram-cut-function' is set, pass the resulting kill to
 it."
   (setcar kill-ring
          (if before-p
@@ -950,10 +970,12 @@ Any command that calls this function is a \"kill command\".
 If the previous command was also a kill command,
 the text killed this time appends to the text killed last time
 to make one entry in the kill ring."
-  (interactive "r")
+  (interactive "*r")
   (cond
-   (buffer-read-only
-    (copy-region-as-kill beg end))
+   ;; If the buffer was read-only, we used to just do a
+   ;; copy-region-as-kill.  This was never what I wanted - usually I
+   ;; was making a mistake and trying to edit a file checked into RCS -
+   ;; so I've taken the code out.
    ((not (or (eq buffer-undo-list t)
             (eq last-command 'kill-region)
             (eq beg end)))
@@ -1150,8 +1172,8 @@ most recent first.")
 
 (defun set-mark-command (arg)
   "Set mark at where point is, or jump to mark.
-With no prefix argument, set mark, and push previous mark on mark ring.
-With argument, jump to mark, and pop into mark off the mark ring.
+With no prefix argument, set mark, and push old mark position on mark ring.
+With argument, jump to mark, and pop a new position for mark off the ring.
 
 Novice Emacs Lisp programmers often try to use the mark for the wrong
 purposes.  See the documentation of `set-mark' for more information."
@@ -1289,6 +1311,9 @@ When the `track-eol' feature is doing its job, the value is 9999.")
   (move-to-column (or goal-column temporary-goal-column))
   nil)
 
+;;; Many people have said they rarely use this feature, and often type
+;;; it by accident.  Maybe it shouldn't even be on a key.
+(put 'set-goal-column 'disabled t)
 
 (defun set-goal-column (arg)
   "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
@@ -1406,7 +1431,9 @@ With argument 0, interchanges line point is in with line mark is in."
 \f
 (defconst comment-column 32
   "*Column to indent right-margin comments to.
-Setting this variable automatically makes it local to the current buffer.")
+Setting this variable automatically makes it local to the current buffer.
+Each mode establishes a different default value for this variable; you
+can the value for a particular mode using that mode's hook.")
 (make-variable-buffer-local 'comment-column)
 
 (defconst comment-start nil