[CLJ-1191] Improve apropos to show some indication of namespace of symbols found Created: 04/Apr/13 Updated: 29/Aug/14 Resolved: 29/Aug/14
|Affects Version/s:||Release 1.5, Release 1.6|
|Fix Version/s:||Release 1.7|
|Attachments:||clj-1191-patch-v1.txt clj-1191-patch-v2.txt clj-1191-v3.patch|
|Patch:||Code and Test|
apropos does find all symbols in all namespaces that match the argument, but the return value gives no clue as to which namespace the found symbols are in. It can even return multiple occurrences of the same symbol, which only gives a clue that the symbol exists in more than one namespace, but not which ones. For example:
It would be nice if the returned symbols could indicate the namespace.
With the screened patch clj-1191-v3.patch applied the output for the examples above becomes:
Screened by: Alex Miller
|Comment by Andy Fingerhut [ 04/Apr/13 8:25 PM ]|
Path clj-1191-patch-v1.txt enhances apropos to put a namespace/ qualifier before every symbol found that is not in the current namespace ns. It also finds the shortest namespace alias if there is more than one. Examples of output with patch:
user=> (apropos "replace")
user=> (require '[clojure.string :as str])
user=> (in-ns 'clojure.string)
|Comment by Colin Jones [ 05/Apr/13 1:34 PM ]|
apropos as it already stands is quite helpful for already-referred vars, but not for vars that are only in other nses.
This update includes the information someone would need to further investigate the output.
|Comment by Alex Miller [ 20/Aug/14 11:22 AM ]|
If you have "use"d many namespaces (which is not uncommon at the repl), this updated apropos still doesn't help you understand where a particular function is coming from (as the ns will be omitted). It's cool that this patch is "unresolving" and finding the shortest-alias etc but I think it's actually doing too much. In my opinion, simply providing the full namespace for all matches would actually be more useful (and easier).
|Comment by Andy Fingerhut [ 20/Aug/14 12:27 PM ]|
Patch clj-1191-patch-v2.txt dated Aug 20 2014 modifies apropos so that every symbol returned has a full namespace qualifier, even if it is in clojure.core. Before this patch:
After this patch:
|Comment by Alex Miller [ 20/Aug/14 1:34 PM ]|
Some comments on the code itself:
1) I don't think we should do anything special for ns - there are plenty of ways to search your current ns. I think it unnecessarily adds a lot of complexity without enough value.
|Comment by Andy Fingerhut [ 20/Aug/14 5:02 PM ]|
Patch clj-1191-patch-v3.txt attempts to address Alex Miller's comments on the v2 patch.
Perhaps the diff will get down to a 1-line change
|Comment by Andy Fingerhut [ 20/Aug/14 5:05 PM ]|
Patch clj-1191-v3.patch is identical to clj-1191-patch-v3.txt mentioned in the previous comment, but conforms to the requested .patch or .diff file name ending.