I am using qq function to store my SQL requests in 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. How can I fix it?
Emacs has wonderful facilities that understand syntax really well considering it's not a full parser.
Try this in your init file.
(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. see tab-to-tab-stop