I don't like jumping back and forth between a buffer and the repl when testing small snippets of code, I prefer to temporarily insert them into the buffer and eval them in place.
This creates problems in slime because some features (who-calls, compiler notes) only work properly with compilation, which means I have to use both eval and compile for this strategy to be effective.
This leads to errors when done manually so I defined this function:
(defun slime-eval/compile-defun-dwim (&optional arg) "Call the computation command you want (Do What I Mean). Look at defun and determine whether to call `slime-eval-defun' or `slime-compile-defun'.
A prefix of `-' forces evaluation, any other prefix forces compilation." (interactive "P") (case arg ;; prefix is `-', evaluate defun ('- (slime-eval-defun)) ;; no prefix, automatically determine action ('nil (if (string-match "^(def" (slime-defun-at-point)) (slime-compile-defun) (slime-eval-defun))) ;; prefix is not `-', compile defun (otherwise (slime-compile-defun))))
I use this command all the time so I bind it on M-j. This is bound to indent-new-comment-line by default but it isn't missed since it is also bound on C-M-j. Having the command bound on a Meta key is useful because I don't have to release Meta to M-n or M-p if I get compiler notes.
I thought this might be helpful, but maybe I'm missing something. How do other people typically interact with lisp? What are the most commonly used commands?
jan janmar@iprimus.com.au writes:
I thought this might be helpful, but maybe I'm missing something.
We can add a command like, but the keybinding is probably a bit controversial.
How do other people typically interact with lisp? What are the most commonly used commands?
I rarely use the REPL. I insert the snippets I want to try in the buffer near the code (often in a comment) or the slime-scratch buffer (I globally bind C-c s to slime-selector and use that for buffer switching). I run the code with C-x C-e and compile it with C-c C-c. C-x C-e also works in comments. I use C-M-x only to call slime-re-evaluate-defvar. C-c C-p is convenient when something returns a long list. M-., C-c C-d and C-c C-a are probably the commands I use most often.
Helmut.
Helmut Eller e9626484@stud3.tuwien.ac.at writes:
We can add a command like, but the keybinding is probably a bit controversial.
I wouldn't clutter the interface with it unless it is going to be widely used. It took a few minutes to write, anyone who wants to can easily roll their own.
How do other people typically interact with lisp? What are the most commonly used commands?
I rarely use the REPL. I insert the snippets I want to try in the buffer near the code (often in a comment) or the slime-scratch buffer (I globally bind C-c s to slime-selector and use that for buffer switching). I run the code with C-x C-e and compile it with C-c C-c. C-x C-e also works in comments. I use C-M-x only to call slime-re-evaluate-defvar. C-c C-p is convenient when something returns a long list. M-., C-c C-d and C-c C-a are probably the commands I use most often.
Thanks Helmut, this kind of description is valuable to me since I've never met another lisper face to face and can't learn by watching someone at work.
I was also wondering about navigation within functions, do you use line/word movement functions or sexp/list movement functions more?
jan janmar@iprimus.com.au writes:
I was also wondering about navigation within functions, do you use line/word movement functions or sexp/list movement functions more?
Both. C-a and C-e are pretty much reflexes for me :-) I don't know exactly when I use them, but I think I use them a lot. I bind forward/backward-sexp to C-M-left and C-M-right, because that's easier to type for me. (Doesn't work in terminals, though.) I use that quite often, especially when I fix some unbalanced parentheses. C-M-a C-M-q is my key for reindentation and C-M-e C-x C-e for evaluating a large form. I use C-M-u sometimes, C-M-d very rarely. C-M-space is really cool, as is C-M-t. I usually insert a pair of parentheses with M-( and often to try to wrap and expression inside parentheses with ESC 1 M-(, but that rarely works.
This are just my habits, other people may well to it differently.
Helmut.
jan janmar@iprimus.com.au writes:
Thanks Helmut, this kind of description is valuable to me since I've never met another lisper face to face and can't learn by watching someone at work.
Out of curiosity, where in .au are you? I'm a Brisbane lad myself, but living in Sweden.
For picking up new Emacs reflexes, `keywiz' is one brilliant hack - http://www.ifa.au.dk/~harder/keywiz.el. It's a game that automates the learning you otherwise only get by looking over a lot of different shoulders. Highly recommended!
Cheers, Luke
Luke Gorrie luke@bluetail.com writes:
Out of curiosity, where in .au are you? I'm a Brisbane lad myself, but living in Sweden.
I'm in Canberra, "feel the power". ;-)
For picking up new Emacs reflexes, `keywiz' is one brilliant hack - http://www.ifa.au.dk/~harder/keywiz.el. It's a game that automates the learning you otherwise only get by looking over a lot of different shoulders. Highly recommended!
Very nifty, but it's not quite what I'm after. I have no trouble finding commands with apropos, describe-mode etc. The problem is when emacs offers more than one way to do something it's not clear which permutation of commands is most efficient.