#7 instructions to work with mmm-mode

closed
nobody
None
5
2002-01-23
2001-08-26
Turadg Aleahmad
No

Discussion

  • Logged In: YES
    user_id=152677

    Here you go:

    Add this to your .emacs:

    (require 'mmm-mode)
    (setq mmm-global-mode 'maybe)
    (mmm-add-mode-ext-class nil "\\.php[34]?\\'" 'html-php)
    (mmm-add-classes
    '((html-php
    :submode php-mode
    :front "<\\?\\(php\\)?"
    :back "\\?>")))
    (autoload 'php-mode "php-mode" "PHP editing mode" t)
    (add-to-list 'auto-mode-alist '("\\.php[34]?\\'" . html-mode))

    (defun my-php-hook ()
    ;; C-c C-f is used by pgsml
    (define-key php-mode-map
    "\C-c\C-l"
    'php-search-documentation)

    ;; C-c C-m is used by pgsml
    (define-key php-mode-map
    "\C-c\C-p"
    'php-browse-manual)

    (c-toggle-hungry-state t))

    (add-hook 'php-mode-hook 'my-php-hook)

    Done.

    BTW, I would suggest changing the php-browse-manual and
    php-search-documentation keybindings to those above since
    C-C C-f and C-C C-m are used as prefixes by HTML mode, so
    they stop working when php-mode is run as a sub-mode.

     
  • Logged In: YES
    user_id=152677

    Actually, this works better:

    ;; PHP mode

    (require 'mmm-mode)
    (setq mmm-global-mode 'maybe)
    (mmm-add-mode-ext-class nil "\\.php[34]?\\'" 'html-php)
    (mmm-add-classes
    '((html-php
    :submode php-mode
    :front "<\\?\\(php\\)?"
    :back "\\?>")))
    (autoload 'php-mode "php-mode" "PHP editing mode" t)
    (add-to-list 'auto-mode-alist '("\\.php[34]?\\'" . html-mode))

    (defun insert-php-region ()
    (interactive "*")
    (let ((php-template '("<?php" > n p n "?>" > n )))
    (tempo-insert-template 'php-template tempo-insert-region)
    (mmm-parse-buffer)))

    (defun my-php-hook ()
    ;; C-c C-f is used by pgsml
    (define-key php-mode-map
    "\C-cd"
    'php-search-documentation)

    ;; C-c C-m is used by pgsml
    (define-key php-mode-map
    "\C-cb"
    'php-browse-manual)

    (define-key html-mode-map
    "\C-c\C-p"
    'insert-php-region)

    (c-toggle-hungry-state t))

    (add-hook 'php-mode-hook 'my-php-hook)

     
    • status: open --> closed
     
  • Logged In: YES
    user_id=137402

    May I upload make your code a file for download? How
    should I credit you?

     
  • Logged In: YES
    user_id=152677

    Of course you may.

    You may credit me by saying something like "thanks to Ryan
    T. Sammartino".

    Cheers.