changeset 2215:a7d915ce7676

src/ * simple.el (quoted-insert): In overwrite mode, don't read digits as an octal character code. In binary overwrite mode, overwrite the characters instead of inserting them. (overwrite-mode-textual, overwrite-mode-binary): New symbols, for use in the mode line. (overwrite-mode): Doc fix. Use force-mode-line-update. (binary-overwrite-mode): New function. * loaddefs.el (minor-mode-alist): Make the mode line element for overwrite-mode be the symbol `overwrite-mode'.
author Jim Blandy <jimb@redhat.com>
date Tue, 16 Mar 1993 18:18:47 +0000
parents e5928bec8d5d
children 8dfca05a5852
files lisp/simple.el
diffstat 1 files changed, 51 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Tue Mar 16 18:18:05 1993 +0000
+++ b/lisp/simple.el	Tue Mar 16 18:18:47 1993 +0000
@@ -60,11 +60,22 @@
   "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.
-`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."
+
+In overwrite mode, this function inserts the character anyway, and
+does not handle octal digits specially.  This means that if you use
+overwrite 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
+digits are interpreted as a character code.  This is supposed to make
+this function useful in editing binary files."
   (interactive "*p")
-  (let ((char (read-quoted-char)))
+  (let ((char (if (or (not overwrite-mode)
+		      (eq overwrite-mode 'overwrite-mode-binary))
+		  (read-quoted-char)
+		(read-char))))
+    (if (eq overwrite-mode 'overwrite-mode-binary)
+	(delete-char arg))
     (insert-char char arg)))
 
 (defun delete-indentation (&optional arg)
@@ -1809,16 +1820,48 @@
   (prin1 selective-display t)
   (princ "." t))
 
+(defconst overwrite-mode-textual " Ovwrt"
+  "The string displayed in the mode line when in overwrite mode.")
+(defconst overwrite-mode-binary " Bin Ovwrt"
+  "The string displayed in the mode line when in binary overwrite mode.")
+
 (defun overwrite-mode (arg)
   "Toggle overwrite mode.
 With arg, turn overwrite mode on iff arg is positive.
 In overwrite mode, printing characters typed in replace existing text
-on a one-for-one basis, rather than pushing it to the right."
+on a one-for-one basis, rather than pushing it to the right.  At the
+end of a line, such characters extend the line.  Before a tab,
+such characters insert until the tab is filled in.
+\\[quoted-insert] still inserts characters in overwrite mode; this
+is supposed to make it easier to insert characters when necessary."
   (interactive "P")
   (setq overwrite-mode
-	(if (null arg) (not overwrite-mode)
-	  (> (prefix-numeric-value arg) 0)))
-  (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line.
+	(if (if (null arg) (not overwrite-mode)
+	      (> (prefix-numeric-value arg) 0))
+	    'overwrite-mode-textual))
+  (force-mode-line-update))
+
+(defun binary-overwrite-mode (arg)
+  "Toggle binary overwrite mode.
+With arg, turn binary overwrite mode on iff arg is positive.
+In binary overwrite mode, printing characters typed in replace
+existing text.  Newlines are not treated specially, so typing at the
+end of a line joins the line to the next, with the typed character
+between them.  Typing before a tab character simply replaces the tab
+with the character typed.
+\\[quoted-insert] replaces the text at the cursor, just as ordinary
+typing characters do.
+
+Note that binary overwrite mode is not its own minor mode; it is a
+specialization of overwrite-mode, entered by setting the
+`overwrite-mode' variable to `overwrite-mode-binary'."
+  (interactive "P")
+  (setq overwrite-mode
+	(if (if (null arg)
+		(not (eq (overwrite-mode 'overwrite-mode-binary)))
+	      (> (prefix-numeric-value arg) 0))
+	    'overwrite-mode-binary))
+  (force-mode-line-update))
 
 (defvar blink-matching-paren t
   "*Non-nil means show matching open-paren when close-paren is inserted.")