简体   繁体   English

Emacs使用 <tab> 在cperl模式下的内部qq

[英]Emacs use <tab> inside qq in cperl-mode

I am using qq function to store my SQL requests in Perl. 我正在使用qq函数将我的SQL请求存储在Perl中。 Like this: 像这样:

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

But in Emacs cperl-mode it's impossible to use tab inside qq, which slows my work. 但是在Emacs cperl模式下,无法在qq中使用制表符 ,这会使我的工作变慢。 How can I fix it? 我该如何解决?

Emacs has wonderful facilities that understand syntax really well considering it's not a full parser. 考虑到Emacs不是完整的解析器,它具有出色的功能,可以很好地理解语法。

Try this in your init file. 在您的init文件中尝试。

(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))

Of course you still need to tweak indent-relative to get it to do exactly what you want. 当然,您仍然需要调整indent-relative对于indent-relative以使其完全执行所需的操作。 see tab-to-tab-stop 查看tab-to-tab-stop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM