I created an align for Clojure a little while back. [1] It has some limitations such as not handling type hints (yet) but works well enough. There was also a fork [2] that added alignment to compojure forms.
[1] http://clojure-libraries.appspot.com/show/34002 [2] https://github.com/scottjad/align-cljlet On 2 April 2011 16:50, Christian Schuhegger <christian.schuheg...@gmail.com>wrote: > I am replying to this thread from January this year: > https://groups.google.com/group/clojure/browse_frm/thread/47c388127e0da3ef > > I am not certain if my solution fulfills the aesthetic requirements of > clojure hackers, but I use one of my old C/C++ marcros for aligning > equal signs to align at commas (see below). As commas in clojure are > whitespace you can put them in front of the clauses you want to be > aligned, e.g. in let binding forms. You select the region you want the > alignment to happen and press C-= and the full block gets nicely > aligned. > > I hope this may be useful for other people, too. > > -- snip start -- > (defun align-equals (start end) > "make the first assignment operator on each line line up vertically" > (interactive "*r") > (save-excursion > (let ((indent 0)) > (narrow-to-region start end) > (beginning-of-buffer) > (while (not (eobp)) > (if (find-assignment) > (progn > (exchange-point-and-mark) > (setq indent (max indent (current-column))) > (delete-horizontal-space) > (insert " "))) > (forward-line 1)) > (beginning-of-buffer) > (while (not (eobp)) > (if (find-assignment) > (indent-to-column (1+ (- indent (- (mark) (point)))))) > (forward-line 1))) > (widen))) > > (defun find-assignment () > (if (re-search-forward > "[^<>=!]=\\|\\+=\\|-=\\|\\*=\\|/=\\|&=\\||=\\|\\^=\\|<<=\\|>>=\ > \|:=\\|:\\|," > (save-excursion (end-of-line) (point)) t) > (progn > (goto-char (match-beginning 0)) > (if (looking-at ".==") > nil > (if (looking-at > "\\+=\\|-=\\|\\*=\\|/=\\|&=\\||=\\|\\^=\\|<<=\\|>>=\ > \|:=\\|:\\|,") > (set-mark (match-end 0)) > (forward-char 1) > (set-mark (1+ (point)))) > (delete-horizontal-space) > t)) > nil)) > > (global-set-key [(control =)] 'align-equals) > > -- snip end -- > > -- > 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 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