cperl-modeでの引数の無名関数のインデント
コールバックを引数で取るような関数で無名関数を使ったとき
こんな感じにして欲しいところですが、
なってしまいます。どうやったら一番上になるんだって思って
ソース見ていたらなんとかなりそうだったのでその手順を示します。
melpaから取得できる cperl-modeの場合
このためのフラグ cperl-indent-subs-speciallyが用意されているので
それを設定するだけで対応できます。
(setq cperl-indent-subs-specially nil) ;; もしくは (custom-set-variables '(cperl-indent-subs-specially nil))
Emacs付属の cperl-modeの場合
Emacs付属の cperl-modeも一応開発が進んでいるようで、
melpaにはない修正がいくつか見られました。ただ上記のフラグは
ないので、ソースを直す必要があるかと思います。
cperl-sniff-for-indent関数の以下の部分を修正すれば良いです。
以下は Emacs 24.1に付属する cperl-modeです。
diff --git a/cperl-mode.el b/cperl-mode.el index 9ea42db..b1ac843 100644 --- a/cperl-mode.el +++ b/cperl-mode.el @@ -2969,6 +2969,7 @@ Will not look before LIM." ;; first thing on the line, say in the case of ;; anonymous sub in a hash. (if (and;; Is it a sub in group starting on this line? + nil (cond ((get-text-property (point) 'attrib-group) (goto-char (cperl-beginning-of-property (point) 'attrib-group)))
.elファイルを修正しても .elcファイルがあればそっちを優先的に読んで
しまうので .elcを捨てるか、バイトコンパイルをしなおすかしてください。
補足
私の cperl-modeの indent周りの設定は以下のとおりです。
@sugyanさんのをパクってきただけですが・・・。
(cperl-set-style "PerlStyle") (custom-set-variables '(cperl-indent-parens-as-block t) '(cperl-close-paren-offset -4) '(cperl-indent-subs-specially nil))