Tobias C. Rittweiler wrote:
Numeromancer tschaef@sbcglobal.net writes:
Does slime have a function which will qualify the symbol at point with its package name if it is imported? And the obvious extension, qualifying all symbols in the region or file? Does anyone have any hints on how one might create such a function?
What do you mean with "if it is imported"? Do you really only mean if the symbol was imported via IMPORT or via the :IMPORT-FROM clause of DEFPACKAGE? What do you want this for?
-T.
Sorry about the delay.
Perhaps "imported" is not technically correct. "Available in the current package without qualification" might be better. Or not.
I mean this: if I am in package foo, which uses cl, for example, then
(map 'func-in-foo (list 1 2 3 var-in-foo))
would be transformed to
(cl:map 'func-in-foo (cl:list 1 2 3 var-in-foo))
if the whole expression were in the region. The symbols in the current package are not qualified. Or, the package name is an argument and only symbols in that package are so qualified.
This would help in finding details of the dependencies between packages.
E.g.: If I have a utils package (don't we all?) and another package, foo maybe, and I want to split the latter off into a separate project, I may want to see if I can easily make it independent of utils. Macroexpanding will show me this, but if Slime could do as I suggest I could change the buffer and then one-by-one change the use of objects in util to something else, and thereby remove any dependency on the util package.
Or, similarly, I might want to continue to use utils in foo but not :use it, and so force all symbols from utils to have package qualifiers. I could then :use instead some new package that has symbols which conflict with symbols in utils.
I hope this is clear.
These are not everyday tasks, but they can be tedious, and what I have suggested would help.
Thanks
Tim S
* Numeromancer [2008-01-30 23:27+0100] writes:
Numeromancer tschaef@sbcglobal.net writes:
Does slime have a function which will qualify the symbol at point with its package name if it is imported? And the obvious extension, qualifying all symbols in the region or file? Does anyone have any hints on how one might create such a function?
No, Slime has no such command.
[...]
Perhaps "imported" is not technically correct. "Available in the current package without qualification" might be better. Or not.
I mean this: if I am in package foo, which uses cl, for example, then
(map 'func-in-foo (list 1 2 3 var-in-foo))
would be transformed to
(cl:map 'func-in-foo (cl:list 1 2 3 var-in-foo))
if the whole expression were in the region. The symbols in the current package are not qualified. Or, the package name is an argument and only symbols in that package are so qualified.
Would you like to implement something like this?
Sending the region (as string) and the name of the current package to the Lisp process is very easy. Perhaps it's good enough to READ the region in the package (or perhaps some temporary package with suitable imports) and pprint the form with clever printer settings. Sending the printed result back and inserting it in the buffer is also easy.
Helmut.
Helmut Eller wrote:
- Numeromancer [2008-01-30 23:27+0100] writes:
Numeromancer tschaef@sbcglobal.net writes:
Does slime have a function which will qualify the symbol at point with its package name if it is imported? And the obvious extension, qualifying all symbols in the region or file? Does anyone have any hints on how one might create such a function?
No, Slime has no such command.
[...]
Perhaps "imported" is not technically correct. "Available in the current package without qualification" might be better. Or not.
I mean this: if I am in package foo, which uses cl, for example, then
(map 'func-in-foo (list 1 2 3 var-in-foo))
would be transformed to
(cl:map 'func-in-foo (cl:list 1 2 3 var-in-foo))
if the whole expression were in the region. The symbols in the current package are not qualified. Or, the package name is an argument and only symbols in that package are so qualified.
Would you like to implement something like this?
Yes
Sending the region (as string) and the name of the current package to the Lisp process is very easy. Perhaps it's good enough to READ the region in the package (or perhaps some temporary package with suitable imports) and pprint the form with clever printer settings. Sending the printed result back and inserting it in the buffer is also easy.
Helmut.
Something like this, maybe?
(defun slime-eval-region (start end) "Evaluate region." (interactive "r") (slime-eval-with-transcript `(swank:interactive-expand-symbols ,(buffer-substring-no-properties start end))))
I just need do define swank:interactive-expand-symbols. I'll look into it. Thanks.
Tim S