Fork me on GitHub

Is there a shorthand way to require nested namespaces? i.e

(ns baz
      [bar :as b]
      [cat :as c]]))
To require the namespaces


prefix lists are valid but they have unpleasant side effects for some common workflows


for example they make it harder to grep for usage of a namespace


maybe smth like (:require [foo [bar :as b] [cat :as c]]) ?


oh, you wrote exactly that


@noisesmith what are you using now instead of emacs?


I switched to vim because it doesn’t require chording as much as all the other editors do, and that’s nicer for my wrists. I used evil for a while but eventually using vim was simpler and more consistent.


did you remap your capslock?


@ajs I'm another "ex-Emacs" Clojurian -- I switched to #protorepl about six months ago and I've been very happy with that.


(and I started off with Emacs key bindings installed in ProtoREPL to ease the transition but recently -- maybe a month ago? -- pulled those out and went back to stock key bindings, with a handful of additional ones to expose more paredit functionality)


@seancorfield i've never heard of protorepl before, now i'm curious; @noisesmith did you find the vim/clojure integration (paredit, repl, etc) to be straightforward?


vim-sexp is better than paredit because it matches the functionality / editing model of vim itself imho


the repl works but honestly I was never one to use the repl integration much


@seancorfield you are talking about the atom package?


I always have a live REPL running in Atom. I love ProtoREPL's ability to evaluate forms inline and show results right there in the source editor (as well as the REPL).


man, I tried for maybe 30 minutes last night and couldn’t get proto-repl-charts to work with a project. 😞 (Until another day)


