Mercurial > emacs
comparison lisp/progmodes/inf-lisp.el @ 93823:11a95e2059c8
lisp-eval-defun & lisp-compile-defun: DEFVAR forms reset the variables
to the init values, similar to emacs-lisp eval-defun
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Mon, 07 Apr 2008 16:01:47 +0000 |
parents | a1342e6e097a |
children | 1e3a407766b9 |
comparison
equal
deleted
inserted
replaced
93822:ac3c073bf1c2 | 93823:11a95e2059c8 |
---|---|
321 (interactive "r\nP") | 321 (interactive "r\nP") |
322 (comint-send-region (inferior-lisp-proc) start end) | 322 (comint-send-region (inferior-lisp-proc) start end) |
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. |
328 Prefix argument means switch to the Lisp buffer afterwards." | 338 The actually processing is done by `do-string' and `do-region' |
329 (interactive "P") | 339 which determine whether the code is compiled before evaluation. |
340 DEFVAR 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. | |
356 DEFVAR forms reset the variables to the init values. | |
357 Prefix 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) |
339 "Send the previous sexp to the inferior Lisp process. | 363 "Send the previous sexp to the inferior Lisp process. |
340 Prefix argument means switch to the Lisp buffer afterwards." | 364 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. |
347 Prefix argument means switch to the Lisp buffer afterwards." | 370 Prefix 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. |
377 DEFVAR forms reset the variables to the init values. | |
357 Prefix argument means switch to the Lisp buffer afterwards." | 378 Prefix 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) |
368 "Switch to the inferior Lisp process buffer. | 384 "Switch to the inferior Lisp process buffer. |
369 With argument, positions cursor at end of buffer." | 385 With argument, positions cursor at end of buffer." |