comparison lisp/emacs-lisp/eval-reg.el @ 22464:fc8109f5d8f5

(elisp-eval-region): Accept new arg read-function; also handle load-read-function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 13 Jun 1998 04:34:18 +0000
parents 14e5e43d8626
children bb42066bb94a
comparison
equal deleted inserted replaced
22463:fd555029931d 22464:fc8109f5d8f5
120 (funcall elisp-code)) 120 (funcall elisp-code))
121 (setq elisp-eval-region-level (1+ elisp-eval-region-level))) 121 (setq elisp-eval-region-level (1+ elisp-eval-region-level)))
122 (funcall elisp-code))))) 122 (funcall elisp-code)))))
123 123
124 124
125 (defun elisp-eval-region (elisp-start elisp-end &optional elisp-output) 125 (defun elisp-eval-region (elisp-start elisp-end &optional elisp-output
126 elisp-read-function)
126 "Execute the region as Lisp code. 127 "Execute the region as Lisp code.
127 When called from programs, expects two arguments, 128 When called from programs, expects two arguments,
128 giving starting and ending indices in the current buffer 129 giving starting and ending indices in the current buffer
129 of the text to be executed. 130 of the text to be executed.
130 Programs can pass third argument PRINTFLAG which controls printing of output: 131 Programs can pass third argument PRINTFLAG which controls printing of output:
131 nil means discard it; anything else is stream for print. 132 nil means discard it; anything else is stream for print.
133
134 Also the fourth argument READ-FUNCTION, if non-nil, is used
135 instead of `read' to read each expression. It gets one argument
136 which is the input stream for reading characters.
132 137
133 This version, from `eval-reg.el', allows Lisp customization of read, 138 This version, from `eval-reg.el', allows Lisp customization of read,
134 eval, and the printer." 139 eval, and the printer."
135 140
136 ;; Because this doesn't narrow to the region, one other difference 141 ;; Because this doesn't narrow to the region, one other difference
147 elisp-form 152 elisp-form
148 elisp-val) 153 elisp-val)
149 (goto-char elisp-start) 154 (goto-char elisp-start)
150 (elisp-skip-whitespace) 155 (elisp-skip-whitespace)
151 (while (< (point) elisp-end-marker) 156 (while (< (point) elisp-end-marker)
152 (setq elisp-form (read elisp-buf)) 157 (setq elisp-form
158 (cond (elisp-read-function
159 (funcall elisp-read-function elisp-buf))
160 (load-read-function
161 (funcall load-read-function elisp-buf))
162 (t
163 (read elisp-buf))))
153 164
154 (let ((elisp-current-buffer (current-buffer))) 165 (let ((elisp-current-buffer (current-buffer)))
155 ;; Restore the inside current-buffer. 166 ;; Restore the inside current-buffer.
156 (set-buffer elisp-inside-buf) 167 (set-buffer elisp-inside-buf)
157 (setq elisp-val (eval elisp-form)) 168 (setq elisp-val (eval elisp-form))