Hi all, can’t seem to get my brain around this and wondering if someone could point me in the right direction. I have two collections. One is small (call it smallList) and is a list of lists each with two elements ((A B) (C D) (E F)) the second is larger (call it bigList) and is a vector of vectors each with 8 elements: [[ A B 1 2 3 4 5 6 ] [ C D 1 2 3 4 5 6] ...] I need to return all items from bigList whose first two elements match each of the lists in smallList. For example: (nth smallList 0) equals (take 2 (nth bigList 0) so I would like the entire (nth bigList 0). Couldn’t figure out how to do that since count bigList is much larger than count smallList. Hope that makes sense!!! Thanks for investing the time to read all this!


so smalllist is just a set of tags. and you want to filter biglist down to the members who's first two members are members of that set of tags?


sounds like a job for a hash-map


so turn smalllist into a set. (into #{} smalllist)


oh, right, a set is a better match


and the predicate is (fn [list] (when (contains? smallListSet (take 2 list)))


* some parens assembly required


#(when (smallListSet (take 2 %)) %)


yeah thanks


well that’s built to be a filter rather than predicate… but yeah


oh just get rid of the when and just use the contains


you don’t even need contains, a set is a function on membership that returns the item


and you’ll never be looking up false or nil


@seancorfield "ex-emacs"??? you're gasting my flabbers. code editing aside, i can hardly imagine life without dired, bookmarks, etc etc. proto-repl has similar? what about cross platform? i use osx but often must use linus and windows.


Yes, Atom is cross-platform. I don't miss any Emacs features but YMMV. I do sometimes miss having multiple REPLs open but I've changed my workflow a bit to make that less of an issue.


hmm, you got me actually thinking about emacs alternatives, which i never thought would happen, heh. if you don't mind: how is life better with protorepl? is it clojure-specific? (i also need to edit c, c++, js, etc.)


I also edit JS and some other stuff. Atom has pretty broad support for languages. Atom is a nice, modern, well-maintained editor and its packages are also (mostly) well-maintained -- and it has a nice auto-update setup so you know when there are updates and what's changed in them. I got tired of Emacs' old-fashioned, clunky feel.


On the Clojure-specific side, the ProtoREPL chart stuff is very cool for visualizing data while you're working with it, and the REPL integration directly inline in the editor panel is sweet.


Much depends on what you rely on in Emacs and what you'd miss.


I first got started with Emacs back in the 17.x days, lived through the 18.x period and stopped using it just as 19.x was coming on stream. Then I went back to it several years ago -- because of Clojure -- just as 24.x was coming on stream. So I have a lot of years of Emacs under my belt.


i started using emacs on os2 in the 90s, buleevw it or not! how,much time wpuld you allocate for getting used to protorepl? assuming you cannot cut over all at once.


separate q: assuming colleagues coming over from e.g. python or java. would you recommend protorepl in such cases? (not knowing which tools they areused to)


Python, yeah. I'd expect Atom/ProtoREPL to be familiar enough (or at least, not as different as Emacs!).


Java, hard to say. Most Java folks are used to a full IDE (Eclipse, IntelliJ) because Java's such a crappy language to use without all that IDE support.


As for switching from Emacs to ProtoREPL. I set ProtoREPL up (with Emacs key bindings) on both my machines over a couple of days and got it Emacs-y enough to be comfortable, then the next Monday I just shut Emacs down and vowed not to use it again for at least a week.


The first couple of days were painful as some of the buffer/window navigation shortcuts didn't translate over but by the end of the week it was mostly plain sailing. I stuck with it another week without Emacs and by that point I was fully productive.


The key is just forcing yourself to use a new tool and not "sneaking back" to the old one.


It was much the same when I stripped the Emacs key bindings from Atom and re-enabled the defaults. Took a few days to realize I needed to re-surface some paredit key bindings, but otherwise it was relatively easy 😸


Some of my Atom setup is here (not my core config tho' since it's not yet portable across Mac/Win).


but all things considered you think the switch was worth the trouble?


Yeah, definitely. I was always frustrated at how fragile Emacs configurations could be and how difficult it was to stay current on packages without things breaking. I'd originally hand-built my Emacs setup but it wasn't exactly "best practice" so I switched to Emacs Live (from the Overtone folks) but that used special packaging for modules -- and wasn't being very actively maintained after a while! -- so I switched to Prelude (from the CIDER folks) which was OK but too complex and a bit too opinionated. So, bottom line, I was never 100% happy with the configuration/setup side of Emacs. That's definitely not a concern with Atom/ProtoREPL and I'm finding the modernity of Atom pleasing. It just feels easier to work with, easier to customize.


That all said, editors are definitely subjective things -- and Emacs/CIDER is still far and away the most popular Clojure setup, followed by Cursive, then vim, with Atom in 4th place (although Cognitect's survey noted: "The most interesting development was the rise in the use of Atom which was a new choice and selected by 6% of respondents." -- but that compares to 47% for Emacs, 26% for Cursive, and 12% for vim so...).


well, you’ve convinced me to at least take a look. I luvs me my emacs, but i have to admit it’s kinduv a pain in the arse. scratch that (no pun intended), major pain in the arse. just got a new windows machine at work and am looking forward to spending 2-3 weeks getting emacs running properly; huzzah! I personally would stick with emacs, but recommending it to colleagues is, let’s face it, a non-starter.


That was part of the issue for me. We cross-trained a few folks to Clojure and Emacs was very alien to them. My teammate now is a huge Emacs fan, but he also runs Linux as his desktop etc. But it's good to have a solid, modern (non-Emacs) option for any new folks we add. And I like having a much-more straightforward config I can set up in maybe 30 minutes tops on a new machine.


Anyways, dinner time here. Then I'll be back on later.


yeah. let’s face it, emacs is an alpha-geek kinda thing. i mean it is incredibly awesomenistic, but it ain’t for everybody. if you do emacs you get bonus points, but if you don’t it does not mean you’re not a badass. not a vim guy myself, but i reckon a vim master is about as much a badass as an emacs maestro.


the atom equiv of elisp is …? seems too good to be true.


That looks like a generic REPL for various languages. Atom itself is scripted with JS (unfortunately). ProtoREPL is written in CoffeeScript (very unfortunately).


But I suspect you could program it in ClojureScript...


Been meaning to ask, why the "mobileink" nickname?


way back when, was heavily involved in typesetting. even had a job writing typesetting code, and still harbor some fading hopes of writing the One True Typesetting Engine, ha ha.


awesome! thanks for the help! Not sure what all those do yet but should be straight forward to figure out. Thanks again!


user> (let [smallset (into #{} '((a b) (c d)))]
        (filter #(contains? smallset (take 2 %))
                '((a b 1 2 3 4)
                  (c d 1 2 3 4)
                  (e f 1 2 3 4))))
((a b 1 2 3 4) (c d 1 2 3 4))


take 2 grabs the first two of a list. Contains checks if an element is in a collection. Filter returns a seq of elements matching that predicate. and set is a datastructure that gives O(1) membership checks


which translates very literally into your requirement, "if the first two elements of a list are in this set, keep it"


thx. Yeah it was using the set that I was missing. Makes sense. Thanks again!

dpsutton21:07:26 for some info about set and the operations on it. set is also a sequence so you can take, filter, etc. but it does not maintain order


Yes, worked perfectly. Thank you both!


set is not a sequence. but it can provide a sequential view of the set (which is implicitly done within seq operations)


In other words, sets are seqable but not seqs


(seq? #{1 2 3}) => false; (seqable? #{1 2 3}) => true


Yeah, what he said ☝️:skin-tone-2:


whoops. my bad


I am just picking up Clojure again after about 8 months of being busy with work and trying to use it for XML handling. I’m trying to (require clojure.xml) but it’s not autocompleting in the repl and it says not found when I type it. seems to indicate that it’s part of the standard library. Did it move or something?


You might need either (require 'clojure.xml) or (require '[clojure.xlm :as xml])


Thanks, that seemed to move the ball forward a little

project.core=> (require 'clojure.xml)
project.core=> (xml/parse)

CompilerException java.lang.RuntimeException: No such var: xml/parse, compiling:(/private/var/folders/q6/xdxb066n7mv6qg0wb8nx1qf80000gp/T/form-init8575028924345994165.clj:1:1) 


Oh, got it working. Thanks very much!