;;; praat-mode.el --- Praat code editing commands for Emacs ;; Author: Stefan Werner ;; Maintainer: ? ;; Created: 20 Feb 02 ;; Version: 0.1.0 ;; Keywords: praat ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License ;; as published by the Free Software Foundation; either version 2 ;; of the License, or (at your option) any later version. ;; wwww.gnu.org ;;; Commentary: ;; Sets up C-mode with support for praat-style #-comments and a lightly ;; hacked syntax table. ;; (Based on awk-mode.el) ;; You may wish to add something like the following to your ~/.emacs file ;; (the examples assume that you put praat-mode.el into your ~/emacs directory ;; and that your Praat script files have the suffix ".praat" in their name): ;; (setq load-path (cons "~/emacs" load-path)) ;; (autoload 'praat-mode "praat" "Enter Praat mode." t) ;; (setq auto-mode-alist (cons '("\\.praat$" . praat-mode) auto-mode-alist)) ;;; Code: (defvar praat-mode-syntax-table nil "Syntax table in use in Praat-mode buffers.") (if praat-mode-syntax-table () (setq praat-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?\\ "\\" praat-mode-syntax-table) (modify-syntax-entry ?\n "> " praat-mode-syntax-table) (modify-syntax-entry ?\f "> " praat-mode-syntax-table) (modify-syntax-entry ?\# "< " praat-mode-syntax-table) (modify-syntax-entry ?/ "." praat-mode-syntax-table) (modify-syntax-entry ?* "." praat-mode-syntax-table) (modify-syntax-entry ?+ "." praat-mode-syntax-table) (modify-syntax-entry ?- "." praat-mode-syntax-table) (modify-syntax-entry ?= "." praat-mode-syntax-table) (modify-syntax-entry ?% "." praat-mode-syntax-table) (modify-syntax-entry ?< "." praat-mode-syntax-table) (modify-syntax-entry ?> "." praat-mode-syntax-table) (modify-syntax-entry ?& "." praat-mode-syntax-table) (modify-syntax-entry ?| "." praat-mode-syntax-table) (modify-syntax-entry ?_ "_" praat-mode-syntax-table) (modify-syntax-entry ?\' "\"" praat-mode-syntax-table)) ;; Regexps for font-lock (defconst praat-font-lock-keywords (eval-when-compile (list ;; ;; Builtins. '("\\([a-zA-Z]*[.][.]+\\)" 1 font-lock-keyword-face) ;; ;; Keywords. (regexp-opt '("BEGIN" "END" "break" "continue" "delete" "exit" "else" "for" "getline" "if" "next" "print" "printf" "return" "while" "Add" "Copy" "Create" "Down" "Draw" "Formula" "Get" "Play" "Query" "Read" "Remove" "Rename" "To" "Write" "call" "clearinfo" "comment" "down" "echo" "editor" "else" "elsif" "endeditor" "endfor" "endform" "endif" "endproc" "endwhile" "execute" "exit" "fi$" "for" "form" "from" "if" "ifelse" "minus" "no" "pause" "plus" "print" "printline" "printtab" "procedure" "repeat" "select" "to" "until" "while" "yes" "Replace pitch tier" "Edit" "positive" "boolean" "sentence" "text" "Get duration" "Get additive constant" ">Get fraction correct" "Get chi squared probability" "Get Cramer's statistic" "Get contingency coefficient" "Get number of strings" "Get additive constant" "Get loudness" "Get intensity (dB)" "Get number of formants" "Get standard deviation" "Get starting time" "Get finishing time" "Get frame length" "Get number of frames" "Get first formant" "Get second formant" "Get band width" "Get frequency range" "Get highest frequency" "Get lowest frequency" "Get number of bands" "Get resynthesis (PSOLA)" "Get power in air" "Get sample period" "Get sample rate" "Get pitch" "Get number of points" "fileappend" "filedelete" "newline$" "tab$") 'words) ;; ;; Builtins. (cons (regexp-opt '(" AffineTransform" " AnyPoint" " AnyTier" " ArtWord" " Articulation" " Articulatory synthesis" " Artword" " BarkFilter" " CC" " Categories" " CategoriesEditor" " Cepstrum" " ChebyshevSeries" "ClassificationTable" " Cochleagram" " Configuration" " Confusion" " ContingencyTable" " Correlation" " Correspondence analysis" " Covariance" " DTW" " Design principles" " Discriminant" " Discriminant analysis" " Dissimilarity" " Distance" " Distributions" " DurationTier" " Editors" " Eigen" " Excitation" " Excitations" " ExperimentMFC" " FFNet" " Filtering" " Formant" " FormantFilter " " FormantFilter" " FormantTier" " Function" " Harmonicity" " INDSCAL analysis" " ISpline" " Intensity" " IntensityTier" " IntervalTier" " LFCC" " LPC" " LegendreSeries" " LongSound" " LongSoundEditor" " Ltas" " MFCC" " MSpline" " Manipulation" " ManipulationEditor" " Matrix"" MelFilter" " OTAnyGrammar" " OTAnyGrammarEditor" " OTGrammar" " OTGrammarEditor" " OTGrammar_tongueRoot" " PCA" " PSOLA" " PairDistribution" " ParamCurve" " Pattern" " Picture window" " Pitch" " PitchEditor" " PitchTier" " PitchTierEditor" " PointEditor" " PointProcess" " Polygon" " Polynomial" " Procrustus" " Proximity" " RealPoint" " RealTier" " Roots" " SSCP" " Salience" " Sampled" " ScalarProduct" " Sequence" " Similarity" " Sound" " Sound files" " SoundEditor" " SoundRecorder" " Speaker" " Spectrogram" " Spectrum" " SpectrumEditor" " SpellingChecker" " Strings" " TableOfReal" " TextGrid" " TextGridEditor" " TextPoint" " TextTier" " VocalTract" " Wavelet" " Weight" " WordList" " WordList")) 'font-lock-builtin-face) ;; ;; ;; Operators. (cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "=" "!=" "<>" "+" "-" "*" "/" "length" "left$" "right$" "mid$" "index" "rindex" "fixed$")) 'font-lock-constant-face) )) "Default expressions to highlight in Praat mode.") (define-derived-mode praat-mode c-mode "Praat" "Major mode for editing Praat code. This is much like C mode except for the syntax of comments. Its keymap inherits from C mode's and it has the same variables for customizing indentation. It has its own abbrev table and its own syntax table. Turning on Praat mode runs `praat-mode-hook'." (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter)) (set (make-local-variable 'paragraph-separate) paragraph-start) (set (make-local-variable 'comment-start) "# ") (set (make-local-variable 'comment-end) "") (set (make-local-variable 'comment-start-skip) "#+ *") (setq font-lock-defaults '(praat-font-lock-keywords nil nil ((?_ . "w"))))) (provide 'praat-mode) ;;; praat-mode.el ends here ; See http://uk.groups.yahoo.com/group/praat-users/message/267