Linux Archive

Linux Archive (
-   Debian User (
-   -   Emacs lisp: Using AddKeywords in DerivedMode (

T o n g 06-27-2011 10:08 PM

Emacs lisp: Using AddKeywords in DerivedMode

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
"ifndef" "include" "endif" "define"
) 'words)



(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'.

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

(run-hooks 'my-mode-hook)

(provide 'my-mode)

Tong (remove underscore(s) to reply)

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: iuav0p$7r5$">$7r5$

All times are GMT. The time now is 10:37 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.