aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1995-06-14 22:30:41 +0000
committerKarl Heuer1995-06-14 22:30:41 +0000
commite8d1a377251b2c9407c78d8cc1cfd80bf17d80db (patch)
treebf117e3ee2deb78cb7f61205da31ae6d23fbd88a
parent3b8c40f5ba6f568e399a374186fe15cdc121fba5 (diff)
downloademacs-e8d1a377251b2c9407c78d8cc1cfd80bf17d80db.tar.gz
emacs-e8d1a377251b2c9407c78d8cc1cfd80bf17d80db.zip
(universal-argument, describe-arg): Restore Lisp code,
undoing Feb 28 change. (prefix-arg-internal, digit-argument, negative-argument): Likewise.
-rw-r--r--lisp/simple.el71
1 files changed, 71 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 2c1c7cb53c5..e29c1d4e29b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -935,6 +935,77 @@ In either case, the output is inserted after point (leaving mark after it)."
935 (t 935 (t
936 (set-window-start (display-buffer buffer) 1)))))))) 936 (set-window-start (display-buffer buffer) 1))))))))
937 937
938(defun universal-argument ()
939 "Begin a numeric argument for the following command.
940Digits or minus sign following \\[universal-argument] make up the numeric argument.
941\\[universal-argument] following the digits or minus sign ends the argument.
942\\[universal-argument] without digits or minus sign provides 4 as argument.
943Repeating \\[universal-argument] without digits or minus sign
944 multiplies the argument by 4 each time."
945 (interactive nil)
946 (let ((factor 4)
947 key)
948;; (describe-arg (list factor) 1)
949 (setq key (read-key-sequence nil t))
950 (while (equal (key-binding key) 'universal-argument)
951 (setq factor (* 4 factor))
952;; (describe-arg (list factor) 1)
953 (setq key (read-key-sequence nil t)))
954 (prefix-arg-internal key factor nil)))
955
956(defun prefix-arg-internal (key factor value)
957 (let ((sign 1))
958 (if (and (numberp value) (< value 0))
959 (setq sign -1 value (- value)))
960 (if (eq value '-)
961 (setq sign -1 value nil))
962;; (describe-arg value sign)
963 (while (equal key "-")
964 (setq sign (- sign) factor nil)
965;; (describe-arg value sign)
966 (setq key (read-key-sequence nil t)))
967 (while (and (stringp key)
968 (= (length key) 1)
969 (not (string< key "0"))
970 (not (string< "9" key)))
971 (setq value (+ (* (if (numberp value) value 0) 10)
972 (- (aref key 0) ?0))
973 factor nil)
974;; (describe-arg value sign)
975 (setq key (read-key-sequence nil t)))
976 (setq prefix-arg
977 (cond (factor (list factor))
978 ((numberp value) (* value sign))
979 ((= sign -1) '-)))
980 ;; Calling universal-argument after digits
981 ;; terminates the argument but is ignored.
982 (if (eq (key-binding key) 'universal-argument)
983 (progn
984 (describe-arg value sign)
985 (setq key (read-key-sequence nil t))))
986 (setq unread-command-events (listify-key-sequence key))))
987
988(defun describe-arg (value sign)
989 (cond ((numberp value)
990 (message "Arg: %d" (* value sign)))
991 ((consp value)
992 (message "Arg: [%d]" (car value)))
993 ((< sign 0)
994 (message "Arg: -"))))
995
996(defun digit-argument (arg)
997 "Part of the numeric argument for the next command.
998\\[universal-argument] following digits or minus sign ends the argument."
999 (interactive "P")
1000 (prefix-arg-internal (char-to-string (logand last-command-char ?\177))
1001 nil arg))
1002
1003(defun negative-argument (arg)
1004 "Begin a negative numeric argument for the next command.
1005\\[universal-argument] following digits or minus sign ends the argument."
1006 (interactive "P")
1007 (prefix-arg-internal "-" nil arg))
1008
938(defun forward-to-indentation (arg) 1009(defun forward-to-indentation (arg)
939 "Move forward ARG lines and position at first nonblank character." 1010 "Move forward ARG lines and position at first nonblank character."
940 (interactive "p") 1011 (interactive "p")