On Tue, Jan 29, 2013 at 11:45 AM, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Hello Jay, > > I'd like to learn a little bit more from what makes you prefer emacs > over IntelliJ. > As the main developer of Counterclockwise, I'm I could learn some > ideas, if not lessons, from your experience.
Sure, responses inline- > 2013/1/28 Jay Fields <j...@jayfields.com>: >> There are too many reasons to list, but it all comes down to a >> simple question for me: do you want the ability to easily automate tasks >> that you often repeat? > > Is this really the core of your concerns? Are you talking about the > ability for you to write new elisp scripts, or to benefit from a bunch > of existing elisp scripts from the emacs community? Is this mostly > related to the fact that Clojure support in IntelliJ is lacking in key > areas? Or is it really the liberty that comes with emacs lisp that you > value overall? (And is it overrated, or not ?) What's already written is great (clojure-mode, paredit, magit, ace jump) and the ability to extend via elisp is equally nice. Here's a "grep defun init.el" (defun run-expectations () ;;; run all the tests for my project (defun run-expectations-for-source () ;;; run the tests for the src file I'm currently editing (defun rerun-last-run-expectations () ;;; rerun the last tests, regardless of what buffer I'm in (defun toggle-expectations-and-src () ;;; go to test for src or src for test, depending on which I'm already in (defun clojure-comment-sexp () ;;; comment an entire sexp instead of only commenting a line (defun switch-project (project-root) ;;; close all buffers, restart the repl, set my project dir, etc (defun grep-string-in-project (s) ;;; find a string in my project (defun grep-string-in (s project-root) ;;; find a string in a dir - defaulted to my project root (defun default-window-layout () ;;; layout my buffers in my usual way (two pane, src & test) (defun console-layout () ;;; layout my buffers with src on left and logs on right (defun clear-nrepl-server-output () ;;; no matter what buffer I'm in, clear the output in the nrepl server buffer (defun create-clj-function () ;;; create a new function with the name of the currently selected symbol (defun extract-let (var-name) ;;; extract a let with the currently selected sexp (defun inline-let-var () ;;; inline instances of a var from my let Basically, I can switch to a project, set my buffers (split horizontal or vertical), search, run tests, & run the app all with commands that I've defined (or keystrokes that I've defined). >> IntelliJ is great at automating some things (e.g. Import namespace), but if >> you want to extend its functionality it's a significant task. Conversely, I >> now open my projects with a keystroke, > > Can you describe this "open my projects with a keystroke" feature to me? the elisp (defun switch-project (project-root) (interactive (list (read-directory-name "Project Root: " (locate-dominating-file default-directory "project.clj")))) (nrepl-quit) (when (equal current-prefix-arg nil) (mapc 'kill-buffer (buffer-list))) (cd project-root) (nrepl-jack-in)) in english select the project root, kill any currently running nrepl, conditionally kill all existing buffers, set my working dir, start a new repl. At that point I can navigate (C-x C-f **) to my "main" namespace and run my "start" function (C-x C-e ***) to start my project in the context of my newly running repl. The bottom of my main namespace will probably look like (comment (start) ) So, I go to the space following the closing parenthesis on the start line and C-x C-e to evaluate (start) - which starts my app. Now my app is running and I can C-x C-e on any sexp in my codebase to change anything. I can stop/start any third party connections, reload configuration files, send fake data to the UI, or anything else I want. Since I can evaluate any snippet of code in the context of my app, I can do anything. Often it's as simple as simply looking at the values of an atom or ref, but it can also be: reload the config file to pick up a change I just made to point to a new 3rd party server, restart the 3rd party connections, redefine the 3rd party data handler to print the incoming data, then redefine the 3rd party data handler to store it in the appropriate atom, then print the value of the atom for verification. I have an interactive environment that I can eval any snippet in. I can develop new features without starting and stopping my server, and see the changes immediately. ** Find file *** Evaluate the Emacs Lisp expression before point, and print the value in the echo area (eval-last-sexp). >> start my app with a keystroke > > same question. Is it mostly (only?) leiningen apps with a repl ? Answered above, but, yes, a leiningen app, connected to emacs with nrepl-jack-in >> I also automated running tests, creating tests that do not exist, and >> navigating to tests. > > Can you point me to the emacs lisp which does this ? I would be > interested in studying a little bit what kind of API it provides to > you, the user (without digging into tons of reference material: a > concrete example like you automating running tests would be great to > look at) https://github.com/gar3thjon3s/expectations-mode allows you to run expectations in emacs http://blog.jayfields.com/2012/11/elisp-automated-switching-between.html automated navigation Basically, emacs comes with a fn that allows me to figure out what the project root is, then I use convention to determine where a test should live (and create it if it doesn't exist), then I run it using what's already available in expectations-mode, or switch to that buffer using what emacs exposes to switch to buffer (a.k.a "open files"). I'm not sure if that's clear, but I'm happy to send more if you have more questions. Cheers, Jay -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.