I want fold php block in php template file.
<html> <?php $bar = foo(); echo $bar; ?> <h1><?php echo $title; ?></h1> </html> to >>>> <html> {{PHP}} <h1>{{PHP}}</h1> </html>
First, I try to use font-lock-add-keywords, it failed. Many thanks to @Gilles for (support? advice? I don't know which word should be here, sorry).
(eval-after-load 'php-mode '(progn (setq font-lock-multiline t) (font-lock-add-keywords 'php-mode `(("\\(<?php .* ?>\\)(" (0 (progn (compose-region (match-beginning 1) (match-end 1) "の") nil)))))))
Then, I try below, It works.
(defun lot/php-hide () "compose php block in buffer" (interactive) (beginning-of-buffer) (while (re-search-forward "\\(<\\?php\\(.\\|\n\\)*?\\?>\\)" nil t) ;; (make-overlay (match-beginning 0) (match-end 0)) ;; (hide-region-hide) ;; 'hide-region-hide' doesn't work, so try compose-region (compose-region (match-beginning 0) (match-end 0) ;; "{{PHP}}" ; use word can't work perfect. "の" ) ) )
Show me the error if have, Thank you XD
Ƥ
. the Ƥ is block. – lot Dec 23 '10 at 03:02