2012-03-08 65 views
1

我使用qq函数将我的SQL请求存储在Perl中。就像这样:Emacs在cpl模式下使用<tab>内部qg

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

但在Emacs cperl模式是不可能的使用标签内部QQ,减慢我的工作。我该如何解决它?

回答

1

考虑到它不是一个完整的解析器,Emacs拥有非常好的理解语法的功能。

在你的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)) 

当然,你仍然需要调整indent-relative让它做到你想要的。见tab-to-tab-stop

+0

非常感谢。有效。 – user4035 2012-03-10 11:45:04