how can I make <? always trigger php-mode

Asked by tracey jaquith

when I have code now like:

<?require_once("setup.inc"); ...

<?if($a)...

<?foreach...

the sequences like "<?r" and "<?i" and "<?f" trigger a "bad mode".
I've tried a bit to mod the local .el files to make "<?f" and similar explicit triples of chars trigger php-mode, but not able to get working so far.

Is there a suggested way to do that -- or even more generally any "<?" triggers php-mode (sufficient for our setup)

thanks for any help/pointers/RTFMs! 8-)

Question information

Language:
English Edit question
Status:
Solved
For:
nXhtml Edit question
Assignee:
No assignee Edit question
Solved by:
tracey jaquith
Solved:
Last query:
Last reply:
Revision history for this message
tracey jaquith (tracey-pooh) said :
#1

aha! think i figured out my own answer (the proverbial "one line change", too, woo).

a bit of a sledgehammer, but essentially never do bad-mode and always fallback to php-mode after anything like "<?" that isn't "<?xml" is found...

Index: mumamo-fun.el
===================================================================
--- mumamo-fun.el (revision 9467)
+++ mumamo-fun.el (working copy)
@@ -296,41 +296,41 @@
 ;; "Helper for `mumamo-chunk-xml-pi'.
 ;; POS is where to start search and MIN is where to stop."
 ;; (mumamo-search-bw-exc-start-xml-pi-1 pos min "<?"))

 (defun mumamo-search-fw-exc-start-xml-pi-new (pos max)
   (let ((here (point))
         start
         spec
         exc-mode
         ret)
     (setq start (search-forward "<?" max t))
     (when (and start
                (looking-at (rx (0+ (any "a-z")))))
       (setq spec (match-string-no-properties 0))
       (unless (string= spec "xml")
         (when (= 0 (length spec))
           (setq spec "php"))
         (setq exc-mode (assoc spec mumamo-xml-pi-mode-alist))
         (if exc-mode
             (setq exc-mode (cdr exc-mode))
- (setq exc-mode 'mumamo-bad-mode))
+ (setq exc-mode 'php-mode))
         (setq ret (list (- start 2) exc-mode nil))))
     (goto-char here)
     ret))

 (defun mumamo-xml-pi-end-is-xml-end (pos)
   "Return t if the ?> at pos is end of <?xml."
   (when (> 1000 pos)
 ;;; (assert (and (= (char-after pos) ??)
 ;;; (= (char-after (1+ pos)) ?>)))
     (save-excursion
       (save-restriction
         (widen)
         (save-match-data
           (when (search-backward "<" (- pos 150) t)
             (when (looking-at (rx line-start "<\?xml" (1+ space)))
               (mumamo-msgfntfy "mumamo-xml-pi-end-is-xml-end %s => t" pos)
               t)))))))

 ;; (defun mumamo-search-bw-exc-end-xml-pi (pos min)
 ;; "Helper for `mumamo-chunk-xml-pi'.