;;; 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.
(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)
(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)))
"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."
(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)
(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
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)))
(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."
(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].
\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