Where am I going wrong in defining emacs major mode?

100 views Asked by At

I am trying to define a new mode which inherits everything from Org mode, called web mode.

Here is a preliminary amateur stab at this.

(defvar web-mode-syntax-table
       org-mode-syntax-table
       "Syntax table used while in `web-mode'.")

;; Create the keymap for this mode.
(defvar web-mode-map
       org-mode-map
       "Keymap for `web-mode'.")


(setq web-highlights
      '(("Sin\\|Cos\\|Sum" . font-lock-function-name-face)
        ("Pi\\|Infinity" . font-lock-warning-face)))

;; set files ending in .web to open in web mode. 
(add-to-list 'auto-mode-alist '("\\.web\\'" . web-mode))

(define-derived-mode web-mode org-mode "web-mode"
  "Major mode based on Org-mode"
    (kill-all-local-variables)
    (setq major-mode 'web-mode)
    (setq mode-name "Web Mode")

    ;; Tell font-lock mode about some things which
    ;; need to be highlighted. 
    (setq font-lock-defaults '(web-highlights))

  )

However, when web-mode is loaded in a text file it seems identical to the plain-vanilla text mode. The key-words Sin, Cos and Sum get highlighted in blue correctly and the Pi and Infinity in bold red font, but otherwise nothing seems to have been inherited from Org mode, and seems indistinguishable from text mode.

Why is this?

0

There are 0 answers