aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-16 05:34:38 +0000
committerRichard M. Stallman1997-07-16 05:34:38 +0000
commit2444730b8b8ae2c812ba95bd591be1c94192949b (patch)
tree86200e10afa7d59aea0dc386ad6db796ecf04839 /lisp
parent7ae13091e55958e35133ebf2f003c389609b8d55 (diff)
downloademacs-2444730b8b8ae2c812ba95bd591be1c94192949b.tar.gz
emacs-2444730b8b8ae2c812ba95bd591be1c94192949b.zip
(read-quoted-char): Read any number of octal digits,
and ignore a space if that terminates the octal digits.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el36
1 files changed, 23 insertions, 13 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ecc64fcb450..bc966c7bda8 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -650,29 +650,39 @@ FILE should be the name of a library, with no directory name."
650;;;; Input and display facilities. 650;;;; Input and display facilities.
651 651
652(defun read-quoted-char (&optional prompt) 652(defun read-quoted-char (&optional prompt)
653 "Like `read-char', except that if the first character read is an octal 653 "Like `read-char', but do not allow quitting.
654digit, we read up to two more octal digits and return the character 654Also, if the first character read is an octal digit,
655represented by the octal number consisting of those digits. 655we read any number of octal digits and return the
656Optional argument PROMPT specifies a string to use to prompt the user." 656soecified character code. Any nondigit terminates the sequence.
657 (let ((message-log-max nil) (count 0) (code 0) char) 657If the terminator is a space, it is discarded;
658 (while (< count 3) 658any other terminator is used itself as input.
659 (let ((inhibit-quit (zerop count)) 659
660The optional argument PROMPT specifies a string to use to prompt the user."
661 (let ((message-log-max nil) done (first t) (code 0) char)
662 (while (not done)
663 (let ((inhibit-quit first)
660 ;; Don't let C-h get the help message--only help function keys. 664 ;; Don't let C-h get the help message--only help function keys.
661 (help-char nil) 665 (help-char nil)
662 (help-form 666 (help-form
663 "Type the special character you want to use, 667 "Type the special character you want to use,
664or three octal digits representing its character code.")) 668or the octal character code.
669Space terminates the character code and is discarded;
670any other non-digit terminates the character code and is then used as input."))
665 (and prompt (message "%s-" prompt)) 671 (and prompt (message "%s-" prompt))
666 (setq char (read-char)) 672 (setq char (read-char))
667 (if inhibit-quit (setq quit-flag nil))) 673 (if inhibit-quit (setq quit-flag nil)))
668 (cond ((null char)) 674 (cond ((null char))
669 ((and (<= ?0 char) (<= char ?7)) 675 ((and (<= ?0 char) (<= char ?7))
670 (setq code (+ (* code 8) (- char ?0)) 676 (setq code (+ (* code 8) (- char ?0)))
671 count (1+ count))
672 (and prompt (setq prompt (message "%s %c" prompt char)))) 677 (and prompt (setq prompt (message "%s %c" prompt char))))
673 ((> count 0) 678 ((and (not first) (eq char ?\ ))
674 (setq unread-command-events (list char) count 259)) 679 (setq done t))
675 (t (setq code char count 259)))) 680 ((not first)
681 (setq unread-command-events (list char)
682 done t))
683 (t (setq code char
684 done t)))
685 (setq first nil))
676 ;; Turn a meta-character into a character with the 0200 bit set. 686 ;; Turn a meta-character into a character with the 0200 bit set.
677 (logior (if (/= (logand code ?\M-\^@) 0) 128 0) 687 (logior (if (/= (logand code ?\M-\^@) 0) 128 0)
678 code))) 688 code)))