考虑到 Emacs 不是一个完整的解析器,它有很好的工具可以很好地理解语法。
在你的初始化文件中试试这个。
(defun my-cperl-indent-command ()
"indent as cperl normally
indent relatively inside multi-line strings.
"
(interactive)
(let ((state (syntax-ppss)))
(if (and (nth 3 state) ;string
(and (nth 8 state) ;multi-line?
(< (nth 8 state) (point-at-bol))))
(indent-relative)
(cperl-indent-command))))
(eval-after-load "cperl-mode" '(define-key cperl-mode-map [remap cperl-indent-command] 'my-cperl-indent-command))
当然,您仍然需要进行调整indent-relative
以使其完全按照您的意愿行事。看tab-to-tab-stop