Rya*_*son 8 emacs indentation auto-indent cperl-mode
在emacs的cperl-mode中,连续前一行语句的行缩进一级:
my $var
= (1+1)
* (2+2)
/ (3+3);
Run Code Online (Sandbox Code Playgroud)
但是,如果语句不是从零缩进开始,因为它在块内,那么如果将语句分成第三行,则会得到另一级别的缩进,依此类推:
sub break_my_indentation {
my $var
= (1+1)
* (2+2)
/ (3+3);
return "Indentation is broken.";
}
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题,以便语句在块内部以与外部相同的方式缩进?我想第二个例子看起来像这样:
sub fix_my_indentation {
my $var
= (1+1)
* (2+2)
/ (3+3);
return "Indentation is fixed.";
}
Run Code Online (Sandbox Code Playgroud)
我确认您描述的行为存在,但是,从阅读源代码并在调试器下运行,并不是很明显有一个自定义可以让您(和我)想要的行为.
因此,我认为这是一个错误cperl-mode.
修复是:
=== modified file 'lisp/progmodes/cperl-mode.el'
--- lisp/progmodes/cperl-mode.el 2012-12-01 05:09:12 +0000
+++ lisp/progmodes/cperl-mode.el 2012-12-26 16:29:19 +0000
@@ -3120,7 +3121,9 @@ and closing parentheses and brackets."
((eq 'continuation (elt i 0))
;; [continuation statement-start char-after is-block is-brace]
(goto-char (elt i 1)) ; statement-start
- (+ (if (memq (elt i 2) (append "}])" nil)) ; char-after
+ (+ (if (or (memq (elt i 2) (append "}])" nil)) ; char-after
+ (eq 'continuation ; do not repeat cperl-close-paren-offset
+ (elt (cperl-sniff-for-indent parse-data) 0)))
0 ; Closing parenth
cperl-continued-statement-offset)
(if (or (elt i 3) ; is-block
Run Code Online (Sandbox Code Playgroud)
请测试这个补丁; 如果你对它感到满意,我会添加一个自定义来启用它.
| 归档时间: |
|
| 查看次数: |
636 次 |
| 最近记录: |