aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2008-04-07 16:01:47 +0000
committerSam Steingold2008-04-07 16:01:47 +0000
commit49ec8931145d0bb09986e047a82ff1fe5f0bd27b (patch)
tree4083b81ba9c7cd477d08761a6674047c02737624
parentf7e4a59c5f935e7a303013d06f61539d99f468ed (diff)
downloademacs-49ec8931145d0bb09986e047a82ff1fe5f0bd27b.tar.gz
emacs-49ec8931145d0bb09986e047a82ff1fe5f0bd27b.zip
lisp-eval-defun & lisp-compile-defun: DEFVAR forms reset the variables
to the init values, similar to emacs-lisp eval-defun
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/progmodes/inf-lisp.el48
2 files changed, 42 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9f51e4a0ab8..e7a74037af8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12008-04-07 Sam Steingold <sds@gnu.org>
2
3 * progmodes/inf-lisp.el (lisp-compile-string, lisp-eval-string):
4 Add helper functions.
5 (lisp-do-defun): Extracted the common part of lisp-eval-defun and
6 lisp-compile-defun; DEFVAR forms reset the variables to the init
7 values, just like in emacs-lisp mode eval-defun.
8 (lisp-eval-defun, lisp-compile-defun): Use lisp-do-defun.
9 (lisp-compile-region): Use lisp-compile-string.
10
12008-04-07 Stefan Monnier <monnier@iro.umontreal.ca> 112008-04-07 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * pcvs-util.el (cvs-map): Avoid recursion :-( 13 * pcvs-util.el (cvs-map): Avoid recursion :-(
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 89a2890973c..ca94af2394d 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -323,16 +323,40 @@ Prefix argument means switch to the Lisp buffer afterwards."
323 (comint-send-string (inferior-lisp-proc) "\n") 323 (comint-send-string (inferior-lisp-proc) "\n")
324 (if and-go (switch-to-lisp t))) 324 (if and-go (switch-to-lisp t)))
325 325
326(defun lisp-eval-defun (&optional and-go) 326(defun lisp-compile-string (string)
327 "Send the string to the inferior Lisp process to be compiled and executed."
328 (comint-send-string
329 (inferior-lisp-proc)
330 (format "(funcall (compile nil (lambda () %s)))\n" string)))
331
332(defun lisp-eval-string (string)
333 "Send the string to the inferior Lisp process to be executed."
334 (comint-send-string (inferior-lisp-proc) (concat string "\n")))
335
336(defun lisp-do-defun (do-string do-region)
327 "Send the current defun to the inferior Lisp process. 337 "Send the current defun to the inferior Lisp process.
328Prefix argument means switch to the Lisp buffer afterwards." 338The actually processing is done by `do-string' and `do-region'
329 (interactive "P") 339 which determine whether the code is compiled before evaluation.
340DEFVAR forms reset the variables to the init values."
330 (save-excursion 341 (save-excursion
331 (end-of-defun) 342 (end-of-defun)
332 (skip-chars-backward " \t\n\r\f") ; Makes allegro happy 343 (skip-chars-backward " \t\n\r\f") ; Makes allegro happy
333 (let ((end (point))) 344 (let ((end (point)) (case-fold-search t))
334 (beginning-of-defun) 345 (beginning-of-defun)
335 (lisp-eval-region (point) end))) 346 (if (looking-at "(defvar")
347 (funcall do-string
348 ;; replace `defvar' with `defparameter'
349 (concat "(defparameter "
350 (buffer-substring-no-properties (+ (point) 7) end)
351 "\n"))
352 (funcall do-region (point) end)))))
353
354(defun lisp-eval-defun (&optional and-go)
355 "Send the current defun to the inferior Lisp process.
356DEFVAR forms reset the variables to the init values.
357Prefix argument means switch to the Lisp buffer afterwards."
358 (interactive "P")
359 (lisp-do-defun 'lisp-eval-string 'lisp-eval-region)
336 (if and-go (switch-to-lisp t))) 360 (if and-go (switch-to-lisp t)))
337 361
338(defun lisp-eval-last-sexp (&optional and-go) 362(defun lisp-eval-last-sexp (&optional and-go)
@@ -341,27 +365,19 @@ Prefix argument means switch to the Lisp buffer afterwards."
341 (interactive "P") 365 (interactive "P")
342 (lisp-eval-region (save-excursion (backward-sexp) (point)) (point) and-go)) 366 (lisp-eval-region (save-excursion (backward-sexp) (point)) (point) and-go))
343 367
344;;; Common Lisp COMPILE sux.
345(defun lisp-compile-region (start end &optional and-go) 368(defun lisp-compile-region (start end &optional and-go)
346 "Compile the current region in the inferior Lisp process. 369 "Compile the current region in the inferior Lisp process.
347Prefix argument means switch to the Lisp buffer afterwards." 370Prefix argument means switch to the Lisp buffer afterwards."
348 (interactive "r\nP") 371 (interactive "r\nP")
349 (comint-send-string 372 (lisp-compile-string (buffer-substring-no-properties start end))
350 (inferior-lisp-proc)
351 (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n"
352 (buffer-substring start end)))
353 (if and-go (switch-to-lisp t))) 373 (if and-go (switch-to-lisp t)))
354 374
355(defun lisp-compile-defun (&optional and-go) 375(defun lisp-compile-defun (&optional and-go)
356 "Compile the current defun in the inferior Lisp process. 376 "Compile the current defun in the inferior Lisp process.
377DEFVAR forms reset the variables to the init values.
357Prefix argument means switch to the Lisp buffer afterwards." 378Prefix argument means switch to the Lisp buffer afterwards."
358 (interactive "P") 379 (interactive "P")
359 (save-excursion 380 (lisp-do-defun 'lisp-compile-string 'lisp-compile-region)
360 (end-of-defun)
361 (skip-chars-backward " \t\n\r\f") ; Makes allegro happy
362 (let ((e (point)))
363 (beginning-of-defun)
364 (lisp-compile-region (point) e)))
365 (if and-go (switch-to-lisp t))) 381 (if and-go (switch-to-lisp t)))
366 382
367(defun switch-to-lisp (eob-p) 383(defun switch-to-lisp (eob-p)