Quantcast
Channel: lisp service
Viewing all articles
Browse latest Browse all 20

Leveling up with Emacs: ParEdit, saving my session, and a few other things

$
0
0

The real thing I'm working on these days is trying to make a version of the dataform widget that takes widgets instead of views, but since I don't yet understand the Weblocks code well, working on that has been draining my gumption somewhat quickly. In the interest of doing something slightly useful while I procrastinated, I've been working on improving my Emacs skills.
 
The thing that got me started was that Saikat asked me what the command was to move to the beginning of an sexp. I now know the answer:

backward-sexp (C-M-b) - move to before the preceding sexp.

http://www.cliki.net/Editing%20Lisp%20Code%20with%20Emacs
 
However, when he first asked me, I thought doing this required ParEdit, a minor mode I had heard a lot about, but not actually gotten around to installing. I grabbed paredit from here, installed it in ~/Library/Applications Support/Aquamacs/paredit.el, added the following to my .emacs file,
(autoload 'paredit-mode "paredit"   "Minor mode for pseudo-structurally editing Lisp code."   t) (add-hook 'lisp-mode-hook (lambda () (paredit-mode +1)))
and started reading this cheat sheet. Happily, though paredit does have some useful commands, taking advantage of it mostly requires nothing other than not typing closing parentheses (or quotation marks, or brackets).
 
Then, as it happened, Steve Yegge's oldie but goodie, Effective Emacs, was on the front page of Hacker News. So I read through that and added a few things to my .emacs file:
(global-set-key "\C-x\C-m" 'execute-extended-command) (global-set-key "\C-w" 'backward-kill-word) (global-set-key "\C-x\C-k" 'kill-region)
I'm going to try to incorporate his advice into my working habits.
 
Finally, feeling increased gumption in the Emacs area, at least, I decided to tackle something that had been bugging me for a while: how to have everything reopen when I quit Aquamacs. Ideally, I wanted all the tabs and windows to open in the same positions they'd been in, but I'd be happy if Aquamacs just reopened the buffers. My initial googling was fairly unsucessful, as I search for such things as "aquamacs reopen tabs" and "emacs reopen buffers", but eventually I found what was clearly what I needed: Saving Emacs Sessions.
 
The exact commands recommended therein didn't quite work for me, but once I knew to search for saving emacs sessions, instead of reopening emacs buffers, I was basically set. I had some issues when I tried to automatically open the saved session and start slime, but I'm okay with not starting slime automatically anyway, so things ended up working out, and it's wonderful not to have to be so terrified of quitting Emacs anymore, since I know when I open it again it'll be just like I left it. (Actually, though the buffers always open, the windows only sometimes do, and I can't figure out when and why, but it doesn't much matter to me.)
 
Here's the final version of my new .emacs file, including the clbuild stuff:
  ;; add this to your ~/.emacs to use clbuild and its slime: ;;   ;; possibly controversial as a global default, but shipping a lisp ;; that dies trying to talk to slime is stupid, so: (set-language-environment "UTF-8") (setq slime-net-coding-system 'utf-8-unix)   ;; set tags file (setq tags-table-list '("/Users/divia/.emacs.d/TAGS"))   (autoload 'paredit-mode "paredit"   "Minor mode for pseudo-structurally editing Lisp code."   t) (add-hook 'lisp-mode-hook (lambda () (paredit-mode +1))) (global-set-key "\C-x\C-m" 'execute-extended-command) (global-set-key "\C-w" 'backward-kill-word) (global-set-key "\C-x\C-k" 'kill-region) y   (desktop-save-mode 1)   ;; load slime: (setq load-path (cons "/Users/divia/Projects/clbuild/source/slime" load-path)) (setq load-path (cons "/Users/divia/Projects/clbuild/source/slime/contrib" load-path)) (setq slime-backend "/Users/divia/Projects/clbuild/.swank-loader.lisp") (setq inhibit-splash-screen t) (load "/Users/divia/Projects/clbuild/source/slime/slime") (setq inferior-lisp-program "/Users/divia/Projects/clbuild/clbuild --implementation sbcl lisp") (setq slime-use-autodoc-mode nil) (slime-setup '(slime-fancy slime-tramp slime-asdf)) ;;(slime)

Permalink | Leave a comment  »


Viewing all articles
Browse latest Browse all 20

Trending Articles