aboutsummaryrefslogtreecommitdiff
path: root/scripts/pd-mode.el
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-05-30 19:13:56 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-05-30 19:13:56 +0000
commit099203b69050791f0dad8f631d5d62e674ddf5a4 (patch)
treeace64477c1ec7823a572b86efeb84b2eb88ffb60 /scripts/pd-mode.el
parent1f12848028ff543b3938970ff4b77fe225eb5708 (diff)
updated for new libdir layout which needs a different declare statment than the 0.41.4 release
svn path=/trunk/; revision=13580
Diffstat (limited to 'scripts/pd-mode.el')
-rw-r--r--scripts/pd-mode.el123
1 files changed, 10 insertions, 113 deletions
diff --git a/scripts/pd-mode.el b/scripts/pd-mode.el
index d4a2e3b1..7fa29631 100644
--- a/scripts/pd-mode.el
+++ b/scripts/pd-mode.el
@@ -42,118 +42,15 @@
;;; Code:
;; Requires
-(require 'regexp-opt)
-
-
-;; Variables
-(defvar pd-mode-map nil
- "Keymap used for Pd file buffers")
-
-(defvar pd-mode-syntax-table nil
- "Pd file mode syntax table")
-
-(defvar pd-mode-hook nil
- "*List of hook functions run by `pd-mode' (see `run-hooks')")
-
-
-;; Font lock
-(defconst pd-font-lock-keywords
- (purecopy
- (list
- (list (concat ; object types
- "^#X \\("
- (regexp-opt '("connect" "floatatom" "msg" "obj" "scalar" "struct"
- "symbolatom" "text"))
- "\\) ")
- 1 'font-lock-type-face)
-
- (list (concat ; object types
- "\\(^#[NX] "
- (regexp-opt '("canvas" "restore"))
- "\\) ")
- 1 'font-lock-warning-face)
-
- ; connect numbers
- (list "^#X connect \\([0-9]+\\) [0-9]+ [0-9]+ [0-9]+"
- 1 'font-lock-variable-name-face)
- (list "^#X connect [0-9]+ \\([0-9]+\\) [0-9]+ [0-9]+"
- 1 'font-lock-function-name-face)
- (list "^#X connect [0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+"
- 1 'font-lock-variable-name-face)
- (list "^#X connect [0-9]+ [0-9]+ [0-9]+ \\([0-9]+\\)"
- 1 'font-lock-function-name-face)
-
- ; x y coords
- (list "^#X [a-z]+ \\([0-9]+ [0-9]+\\) "
- 1 'font-lock-reference-face)
-
-; terminating semi-colon
- (list ";$" 0 'font-lock-warning-face t)
-
- (list "\\(^#X\\)" 0 'font-lock-builtin-face t)
-
-; (list "\\(^#N\\)" 0 'font-lock-constant-face t)
-
-; (list "^#N.*$" 0 'font-lock-comment-face t)
-
- (list "^#X obj [0-9]+ [0-9]+ \\([a-zA-Z0-9+*._-]+\\)[ ;]"
- 1 'font-lock-constant-face t)
-
- (list "^#X msg [0-9]+ [0-9]+ \\([a-zA-Z0-9+*._-]+\\);"
- 1 'font-lock-variable-name-face)
-
-; (list "^#X text [0-9]+ [0-9]+ \\(.*\\);"
-; 1 'font-lock-comment-face)
- ))
- "Expressions to highlight in Pd config buffers.")
-
-(put 'pd-mode 'font-lock-defaults '(pd-font-lock-keywords nil t
- ((?_ . "w")
- (?- . "w"))))
-;; Syntax table
-(if pd-mode-syntax-table
- nil
- (setq pd-mode-syntax-table (copy-syntax-table nil))
- (modify-syntax-entry ?_ "_" pd-mode-syntax-table)
- (modify-syntax-entry ?- "_" pd-mode-syntax-table)
- (modify-syntax-entry ?\( "(\)" pd-mode-syntax-table)
- (modify-syntax-entry ?\) ")\(" pd-mode-syntax-table)
- (modify-syntax-entry ?\< "(\>" pd-mode-syntax-table)
- (modify-syntax-entry ?\> ")\<" pd-mode-syntax-table)
- (modify-syntax-entry ?\" "\"" pd-mode-syntax-table))
-
-
-;;;###autoload
-(defun pd-mode ()
- "Major mode for editing Pd configuration files.
-
-\\{pd-mode-map}
-
-\\[pd-mode] runs the hook `pd-mode-hook'."
- (interactive)
- (kill-all-local-variables)
- (use-local-map pd-mode-map)
- (set-syntax-table pd-mode-syntax-table)
-
- (make-local-variable 'comment-start)
- (setq comment-start "#N ")
- (make-local-variable 'comment-start-skip)
- (setq comment-start-skip "#\\W*")
- (make-local-variable 'comment-column)
- (setq comment-column 48)
-
- ;;font-lock stuff (may not be initially necessary for XEmacs)
- (font-lock-mode 1)
- (setq font-lock-keywords pd-font-lock-keywords)
- (font-lock-fontify-buffer)
-
- (setq mode-name "Pd")
- (setq major-mode 'pd-mode)
-
- (run-hooks 'pd-mode-hook))
-
-
-;; Provides
-(provide 'pd-mode)
+(require 'generic-x)
+
+(define-generic-mode 'pd-mode
+ nil
+ '("osc~" "random" "route" "trigger")
+ '(("#X \\([^ ]+\\) " . 'font-lock-function-name-face)
+ (";" . 'font-lock-warning-face))
+ '(".pd\\'" ".pat\\'")
+ nil
+ "Major mode for editing Pd files")
;;; pd-mode.el ends here