代码之家  ›  专栏  ›  技术社区  ›  Matthias

Emacs lisp代码缩进

  •  0
  • Matthias  · 技术社区  · 9 年前

    在emacs lisp模式下,每当我插入右大括号时,我都希望缩进到同一列,就像相应的左大括号一样。这怎么可能?如果我的init.el中有eg

    (defadvice isearch-forward-regexp (before kill-ring-save-before-search activate)
      "Save region (if active) to kill-ring before starting isearch. So that region
    can be inserted into isearch easily with C-y."
      (when (region-active-p)
        (kill-ring-save (region-beginning) (region-end))
        ) ;; this should be under (when
      ) ;; this should be under (defadvice
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   abo-abo    9 年前

    您似乎希望对齐闭合的括号,以便能够 在视觉上使它们与开头的相匹配。你可以用 show-paren-mode 相反,这工作做得更好。

    正如其他人所指出的,我完全同意,悬挂的括号是 看起来非常烦人和痛苦-不要养成使用的习惯 他们我写了一个编辑Elisp的小模式,可能是 对你来说很有趣- lispy-mode :

    1. 紧迫的 将自动缩进s表达式,消除 悬挂的括号。

    2. 紧迫的 d 将从s表达式的一侧切换到 另一个:快速查看当前列表包含的内容。

    3. 紧迫的 将在 当前列表:您可以更清楚地看到它包含的内容。