【问题标题】:Emacs indent issue with qw keywordqw 关键字的 Emacs 缩进问题
【发布时间】:2019-11-14 10:10:06
【问题描述】:

从 jrockway 的 cperl-mode 存储库的最后一次提交中,我使用 cperl-mode 6.2 在 windows 上运行 Emacs 26.3。

我对 Emacs 有以下配置:

(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq cperl-indent-level 4)
(setq cperl-indent-parens-as-block t)
(setq cperl-close-paren-offset -4)
(setq cperl-continued-statement-offset 4)
(setq cperl-tab-always-indent t)
(setq cperl-fix-hanging-brace-when-indent t)
(setq cperl-indent-subs-specially nil)

当我用 qw() 初始化一个数组时,它给了我以下信息:

my @toto = qw(
                 toto
                 tutu
         );

my @tutu = qw[
                 tata
                 titi
         ];

use constant CR => qw(
                         87800
                         76400
                         80200
                         81000
                 );

这不是我的指导方针,因为我遵循 80 个字符的规则...... 我不知道这是正常行为还是错误。 我尝试了多种配置,查看了 cperl 的自定义组,但我找不到一种方法来制作我想要的东西。 这是我想做的:

my @toto = qw(
    toto
    tutu
);

my @tutu = qw[
    tata
    titi
];

use constant CR => qw(
    87800
    76400
    80200
    81000
);

任何人有想法或 Elisp 黑客来做到这一点?

感谢您的帮助:)

【问题讨论】:

  • 感谢您报告此事。对于第一行带有(例如最后一个use constant CR => qw( ...,如果光标位于带有87800 的第一行,当您按下<tab>cperl-mode 将检查上面行的缩进,如line #3092 所示源代码。请注意,此行上的(current-column) 将给出上行的缩进位置(qw(( 之后的位置,由于第 3089 行的goto。我会进一步尝试明白为什么会这样......
  • ...我也同意你的观点,你建议的缩进看起来好多了:)
  • 我添加了一个pull request,你能看看它是否适合你吗?

标签: perl emacs indentation cperl-mode


【解决方案1】:

我刚刚向 Emacs 的 master 分支推送了一个补丁,以修复 qwperl-mode 中的缩进。
它现在几乎可以像您想要的那样工作(除了结束括号)。例如:

my @tutu = qw[
    tata
    titi
    ];

【讨论】:

  • 感谢这次提交,但这不是我想要的。我个人不使用perl-mode,因为这些天它被cperl-mode 远远超越了。perl-modecperl-mode 的修复不一样吗?
  • @LucasLam:cperl-mode 的代码完全不同,因此“相同的修复”可能是可能的,但前提是您认为“相同”的定义非常宽松。我忍不住要提一下,我发现你的“这些日子”非常令人困惑:perl-mode 曾经比cperl-mode 落后光年,但多年来,AFAIK 的距离趋于缩小而不是增加。
【解决方案2】:

由来自@HåkonHægland 的https://github.com/jrockway/cperl-mode/pull/54 解决。

【讨论】:

    猜你喜欢
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    • 2011-04-26
    • 2011-06-07
    • 1970-01-01
    相关资源
    最近更新 更多