[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Emacs lisp: Using AddKeywords in DerivedMode



Hi,

I've read the wiki for AddKeywords and DerivedMode, but I still don't 
know how to put them together -- I tried myself, but all existing 
behaviours or my original mode (eg, font locking, indenting) are just 
gone. [1]

Please provide me with the simplest elisp code frame that derives from an 
existing modes, with the following features.

- register a certain extension, .myext or whatever, optional.
- specific that keyword matching is now case insensitive.
- anything else behaves exactly like the original mode.
- add the following example extra keywords.

  (defconst my-builtin
    (cons
     (regexp-opt
	  (list
	   "ifndef" "include" "endif" "define"
	   ) 'words)
     font-lock-builtin-face
    ))

  (font-lock-add-keywords
   'my-mode
   (list
    my-types
    my-builtin
    ...
  ))

Thanks!!!

[1]
;;###autoload
(define-derived-mode my-mode sh-mode "MY"
  "Major mode for editing my files.
Turning on My mode and running the normal hook `my-mode-hook'.
"
  (interactive)

  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults 
	'(my-builtin
	  nil				; KEYWORDS-ONLY: no
	  nil				; CASE-FOLD: no
	  ((?_ . "w"))			; SYNTAX-ALIST
	  ))

  (run-hooks 'my-mode-hook)
)

(provide 'my-mode)




-- 
Tong (remove underscore(s) to reply)
  http://xpt.sourceforge.net/techdocs/
  http://xpt.sourceforge.net/tools/


Reply to: