Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   Emacs lisp: Using AddKeywords in DerivedMode (http://www.linux-archive.org/debian-user/545216-emacs-lisp-using-addkeywords-derivedmode.html)

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

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/


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: iuav0p$7r5$1@dough.gmane.org">http://lists.debian.org/iuav0p$7r5$1@dough.gmane.org


All times are GMT. The time now is 06:44 AM.

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