;; LSL scripting mode (require 'cc-mode) ;; (require 'w3) (defvar linden-mode-hook nil) (defvar linden-types '("string" "float" "integer" "rotation" "list" "vector" "key")) (defvar linden-keywords '("for" "else" "if" "return" "default")) (defvar linden-event-builtins '("at_rot_target" "at_target" "attach" "changed" "collision" "collision_end" "collision_start" "control" "dataserver" "email" "land_collision" "land_collision_end" "land_collision_start" "link_message" "listen" "money" "moving_end" "moving_start" "no_sensor" "not_at_rot_target" "not_at_target" "object_rez" "on_rez" "remote_data" "run_time_permissions" "sensor" "state_entry" "state_exit" "timer" "touch" "touch_start" "touch_end")) (defun linden-regexpify-list (list &optional noparens) (concat (if noparens "" "\\(") (mapconcat 'identity list "\\|") (if noparens "" "\\)"))) (defconst linden-font-lock-keywords-1 (list (cons (concat "\\<" (linden-regexpify-list linden-types) "\\>") 'font-lock-type-face) (cons (concat "\\<" (linden-regexpify-list linden-keywords) "\\>") 'font-lock-keyword-face) (cons (concat "\\<" (linden-regexpify-list linden-event-builtins) "\\>") 'font-lock-builtin-face) '("\\<[A-Z_]\\{2,\\}\\>" . font-lock-constant-face) '("\\" . font-lock-builtin-face) ) "Highlighting for Linden LSL") (defconst linden-keywords (concat (linden-regexpify-list linden-types) (linden-regexpify-list linden-keywords) (linden-regexpify-list linden-event-builtins))) (defvar linden-font-lock-keywords linden-font-lock-keywords-1 "Highlighting for Linden LSL") (defvar linden-mode-syntax-table nil "Syntax table used in linden-mode buffers.") (if linden-mode-syntax-table () (setq linden-mode-syntax-table (make-syntax-table)) (c-populate-syntax-table linden-mode-syntax-table)) (defvar linden-mode-abbrev-table nil "Abbreviation table used in linden-mode buffers.") (define-abbrev-table 'linden-mode-abbrev-table '(("else" "else" c-electric-continued-statement 0) ("while" "while" c-electric-continued-statement 0))) (defvar linden-mode-map () "Keymap used in linden-mode buffers.") (if linden-mode-map nil (setq linden-mode-map (c-make-inherited-keymap)) ) (defconst linden-indent-style '((c-basic-offset . 4) (c-comment-only-line-offset . (0 . 0)) (c-offsets-alist . ((statement-block-intro . +) (knr-argdecl-intro . 5) (substatement-open . +) (label . 0) (statement-case-open . 0) (statement-cont . 0) (arglist-intro . c-lineup-arglist-intro-after-paren) (arglist-close . c-lineup-arglist) (inline-open . 0) (brace-list-open . +) )) (c-block-comment-prefix . "") )) ;;(defun linden-llhelp (func) ;; "Load the help page from the SecondLife wiki" ;; (interactive) ;; (w3-fetch (concat "http://secondlife.com/badgeo/wakka.php?wakka=" func)) ;;) (defun linden-mode () "Major mode for editing Linden LSL code" (interactive) (c-initialize-cc-mode) (kill-all-local-variables) (set-syntax-table linden-mode-syntax-table) (setq major-mode 'linden-mode mode-name "Linden LSL" local-abbrev-table linden-mode-abbrev-table abbrev-mode t) (c-common-init) (setq comment-start "// " comment-end "" c-keywords (c-identifier-re linden-keywords) c-conditional-key nil c-comment-start-regexp c-C++-comment-start-regexp c-class-key c-C-class-key c-method-key nil c-baseclass-key nil c-recognize-knr-p nil c-inexpr-class-key nil ) (use-local-map linden-mode-map) (c-add-style "linden" linden-indent-style) (c-set-style "linden") (set (make-local-variable 'font-lock-defaults) '(linden-font-lock-keywords)) (run-hooks 'c-mode-common-hook) (run-hooks 'linden-mode-hook) (c-update-modeline) ) (provide 'linden-mode)