[Prev]

5.5 emacs pd-mode

Installing emacs pd-mode is optional.

To install, just add following to your .emacs file and restart

  (setq auto-mode-alist (cons (cons "\\.pd"   'pd-mode) auto-mode-alist))

  ;; pd-mode
  ;;
  ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
  ;; Derived from m4-mode.el by Andrew Csillag <drew_csillag@geocities.com>
  ;; as distributed with emacs-21, which see.
  ;; 28.2.2003, hacked by Sampo Kellomaki <sampo@symlabs.com>
  ;;
  ;; Either paste this in your .emacs or arrange it to be loaded.
  ;; Include -*-pd-*- on first line of your files.

  (defgroup pd nil
    "Major mode for editing PlainDoc documents"
    :prefix "pd-"
    :group 'languages)

  (defvar pd-font-lock-keywords
    `(
      ("^[0-9]+.+\n===+$"  . font-lock-string-face)
      ("^[0-9]+.+\n---+$"  . font-lock-string-face)
      ("^[0-9]+.+\n~~~+$"  . font-lock-string-face)
      ("<<\\w+[^>]*>>"     . font-lock-doc-string-face)
      ("\\[\\w+\\]"         . font-lock-type-face)
      ("(\\*\\*\\*[^)]*)"  . font-lock-function-name-face)
      ("\\*\\w[^*]*\\w\\*" . font-lock-type-face)
      ("\\^\\w[^^]*\\w\\^" . font-lock-type-face)
      ("^\\w+[^:]*::"      . font-lock-type-face)
      ("\\~\\w[^~]*\\w\\~" . font-lock-keyword-face)
      ("\\+\\w[^+]*\\w\\+" . font-lock-keyword-face)
      ("\\!\\w[^!]*\\w\\!" . font-lock-keyword-face)
      "Default font-lock-keywords for pd mode.")
  )

  (defvar pd-mode-syntax-table nil
    "syntax table used in pd mode")
  (setq pd-mode-syntax-table (make-syntax-table))
  (modify-syntax-entry ?# "<\n" pd-mode-syntax-table)
  (modify-syntax-entry ?\n ">#" pd-mode-syntax-table)

  (defcustom pd-mode-hook nil
    "*Hook called by `pd-mode'."
    :type 'hook
    :group 'pd)

  (defvar pd-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map "\C-c\C-c" 'comment-region)
      map))

  (defvar pd-mode-abbrev-table nil
    "Abbrev table used while in pd mode.")

  (unless pd-mode-abbrev-table
    (define-abbrev-table 'pd-mode-abbrev-table ()))

  ;;;###autoload
  (defun pd-mode ()
    "A major mode to edit pd files"
    (interactive)
    (kill-all-local-variables)
    (use-local-map pd-mode-map)
  
    (make-local-variable 'comment-start)
    (setq comment-start "#")
    (make-local-variable 'comment-end)
    (setq comment-end "")
    (make-local-variable 'parse-sexp-ignore-comments)
    (setq parse-sexp-ignore-comments t)
    (setq local-abbrev-table pd-mode-abbrev-table)

    (make-local-variable	'font-lock-defaults)  
    (setq major-mode 'pd-mode
          mode-name "pd"
          font-lock-defaults '(pd-font-lock-keywords nil)
          )
    (set-syntax-table pd-mode-syntax-table)
    (run-hooks 'pd-mode-hook))

  (provide 'pd-mode)

  ;; end of pd mode

If your document extension is not .pd, you can always say

  M-x pd-mode

to get it started.


[Prev | Next]
.