1

我正在使用qq函数将我的 SQL 请求存储在 Perl 中。像这样:

    qq{
       SELECT
             table1.name,
             table1.description
       FROM
             table1
       WHERE
             table1.id=?
    }

但是在 Emacs cperl-mode 中,不可能在 qq 中使用tab,这会减慢我的工作速度。我该如何解决?

4

1 回答 1

1

考虑到 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

于 2012-03-09T07:37:39.480 回答