I just recently became aware of the built-in `align' [1] function for
Emacs while looking for a nice way to auto-align some hash-maps in my
Clojure code. This was easily done using align with the following piece
of customization.
#+begin_src emacs-lisp
(add-to-list 'align-lisp-modes 'clojure-mode)
(add-to-list 'align-rules-list
'(clojure-keyword-map
(regexp . ":[^\s]+\\(\s+\\).+")
(group . 1)
(modes . align-lisp-modes)))
#+end_src
Then marking the following code and calling `align' will turn this
#+begin_src clojure
{:byte [1 byte]
:char [1 char]
:int16 [2 short]
:uint16 [2 uint16]
:int32 [4 int]
:uint32 [4 uint32]
:int64 [8 long]
:uint64 [8 uint64]
:float32 [4 float]
:float64 [8 double]
}
#+end_src
into this
#+begin_src clojure
{:byte [1 byte]
:char [1 char]
:int16 [2 short]
:uint16 [2 uint16]
:int32 [4 int]
:uint32 [4 uint32]
:int64 [8 long]
:uint64 [8 uint64]
:float32 [4 float]
:float64 [8 double]
}
#+end_src
I wonder if anyone else has written any similar Emacs alignment rules
for Clojure which they would be interested in sharing?
Thanks -- Eric
Footnotes:
[1]
,----
| align is an interactive Lisp function in `align.el.gz'.
|
| (align BEG END &optional SEPARATE RULES EXCLUDE-RULES)
|
| Attempt to align a region based on a set of alignment rules.
| BEG and END mark the region. If BEG and END are specifically set to
| nil (this can only be done programmatically), the beginning and end of
| the current alignment section will be calculated based on the location
| of point, and the value of `align-region-separate' (or possibly each
| rule's `separate' attribute).
|
| If SEPARATE is non-nil, it overrides the value of
| `align-region-separate' for all rules, except those that have their
| `separate' attribute set.
|
| RULES and EXCLUDE-RULES, if either is non-nil, will replace the
| default rule lists defined in `align-rules-list' and
| `align-exclude-rules-list'. See `align-rules-list' for more details
| on the format of these lists.
|
| [back]
`----
On Tue, Jan 4, 2011 at 9:10 PM, Eric Schulte <schult...@gmail.com> wrote:Alignment rules for let and defroutes are at the top of my most wanted list.
> I wonder if anyone else has written any similar Emacs alignment rules
> for Clojure which they would be interested in sharing?