適当な範囲でlispのインデント
前にM-x alignとかいうEmacsの拡張の話を書いたけど、align-currentという機能もあるらしい。そういえば、前からlispのインデントもregionの範囲をインデントするとか言うのを使っていたけど、毎回マークをつけるのが面倒なので対応する括弧でインデントするとか空白区切りの間でインデントするとかそういうのの方が便利そうだと思ったので試してみた。
まずは前使っていたの。
;;; regionをインデント (defun indent-current-region (from to) (interactive "*r") (if (> from to) (rotatef from to)) (save-excursion (save-restriction (narrow-to-region from to) (goto-char (point-min)) (funcall mode-specific-indent-command) (indent-region (point-min) (point-max)) (message "indent buffer") )))
カーソル位置から上下に空行が出てくるまでをインデント。
;;;現在の空白区切りでインデント (defun indent-current-block() (interactive) (save-excursion (let (from to) (if (setq from (progn (re-search-backward "^[ \t ]*$")(point))) (next-line)) (re-search-forward "^[ \t ]*$") (setq to (point)) (save-restriction (narrow-to-region from to) (goto-char (point-min)) (funcall mode-specific-indent-command) (indent-region (point-min) (point-max)) (message "indent buffer") ))))
■ついでに
indent-to-token.lというのがxyzzyにもあるらしいというのを書いたけど、あれはどうもM-x alignと全く同じ動きはしないので、ある程度くり返したりするlispを書いた方が便利かもしれない。
■追記
シロさんの話によると、既に普通の補完を連続してやるのは存在するらしい。*1。まあ、既に書いてしまったものは仕方がないし、一応自分の思ったようには動作しているので、まあ、いいかなぁと。不満が出たらac-modeなるのを試した見ようかと思う。
最近、2種類くらい補完もしたい気分も少しあるけど、ひょっとして既に在るんじゃないかと、気になったので、先にここで書いてみる事に。
*1: ヽ(´д`ヽ)(ノ´д`)ノイヤァ〜