I'm wondering if there is some way to tell SLIME to not try to report all output from the inferior lisp? My emacs buffer-menu shows the slime-repl as huge and ever-growing:
* *slime-repl sbc: 123816001 REPL
I'm building a huge data structure and need some way of SLIME sending the command but turning off output from SBCL.
Here is the code that is taking a long time to run:
(defvar *datasize* 100000 "size of dataset")
(defun gendata () (dotimes (i *datasize*) (let* ( (m (random (1+ i))) (n (random (1+ m))) (text (write (generate 'sentence))) ) (list :text text :m m :n n))) )
(setf *d* (gendata))
Hi Terrence,
IIUC, the issue is that you don't want SLIME to print *d* once it has been set. This is a somewhat common problem with interactive Lisp use and large data items. The "problem" is that setf returns the last value and the Lisp printer then tries to print it. There are two easy ways around it.
1. (setf *d* (gendata) foo nil)
This sets *d* to (gendata) and foo to nil and then returns nil.
2 (progn (setf *d* (gendata)) nil)
This sets *d* to (gendata) and then returns nil.
You can also look at the values of *print-length* and *print-level* (note that some Lisps have other printer control variables that may need to be set to completely avoid "run away" printing.
HTH,
On Dec 3, 2007, at 7:38 PM, Terrence Brannon wrote:
I'm wondering if there is some way to tell SLIME to not try to report all output from the inferior lisp? My emacs buffer-menu shows the slime-repl as huge and ever-growing:
* *slime-repl sbc: 123816001 REPL
I'm building a huge data structure and need some way of SLIME sending the command but turning off output from SBCL.
Here is the code that is taking a long time to run:
(defvar *datasize* 100000 "size of dataset")
(defun gendata () (dotimes (i *datasize*) (let* ( (m (random (1+ i))) (n (random (1+ m))) (text (write (generate 'sentence))) ) (list :text text :m m :n n))) )
(setf *d* (gendata))
-- http://www.aliveandwell.org/ | http://www.SlowChess.com | http://mostholy.wholefoodfarmacy.com _______________________________________________ slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM
* "Terrence Brannon" | I'm wondering if there is some way to tell SLIME to not try to report | all output from the inferior lisp?
In addition to Gary King's suggestions, you probably could also use DEFPARMATER, instead of SETQ, when evaluating forms via slime. This would return just the symbol and not the value. i.e.
(defparameter *d* (gendata))
| My emacs buffer-menu shows the | slime-repl as huge and ever-growing: | | * *slime-repl sbc: 123816001 REPL
If you were worried about buffer size and wanted to automatically truncate the buffer, comint can do that for you. See C-h f comint-truncate-buffer
Typically you could define a function like:
(defun my-setup-comint-truncation () (make-variable-buffer-local 'comint-buffer-maximum-size) (make-variable-buffer-local 'comint-output-filter-functions) (add-hook 'comint-output-filter-functions 'comint-truncate-buffer))
and add it to the mode hooks.
However SLIME does not use inferior-lisp-mode to start up the inferior lisp, so you cannot add it to `inferior-lisp-mode-hook'. Instead SLIME uses `slime-start-lisp', but that does not [currently] call any hook functions. So one could resort to an an ugly hack like:
(add-hook 'comint-exec-hook (lambda () (when (and (boundp 'name) (string-match "inferior-lisp" name)) ;;XXX hack depends on comint-exec using a parameter `name' (my-setup-comint-truncation))))
[Note regarding `my-setup-comint-truncation', the variables are explicitly made buffer local in so that your other comint buffers are not affected. Also the default value of comint-buffer-maximum-size is 1024, and this may be set in that function.]
-- Madhu
[some mistakes here]
* I wrote | (defun my-setup-comint-truncation () | (make-variable-buffer-local 'comint-buffer-maximum-size) | (make-variable-buffer-local 'comint-output-filter-functions) | (add-hook 'comint-output-filter-functions | 'comint-truncate-buffer)) [...]
| [Note regarding `my-setup-comint-truncation', the variables are | explicitly made buffer local in so that your other comint buffers are | not affected. Also the default value of comint-buffer-maximum-size is | 1024, and this may be set in that function.]
This probably isn't the best way to do it, also the docs say:
Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument.
So For Emacs 21+:
(defun my-setup-comint-truncation () (make-variable-local 'comint-buffer-maximum-size) (add-hook 'comint-output-filter-functions 'comint-truncate-buffer nil t))
Otherwise, one has to use (make-local-hook 'comint-output-filter-functions) -- Madhu