1

SQL リクエストを Perl に保存するためにqq関数を使用しています。このような:

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

しかし、Emacs の cperl-mode では、qq 内でタブを使用することができず、作業が遅くなります。どうすれば修正できますか?

4

1 に答える 1

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

于 2012-03-09T07:37:39.480 に答える