;;; simple.el --- basic editing commands for Emacs -*- lexical-binding: t -*-
-;; Copyright (C) 1985-1987, 1993-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1993-2014 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
If option `use-hard-newlines' is non-nil, the newline is marked with the
text-property `hard'.
With ARG, insert that many newlines.
-Call `auto-fill-function' if the current column number is greater
+
+To turn off indentation by this command, disable Electric Indent mode
+\(see \\[electric-indent-mode]).
+
+Calls `auto-fill-function' if the current column number is greater
than the value of `fill-column' and ARG is nil.
-A non-nil INTERACTIVE argument means to run the `post-self-insert-hook',
-which by default will also indent the line (see `electric-indent-mode')."
+A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
(interactive "*P\np")
(barf-if-buffer-read-only)
;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
column specified by the function `current-left-margin'."
(interactive "*")
(delete-horizontal-space t)
- (newline)
+ (newline 1 t)
(indent-according-to-mode))
(defun reindent-then-newline-and-indent ()
in addition to the value printed by prin1 in functions which
display the result of expression evaluation."
(if (and (integerp value)
- (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp)))
- (eq this-command last-command)
- (if (boundp 'edebug-active) edebug-active)))
+ (or (eq standard-output t)
+ (zerop (prefix-numeric-value current-prefix-arg))))
(let ((char-string
- (if (or (if (boundp 'edebug-active) edebug-active)
- (memq this-command '(eval-last-sexp eval-print-last-sexp)))
- (prin1-char value))))
+ (if (and (characterp value)
+ (char-displayable-p value))
+ (prin1-char value))))
(if char-string
(format " (#o%o, #x%x, %s)" value value char-string)
(format " (#o%o, #x%x)" value value)))))
Value is also consed on to front of the variable `values'.
Optional argument INSERT-VALUE non-nil (interactively,
with prefix argument) means insert the result into the current buffer
-instead of printing it in the echo area. Truncates long output
-according to the value of the variables `eval-expression-print-length'
+instead of printing it in the echo area. With a zero prefix arg,
+insert the result with no limit on the length and level of lists,
+and include additional formats for integers (octal, hexadecimal,
+and character). Truncates long output according to the value
+of the variables `eval-expression-print-length'
and `eval-expression-print-level'.
If `eval-expression-debug-on-error' is non-nil, which is the default,
(unless (eq old-value new-value)
(setq debug-on-error new-value))))
- (let ((print-length eval-expression-print-length)
- (print-level eval-expression-print-level)
+ (let ((print-length (and (not (zerop (prefix-numeric-value insert-value)))
+ eval-expression-print-length))
+ (print-level (and (not (zerop (prefix-numeric-value insert-value)))
+ eval-expression-print-level))
(deactivate-mark))
(if insert-value
(with-no-warnings
(let ((standard-output (current-buffer)))
- (prin1 (car values))))
+ (prog1
+ (prin1 (car values))
+ (when (zerop (prefix-numeric-value insert-value))
+ (let ((str (eval-expression-print-format (car values))))
+ (if str (princ str)))))))
(prog1
(prin1 (car values) t)
(let ((str (eval-expression-print-format (car values))))
"Keymap used while processing \\[universal-argument].")
(defun universal-argument--mode ()
- (set-temporary-overlay-map universal-argument-map))
+ (set-transient-map universal-argument-map))
(defun universal-argument ()
"Begin a numeric argument for the following command.
The optional argument REGION if non-nil, indicates that we're not just killing
some text between BEG and END, but we're killing the region."
- ;; Pass point first, then mark, because the order matters
- ;; when calling kill-append.
- (interactive (list (point) (mark) 'region))
+ ;; Pass mark first, then point, because the order matters when
+ ;; calling `kill-append'.
+ (interactive (list (mark) (point) 'region))
(unless (and beg end)
(error "The mark is not set now, so there is no region"))
(condition-case nil
some text between BEG and END, but we're copying the region.
This command's old key binding has been given to `kill-ring-save'."
- (interactive "r\np")
+ ;; Pass mark first, then point, because the order matters when
+ ;; calling `kill-append'.
+ (interactive (list (mark) (point)
+ (prefix-numeric-value current-prefix-arg)))
(let ((str (if region
(funcall region-extract-function nil)
(filter-buffer-substring beg end))))
This command is similar to `copy-region-as-kill', except that it gives
visual feedback indicating the extent of the region being copied."
- (interactive "r\np")
+ ;; Pass mark first, then point, because the order matters when
+ ;; calling `kill-append'.
+ (interactive (list (mark) (point)
+ (prefix-numeric-value current-prefix-arg)))
(copy-region-as-kill beg end region)
;; This use of called-interactively-p is correct because the code it
;; controls just gives the user visual feedback.
(buffer-substring-no-properties mark (+ mark len))))))))
(defun append-next-kill (&optional interactive)
- "Cause following command, if it kills, to append to previous kill.
+ "Cause following command, if it kills, to add to previous kill.
+If the next command kills forward from point, the kill is
+appended to the previous killed text. If the command kills
+backward, the kill is prepended. Kill commands that act on the
+region, such as `kill-region', are regarded as killing forward if
+point is after mark, and killing backward if point is before
+mark.
+
+If the next command is not a kill command, `append-next-kill' has
+no effect.
+
The argument is used for internal purposes; do not supply one."
(interactive "p")
;; We don't use (interactive-p), since that breaks kbd macros.
This is done prior to removing the properties specified by
`yank-excluded-properties'."
:group 'killing
+ :type '(repeat (cons (symbol :tag "property symbol")
+ function))
:version "24.3")
;; This is actually used in subr.el but defcustom does not work there.
START can be nil, if it was not found.
The function should return non-nil if the two tokens do not match.")
+(defvar blink-matching--overlay
+ (let ((ol (make-overlay (point) (point) nil t)))
+ (overlay-put ol 'face 'show-paren-match)
+ (delete-overlay ol)
+ ol)
+ "Overlay used to highlight the matching paren.")
+
(defun blink-matching-open ()
- "Move cursor momentarily to the beginning of the sexp before point."
+ "Momentarily highlight the beginning of the sexp before point."
(interactive)
(when (and (not (bobp))
blink-matching-paren)
(message "No matching parenthesis found"))))
((not blinkpos) nil)
((pos-visible-in-window-p blinkpos)
- ;; Matching open within window, temporarily move to blinkpos but only
- ;; if `blink-matching-paren-on-screen' is non-nil.
+ ;; Matching open within window, temporarily highlight char
+ ;; after blinkpos but only if `blink-matching-paren-on-screen'
+ ;; is non-nil.
(and blink-matching-paren-on-screen
(not show-paren-mode)
- (save-excursion
- (goto-char blinkpos)
- (sit-for blink-matching-delay))))
+ (unwind-protect
+ (progn
+ (move-overlay blink-matching--overlay blinkpos (1+ blinkpos)
+ (current-buffer))
+ (sit-for blink-matching-delay))
+ (delete-overlay blink-matching--overlay))))
(t
(save-excursion
(goto-char blinkpos)
(point))))))
(funcall blink-paren-function)))
+(put 'blink-paren-post-self-insert-function 'priority 100)
+
(add-hook 'post-self-insert-hook #'blink-paren-post-self-insert-function
;; Most likely, this hook is nil, so this arg doesn't matter,
;; but I use it as a reminder that this function usually
- ;; likes to be run after others since it does `sit-for'.
+ ;; likes to be run after others since it does
+ ;; `sit-for'. That's also the reason it get a `priority' prop
+ ;; of 100.
'append)
\f
;; This executes C-g typed while Emacs is waiting for a command.
(normal (nth 1 keypad-normal)))
(put keypad 'ascii-character normal)
(define-key function-key-map (vector keypad) (vector normal))))
- '((kp-0 ?0) (kp-1 ?1) (kp-2 ?2) (kp-3 ?3) (kp-4 ?4)
- (kp-5 ?5) (kp-6 ?6) (kp-7 ?7) (kp-8 ?8) (kp-9 ?9)
- (kp-space ?\s)
+ ;; See also kp-keys bound in bindings.el.
+ '((kp-space ?\s)
(kp-tab ?\t)
(kp-enter ?\r)
- (kp-multiply ?*)
- (kp-add ?+)
(kp-separator ?,)
- (kp-subtract ?-)
- (kp-decimal ?.)
- (kp-divide ?/)
(kp-equal ?=)
;; Do the same for various keys that are represented as symbols under
;; GUIs but naturally correspond to characters.