comparison lisp/simple.el @ 10854:cd64b7e04e23

(shell-command-on-region): Fix typos in doc string. (universal-argument, describe-arg): Deleted; this is now in C code. (prefix-arg-internal, digit-argument, negative-argument): Likewise.
author Karl Heuer <kwzh@gnu.org>
date Wed, 01 Mar 1995 03:42:18 +0000
parents 55552df3bd18
children 8e6b25e41a99
comparison
equal deleted inserted replaced
10853:3db086133785 10854:cd64b7e04e23
788 and put point at the end, but don't alter the mark. 788 and put point at the end, but don't alter the mark.
789 789
790 If the output is one line, it is displayed in the echo area, 790 If the output is one line, it is displayed in the echo area,
791 but it is nonetheless available in buffer `*Shell Command Output*' 791 but it is nonetheless available in buffer `*Shell Command Output*'
792 even though that buffer is not automatically displayed. 792 even though that buffer is not automatically displayed.
793 If there is no output. or ifoutput is inserted in the current buffer, 793 If there is no output, or if output is inserted in the current buffer,
794 then `*Shell Command Output*' is deleted. 794 then `*Shell Command Output*' is deleted.
795 795
796 If the optional fourth argument OUTPUT-BUFFER is non-nil, 796 If the optional fourth argument OUTPUT-BUFFER is non-nil,
797 that says to put the output in some other buffer. 797 that says to put the output in some other buffer.
798 If OUTPUT-BUFFER is a buffer or buffer name, put the output there. 798 If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
866 (goto-char (point-min)) 866 (goto-char (point-min))
867 (buffer-substring (point) 867 (buffer-substring (point)
868 (progn (end-of-line) (point)))))) 868 (progn (end-of-line) (point))))))
869 (t 869 (t
870 (set-window-start (display-buffer buffer) 1)))))))) 870 (set-window-start (display-buffer buffer) 1))))))))
871
872 (defun universal-argument ()
873 "Begin a numeric argument for the following command.
874 Digits or minus sign following \\[universal-argument] make up the numeric argument.
875 \\[universal-argument] following the digits or minus sign ends the argument.
876 \\[universal-argument] without digits or minus sign provides 4 as argument.
877 Repeating \\[universal-argument] without digits or minus sign
878 multiplies the argument by 4 each time."
879 (interactive nil)
880 (let ((factor 4)
881 key)
882 ;; (describe-arg (list factor) 1)
883 (setq key (read-key-sequence nil t))
884 (while (equal (key-binding key) 'universal-argument)
885 (setq factor (* 4 factor))
886 ;; (describe-arg (list factor) 1)
887 (setq key (read-key-sequence nil t)))
888 (prefix-arg-internal key factor nil)))
889
890 (defun prefix-arg-internal (key factor value)
891 (let ((sign 1))
892 (if (and (numberp value) (< value 0))
893 (setq sign -1 value (- value)))
894 (if (eq value '-)
895 (setq sign -1 value nil))
896 ;; (describe-arg value sign)
897 (while (equal key "-")
898 (setq sign (- sign) factor nil)
899 ;; (describe-arg value sign)
900 (setq key (read-key-sequence nil t)))
901 (while (and (stringp key)
902 (= (length key) 1)
903 (not (string< key "0"))
904 (not (string< "9" key)))
905 (setq value (+ (* (if (numberp value) value 0) 10)
906 (- (aref key 0) ?0))
907 factor nil)
908 ;; (describe-arg value sign)
909 (setq key (read-key-sequence nil t)))
910 (setq prefix-arg
911 (cond (factor (list factor))
912 ((numberp value) (* value sign))
913 ((= sign -1) '-)))
914 ;; Calling universal-argument after digits
915 ;; terminates the argument but is ignored.
916 (if (eq (key-binding key) 'universal-argument)
917 (progn
918 (describe-arg value sign)
919 (setq key (read-key-sequence nil t))))
920 (setq unread-command-events (listify-key-sequence key))))
921
922 (defun describe-arg (value sign)
923 (cond ((numberp value)
924 (message "Arg: %d" (* value sign)))
925 ((consp value)
926 (message "Arg: [%d]" (car value)))
927 ((< sign 0)
928 (message "Arg: -"))))
929
930 (defun digit-argument (arg)
931 "Part of the numeric argument for the next command.
932 \\[universal-argument] following digits or minus sign ends the argument."
933 (interactive "P")
934 (prefix-arg-internal (char-to-string (logand last-command-char ?\177))
935 nil arg))
936
937 (defun negative-argument (arg)
938 "Begin a negative numeric argument for the next command.
939 \\[universal-argument] following digits or minus sign ends the argument."
940 (interactive "P")
941 (prefix-arg-internal "-" nil arg))
942 871
943 (defun forward-to-indentation (arg) 872 (defun forward-to-indentation (arg)
944 "Move forward ARG lines and position at first nonblank character." 873 "Move forward ARG lines and position at first nonblank character."
945 (interactive "p") 874 (interactive "p")
946 (forward-line arg) 875 (forward-line arg)