Mercurial > emacs
comparison lisp/emacs-lisp/eval-reg.el @ 6807:13fc66bc7472
Renamed from eval-region.el. Fix the `provide' call.
Doc fixes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 11 Apr 1994 21:44:58 +0000 |
parents | 1196b59772d3 |
children | 97da4cb32d03 |
comparison
equal
deleted
inserted
replaced
6806:0d5dec708788 | 6807:13fc66bc7472 |
---|---|
1 ;;; eval-region.el --- Redefine eval-region, and subrs that use it, in Lisp | 1 ;;; eval-reg.el --- Redefine eval-region, and subrs that use it, in Lisp |
2 | 2 |
3 ;; Copyright (C) 1994 Daniel LaLiberte | 3 ;; Copyright (C) 1994 Daniel LaLiberte |
4 | 4 |
5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> | 5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> |
6 ;; Keywords: lisp | 6 ;; Keywords: lisp |
67 (if (not (fboundp 'original-eval-current-buffer)) | 67 (if (not (fboundp 'original-eval-current-buffer)) |
68 (defalias 'original-eval-current-buffer | 68 (defalias 'original-eval-current-buffer |
69 (symbol-function 'eval-current-buffer))) | 69 (symbol-function 'eval-current-buffer))) |
70 | 70 |
71 (defvar elisp-eval-region-level 0 | 71 (defvar elisp-eval-region-level 0 |
72 "If the value is 0, use the original version of elisp-eval-region. | 72 "If the value is 0, use the original version of `elisp-eval-region'. |
73 Callers of elisp-eval-region should increment elisp-eval-region-level | 73 Callers of `elisp-eval-region' should increment `elisp-eval-region-level' |
74 while the Lisp version should be used. Installing elisp-eval-region | 74 while the Lisp version should be used. Installing `elisp-eval-region' |
75 increments it once, and uninstalling decrements it.") | 75 increments it once, and uninstalling decrements it.") |
76 | 76 |
77 ;; Installing and uninstalling should always be used in pairs, | 77 ;; Installing and uninstalling should always be used in pairs, |
78 ;; or just install once and never uninstall. | 78 ;; or just install once and never uninstall. |
79 (defun elisp-eval-region-install () | 79 (defun elisp-eval-region-install () |
97 (put 'with-elisp-eval-region 'lisp-indent-function 1) | 97 (put 'with-elisp-eval-region 'lisp-indent-function 1) |
98 (put 'with-elisp-eval-region 'lisp-indent-hook 1) | 98 (put 'with-elisp-eval-region 'lisp-indent-hook 1) |
99 (put 'with-elisp-eval-region 'edebug-form-spec t) | 99 (put 'with-elisp-eval-region 'edebug-form-spec t) |
100 | 100 |
101 (defmacro with-elisp-eval-region (flag &rest body) | 101 (defmacro with-elisp-eval-region (flag &rest body) |
102 "If FLAG is nil, decrement eval-region-level while executing BODY. | 102 "If FLAG is nil, decrement `eval-region-level' while executing BODY. |
103 The effect of decrementing all the way to zero is that `eval-region' | 103 The effect of decrementing all the way to zero is that `eval-region' |
104 will use the original eval-region, which may be the Emacs subr or some | 104 will use the original `eval-region', which may be the Emacs subr or some |
105 previous redefinition. Before calling this macro, this package should | 105 previous redefinition. Before calling this macro, this package should |
106 already have been installed, using `elisp-eval-region-install', which | 106 already have been installed, using `elisp-eval-region-install', which |
107 increments the count once. So if another package still requires the | 107 increments the count once. So if another package still requires the |
108 elisp version of the code, the count will still be non-zero. | 108 Lisp version of the code, the count will still be non-zero. |
109 | 109 |
110 The count is not bound locally by this macro, so changes by BODY to | 110 The count is not bound locally by this macro, so changes by BODY to |
111 its value will not be lost." | 111 its value will not be lost." |
112 (` (let ((elisp-code (function (lambda () (,@ body))))) | 112 (` (let ((elisp-code (function (lambda () (,@ body))))) |
113 (if (not (, flag)) | 113 (if (not (, flag)) |
125 giving starting and ending indices in the current buffer | 125 giving starting and ending indices in the current buffer |
126 of the text to be executed. | 126 of the text to be executed. |
127 Programs can pass third argument PRINTFLAG which controls printing of output: | 127 Programs can pass third argument PRINTFLAG which controls printing of output: |
128 nil means discard it; anything else is stream for print. | 128 nil means discard it; anything else is stream for print. |
129 | 129 |
130 This version, from eval-region, allows Lisp customization of read, | 130 This version, from `eval-reg.el', allows Lisp customization of read, |
131 eval, and the printer." | 131 eval, and the printer." |
132 | 132 |
133 ;; Because this doesnt narrow to the region, one other difference | 133 ;; Because this doesnt narrow to the region, one other difference |
134 ;; concerns inserting whitespace after the expression being evaluated. | 134 ;; concerns inserting whitespace after the expression being evaluated. |
135 | 135 |
188 (defun elisp-eval-current-buffer (&optional elisp-output) | 188 (defun elisp-eval-current-buffer (&optional elisp-output) |
189 "Execute the current buffer as Lisp code. | 189 "Execute the current buffer as Lisp code. |
190 Programs can pass argument PRINTFLAG which controls printing of output: | 190 Programs can pass argument PRINTFLAG which controls printing of output: |
191 nil means discard it; anything else is stream for print. | 191 nil means discard it; anything else is stream for print. |
192 | 192 |
193 This version from eval-region calls `eval-region' on the whole buffer." | 193 This version calls `eval-region' on the whole buffer." |
194 ;; The standard eval-current-buffer doesn't use eval-region. | 194 ;; The standard eval-current-buffer doesn't use eval-region. |
195 (interactive) | 195 (interactive) |
196 (eval-region (point-min) (point-max) elisp-output)) | 196 (eval-region (point-min) (point-max) elisp-output)) |
197 | 197 |
198 | 198 |
199 (defun elisp-eval-buffer (&optional elisp-bufname elisp-printflag) | 199 (defun elisp-eval-buffer (&optional elisp-bufname elisp-printflag) |
200 "Execute BUFFER as Lisp code. Use current buffer if BUFFER is nil. | 200 "Execute BUFFER as Lisp code. Use current buffer if BUFFER is nil. |
201 Programs can pass argument PRINTFLAG which controls printing of | 201 Programs can pass argument PRINTFLAG which controls printing of |
202 output: nil means discard it; anything else is stream for print. | 202 output: nil means discard it; anything else is stream for print. |
203 | 203 |
204 This version from eval-region calls `eval-region' on the whole buffer." | 204 This version calls `eval-region' on the whole buffer." |
205 (interactive) | 205 (interactive) |
206 (if (null elisp-bufname) | 206 (if (null elisp-bufname) |
207 (setq elisp-bufname (current-buffer))) | 207 (setq elisp-bufname (current-buffer))) |
208 (save-excursion | 208 (save-excursion |
209 (set-buffer (or (get-buffer elisp-bufname) | 209 (set-buffer (or (get-buffer elisp-bufname) |
210 (error "No such buffer: %s" elisp-bufname))) | 210 (error "No such buffer: %s" elisp-bufname))) |
211 (eval-region (point-min) (point-max) elisp-printflag))) | 211 (eval-region (point-min) (point-max) elisp-printflag))) |
212 | 212 |
213 | 213 |
214 (provide 'elisp-eval-region) | 214 (provide 'eval-reg) |
215 | 215 |