aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-05-30 15:34:02 +0000
committerStefan Monnier2003-05-30 15:34:02 +0000
commit5121ef4cd521ff6eb487e8f10c80c428863588ed (patch)
treeb33214f339c1a2788e8a6b7d62d8f502e0d42c64
parent034060e4e71334fc74e0dfe6e728989e268f1f74 (diff)
downloademacs-5121ef4cd521ff6eb487e8f10c80c428863588ed.tar.gz
emacs-5121ef4cd521ff6eb487e8f10c80c428863588ed.zip
(edebug-storing-offsets): Move indent and debug to inside the macro.
(edebug-read-storing-offsets): Simplify. (edebug-read-quote, edebug-read-function): Place the start-position correctly. (edebug-read-backquote-new): Remove. (edebug-read-backquote-level): New var to replace it. (edebug-read-backquote): Increment it. Don't store offsets one extra time. (edebug-read-comma): Decrement it. Read the comma as a plain symbol if outside of any new-style backquote. (edebug-read-list): Use edebug-read-backquote-level. Don't call edebug-read-backquote directly. This way the extra offsets store is done exactly when it's needed. (edebug-read-vector): Use push. (defmacro): Add support for the `declare' thingy.
-rw-r--r--lisp/emacs-lisp/edebug.el85
1 files changed, 38 insertions, 47 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 52777455483..e67ca1eb81e 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -810,10 +810,8 @@ already is one.)"
810 ;; Ignore the last created offset pair. 810 ;; Ignore the last created offset pair.
811 (setcdr edebug-current-offset (cdr (cdr edebug-current-offset)))) 811 (setcdr edebug-current-offset (cdr (cdr edebug-current-offset))))
812 812
813(def-edebug-spec edebug-storing-offsets (form body))
814(put 'edebug-storing-offsets 'lisp-indent-hook 1)
815
816(defmacro edebug-storing-offsets (point &rest body) 813(defmacro edebug-storing-offsets (point &rest body)
814 (declare (debug (form body)) (indent 1))
817 `(unwind-protect 815 `(unwind-protect
818 (progn 816 (progn
819 (edebug-store-before-offset ,point) 817 (edebug-store-before-offset ,point)
@@ -837,15 +835,13 @@ already is one.)"
837 )) 835 ))
838 836
839(defun edebug-read-storing-offsets (stream) 837(defun edebug-read-storing-offsets (stream)
840 (let ((class (edebug-next-token-class)) 838 (let (edebug-read-dotted-list) ; see edebug-store-after-offset
841 func
842 edebug-read-dotted-list) ; see edebug-store-after-offset
843 (edebug-storing-offsets (point) 839 (edebug-storing-offsets (point)
844 (if (setq func (assq class edebug-read-alist)) 840 (funcall
845 (funcall (cdr func) stream) 841 (or (cdr (assq (edebug-next-token-class) edebug-read-alist))
846 ;; anything else, just read it. 842 ;; anything else, just read it.
847 (edebug-original-read stream)) 843 'edebug-original-read)
848 ))) 844 stream))))
849 845
850(defun edebug-read-symbol (stream) 846(defun edebug-read-symbol (stream)
851 (edebug-original-read stream)) 847 (edebug-original-read stream))
@@ -857,25 +853,20 @@ already is one.)"
857 ;; Turn 'thing into (quote thing) 853 ;; Turn 'thing into (quote thing)
858 (forward-char 1) 854 (forward-char 1)
859 (list 855 (list
860 (edebug-storing-offsets (point) 'quote) 856 (edebug-storing-offsets (1- (point)) 'quote)
861 (edebug-read-storing-offsets stream))) 857 (edebug-read-storing-offsets stream)))
862 858
859(defvar edebug-read-backquote-level 0
860 "If non-zero, we're in a new-style backquote.
861It should never be negative. This controls how we read comma constructs.")
862
863(defun edebug-read-backquote (stream) 863(defun edebug-read-backquote (stream)
864 ;; Turn `thing into (\` thing) 864 ;; Turn `thing into (\` thing)
865 (let ((opoint (point))) 865 (forward-char 1)
866 (forward-char 1) 866 (list
867 ;; Generate the same structure of offsets we would have 867 (edebug-storing-offsets (1- (point)) '\`)
868 ;; if the resulting list appeared verbatim in the input text. 868 (let ((edebug-read-backquote-level (1+ edebug-read-backquote-level)))
869 (edebug-storing-offsets opoint 869 (edebug-read-storing-offsets stream))))
870 (list
871 (edebug-storing-offsets opoint '\`)
872 (edebug-read-storing-offsets stream)))))
873
874(defvar edebug-read-backquote-new nil
875 "Non-nil if reading the inside of a new-style backquote with no parens around it.
876Value of nil means reading the inside of an old-style backquote construct
877which is surrounded by an extra set of parentheses.
878This controls how we read comma constructs.")
879 870
880(defun edebug-read-comma (stream) 871(defun edebug-read-comma (stream)
881 ;; Turn ,thing into (\, thing). Handle ,@ and ,. also. 872 ;; Turn ,thing into (\, thing). Handle ,@ and ,. also.
@@ -890,11 +881,12 @@ This controls how we read comma constructs.")
890 (forward-char 1))) 881 (forward-char 1)))
891 ;; Generate the same structure of offsets we would have 882 ;; Generate the same structure of offsets we would have
892 ;; if the resulting list appeared verbatim in the input text. 883 ;; if the resulting list appeared verbatim in the input text.
893 (if edebug-read-backquote-new 884 (if (zerop edebug-read-backquote-level)
894 (list 885 (edebug-storing-offsets opoint symbol)
895 (edebug-storing-offsets opoint symbol) 886 (list
896 (edebug-read-storing-offsets stream)) 887 (edebug-storing-offsets opoint symbol)
897 (edebug-storing-offsets opoint symbol))))) 888 (let ((edebug-read-backquote-level (1- edebug-read-backquote-level)))
889 (edebug-read-storing-offsets stream)))))))
898 890
899(defun edebug-read-function (stream) 891(defun edebug-read-function (stream)
900 ;; Turn #'thing into (function thing) 892 ;; Turn #'thing into (function thing)
@@ -902,11 +894,11 @@ This controls how we read comma constructs.")
902 (cond ((eq ?\' (following-char)) 894 (cond ((eq ?\' (following-char))
903 (forward-char 1) 895 (forward-char 1)
904 (list 896 (list
905 (edebug-storing-offsets (point) 897 (edebug-storing-offsets (- (point) 2)
906 (if (featurep 'cl) 'function* 'function)) 898 (if (featurep 'cl) 'function* 'function))
907 (edebug-read-storing-offsets stream))) 899 (edebug-read-storing-offsets stream)))
908 ((memq (following-char) '(?: ?B ?O ?X ?b ?o ?x ?1 ?2 ?3 ?4 ?5 ?6 900 ((memq (following-char) '(?: ?B ?O ?X ?b ?o ?x ?1 ?2 ?3 ?4 ?5 ?6
909 ?7 ?8 ?9 ?0)) 901 ?7 ?8 ?9 ?0))
910 (backward-char 1) 902 (backward-char 1)
911 (edebug-original-read stream)) 903 (edebug-original-read stream))
912 (t (edebug-syntax-error "Bad char after #")))) 904 (t (edebug-syntax-error "Bad char after #"))))
@@ -916,18 +908,17 @@ This controls how we read comma constructs.")
916 (prog1 908 (prog1
917 (let ((elements)) 909 (let ((elements))
918 (while (not (memq (edebug-next-token-class) '(rparen dot))) 910 (while (not (memq (edebug-next-token-class) '(rparen dot)))
919 (if (eq (edebug-next-token-class) 'backquote) 911 (if (and (eq (edebug-next-token-class) 'backquote)
920 (let ((edebug-read-backquote-new (not (null elements))) 912 (null elements)
921 (opoint (point))) 913 (zerop edebug-read-backquote-level))
922 (if edebug-read-backquote-new 914 (progn
923 (setq elements (cons (edebug-read-backquote stream) elements)) 915 ;; Old style backquote.
924 (forward-char 1) ; Skip backquote. 916 (forward-char 1) ; Skip backquote.
925 ;; Call edebug-storing-offsets here so that we 917 ;; Call edebug-storing-offsets here so that we
926 ;; produce the same offsets we would have had 918 ;; produce the same offsets we would have had
927 ;; if the backquote were an ordinary symbol. 919 ;; if the backquote were an ordinary symbol.
928 (setq elements (cons (edebug-storing-offsets opoint '\`) 920 (push (edebug-storing-offsets (1- (point)) '\`) elements))
929 elements)))) 921 (push (edebug-read-storing-offsets stream) elements)))
930 (setq elements (cons (edebug-read-storing-offsets stream) elements))))
931 (setq elements (nreverse elements)) 922 (setq elements (nreverse elements))
932 (if (eq 'dot (edebug-next-token-class)) 923 (if (eq 'dot (edebug-next-token-class))
933 (let (dotted-form) 924 (let (dotted-form)
@@ -947,7 +938,7 @@ This controls how we read comma constructs.")
947 (prog1 938 (prog1
948 (let ((elements)) 939 (let ((elements))
949 (while (not (eq 'rbracket (edebug-next-token-class))) 940 (while (not (eq 'rbracket (edebug-next-token-class)))
950 (setq elements (cons (edebug-read-storing-offsets stream) elements))) 941 (push (edebug-read-storing-offsets stream) elements))
951 (apply 'vector (nreverse elements))) 942 (apply 'vector (nreverse elements)))
952 (forward-char 1) ; skip \] 943 (forward-char 1) ; skip \]
953 )) 944 ))
@@ -1983,7 +1974,7 @@ expressions; a `progn' form will be returned enclosing these forms."
1983 [&optional ("interactive" interactive)] 1974 [&optional ("interactive" interactive)]
1984 def-body)) 1975 def-body))
1985(def-edebug-spec defmacro 1976(def-edebug-spec defmacro
1986 (&define name lambda-list def-body)) 1977 (&define name lambda-list [&optional ("declare" &rest sexp)] def-body))
1987 1978
1988(def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list. 1979(def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list.
1989 1980