Function: quoted-insert

quoted-insert is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(quoted-insert ARG)

Documentation

Read next input character and insert it.

This is useful for inserting control characters. With argument, insert ARG copies of the character.

If the first character you type is an octal digit, the sequence of one or more octal digits you type is interpreted to specify a character code. Any character that is not an octal digit terminates the sequence. If the terminator is a RET, it is discarded; any other terminator is used itself as input and is inserted.

The variable read-quoted-char-radix specifies the radix for this feature; set it to 10 or 16 to use decimal or hex instead of octal. If you change the radix, the characters interpreted as specifying a character code change accordingly: 0 to 9 for decimal, 0 to F for hex.

In overwrite mode, this function inserts the character anyway, and does not handle octal (or decimal or hex) digits specially. This means that if you use overwrite mode as your normal editing mode, you can use this function to insert characters when necessary.

In binary overwrite mode, this function does overwrite, and octal
(or decimal or hex) digits are interpreted as a character code. This
is intended to be useful for editing binary files.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun quoted-insert (arg)
  "Read next input character and insert it.
This is useful for inserting control characters.
With argument, insert ARG copies of the character.

If the first character you type is an octal digit, the sequence of
one or more octal digits you type is interpreted to specify a
character code.  Any character that is not an octal digit terminates
the sequence.  If the terminator is a RET, it is discarded; any
other terminator is used itself as input and is inserted.

The variable `read-quoted-char-radix' specifies the radix for this feature;
set it to 10 or 16 to use decimal or hex instead of octal.  If you change
the radix, the characters interpreted as specifying a character code
change accordingly: 0 to 9 for decimal, 0 to F for hex.

In overwrite mode, this function inserts the character anyway, and
does not handle octal (or decimal or hex) digits specially.  This means
that if you use overwrite mode as your normal editing mode, you can use
this function to insert characters when necessary.

In binary overwrite mode, this function does overwrite, and octal
\(or decimal or hex) digits are interpreted as a character code.  This
is intended to be useful for editing binary files."
  (interactive "*p")
  (let* ((char
	  ;; Avoid "obsolete" warnings for translation-table-for-input.
	  (with-no-warnings
	    (let (translation-table-for-input input-method-function)
	      (if (or (not overwrite-mode)
		      (eq overwrite-mode 'overwrite-mode-binary))
		  (read-quoted-char)
		(read-char))))))
    ;; This used to assume character codes 0240 - 0377 stand for
    ;; characters in some single-byte character set, and converted them
    ;; to Emacs characters.  But in 23.1 this feature is deprecated
    ;; in favor of inserting the corresponding Unicode characters.
    ;; (if (and enable-multibyte-characters
    ;;          (>= char ?\240)
    ;;          (<= char ?\377))
    ;;     (setq char (unibyte-char-to-multibyte char)))
    (unless (characterp char)
      (user-error "%s is not a valid character"
		  (key-description (vector char))))
    (if (> arg 0)
	(if (eq overwrite-mode 'overwrite-mode-binary)
	    (delete-char arg)))
    (while (> arg 0)
      (insert-and-inherit char)
      (setq arg (1- arg)))))