[Remind-Fans] Updated emacs mode for remind

David F. Skoll dfs at roaringpenguin.com
Fri Feb 15 12:27:05 EST 2008


Hi,

I made a bunch of fixes... please try this one out.

o Case-insensitive keywords
o Recognize "#" as a comment-starter
o Don't highlight keywords that are not standalone words
o Highlight strings.

Regards,

David.

;;; CUT HERE
;;; remind-conf-mode.el ---

;; Copyright (C) 2008  Shelagh Manton <shelagh.manton at gmail.com>

;; Author: Shelagh Manton <shelagh.manton at gmail.com>
;; Keywords: remind configure mode
;; Version: .01

;; 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.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.

;;; Commentary:

;; Use this mode to help with the configuration of remind configuration files.
;; Put (require 'remind-conf-mode) in your .emacs file
;; also put (add-to-list 'auto-mode-alist '("\\.rem$" . remind-conf-mode))
;; (add-to-list 'auto-mode-alist '("~/.reminders$" . remind-conf-mode)) if you
;; want to have the mode work automatically when you open a remind configuration file.


;;; History:
;; Thu, Feb 14, 2008
;; Based mode on wpld-mode tutorial and simple-mode on emacs wiki.
;; Ideas from mupad.el for font-lock styles.

;;; Code:

(require 'font-lock); this goes in the define-derived-mode part.


(defvar remind-conf-mode-version ".01")

(defvar remind-conf-mode-hook nil
  "Hook to run in `remind-conf-mode'.")


;; keymap

(defvar remind-conf-mode-map
  (let ((remind-conf-mode-map (make-sparse-keymap)))
        remind-conf-mode-map)
  "Keymap for `remind-conf-mode'.")

(define-key remind-conf-mode-map "\C-cr" 'rem-skel)

;; syntax-table

(defvar remind-conf-syntax-table
  (let ((remind-conf-syntax-table (make-syntax-table text-mode-syntax-table)))
    ;Comments are the same as Lisp
    (modify-syntax-entry ?\; ". 1b" remind-conf-syntax-table)
    (modify-syntax-entry ?\n "> b" remind-conf-syntax-table)
    ;Names with - are still one word
    (modify-syntax-entry ?- "w" remind-conf-syntax-table)
    ; we do use various sorts of braces stolen from mupad-mode: anything better?
    (modify-syntax-entry ?\( "()"  remind-conf-syntax-table)
    (modify-syntax-entry ?\) ")(" remind-conf-syntax-table)
    (modify-syntax-entry ?\[ "(]"  remind-conf-syntax-table)
    (modify-syntax-entry ?\] ")[" remind-conf-syntax-table)
    (modify-syntax-entry ?\{ "(}"  remind-conf-syntax-table)
    (modify-syntax-entry ?\} "){"  remind-conf-syntax-table)
    remind-conf-syntax-table)
  "Syntax table for `remind-conf-mode'.")

;; faces
;;example of setting up special faces for a mode.

(defvar remind-conf-command-face 'remind-conf-command-face
  "Remind commands.")
(defface remind-conf-command-face
  '((t :foreground "SeaGreen4" :bold t))
  "Font Lock mode face used to highlight commands."
  :group 'remind-conf-highlighting-faces)

(defvar remind-conf-keyword-face 'remind-conf-keyword-face
      "Remind keywords.")
(defface remind-conf-keyword-face
  '((t :foreground "blue violet"))
  "Font Lock mode face used to highlight keywords."
  :group 'remind-conf-highlighting-faces)

(defvar remind-conf-substitutes-face 'remind-conf-substitutes-face
      "Remind substitutes.")
(defface remind-conf-substitutes-face
  '((t :foreground "blue2"))
  "Font Lock mode face used to highlight substitutes."
  :group 'remind-conf-highlighting-faces)

(defvar remind-conf-endline-face 'remind-conf-endline-face
  "Remind endline.")
(defface remind-conf-endline-face
  '((t :foreground "goldenrod2" :bold t))
  "Font Lock mode face used to highlight commands."
  :group 'remind-conf-highlighting-faces)

(defvar remind-conf-variable-face 'remind-conf-variable-face
  "Remind variable.")
(defface remind-conf-variable-face
  '((t :foreground "DeepPink2" :bold t))
  "Font Lock mode face used to highlight commands."
  :group 'remind-conf-highlighting-faces)

(defvar remind-conf-delta-face 'remind-conf-delta-face
  "Remind deltas.")
(defface remind-conf-delta-face
  '((t :foreground "sandy brown" :bold t))
  "Font Lock mode face used to highlight deltas."
  :group 'remind-conf-highlighting-faces)

(defvar remind-comment-face 'remind-comment-face
  "Remind comments.")
(defface remind-comment-face
  '((t :foreground "brown"))
  "Font-lock face for highlighting comments."
  :group 'remind-conf-highlighting-faces)
(defvar remind-string-face 'remind-string-face
  "Remind strings.")
(defface remind-string-face
  '((t :foreground "orange"))
  "Font-lock face for highlighting strings."
  :group 'remind-conf-highlighting-faces)
;; keywords

(defconst remind-conf-font-lock-keywords-1
  (list
   '("^\;.*$" . remind-comment-face)
   '("^\#.*$" . remind-comment-face)
   '("\\<\\(CAL\\|FSET\\|MS[FG]\\|OMIT\\|PS\\(?:FILE\\)?\\|R\\(?:EM\\|UN\\)\\|S\\(?:ATISFY\\|ET\\|HADE\\|PECIAL\\)\\)\\>" . remind-conf-keyword-face)
   '("%\"" . font-lock-warning-face)
   '("\\<%[abcefghijkluv]" . remind-conf-substitutes-face)
   '("\"[^\"]*\"" . remind-string-face))
  "Minimal font-locking for `remind-conf-mode'.")

(defconst remind-conf-font-lock-keywords-2
  (append remind-conf-font-lock-keywords-1
   (list
    '("\\<\\(A\\(?:FTER\\|T\\)\\|B\\(?:ANNER\\|EFORE\\)\\|DURATION\\|INCLUDE\\|ONCE\\|P\\(?:RIORITY\\|USH_OMIT_CONTEXT\\)\\|S\\(?:C\\(?:ANFROM\\|HED\\)\\|KIP\\)\\|TAG\\|UN\\(?:SET\\|TIL\\)\\|WARN\\)\\>" . remind-conf-command-face)
    '("%$" . remind-conf-endline-face)
    '("\s[+-][+-]?[1-9][0-9]*\s" . remind-conf-delta-face)))
  "Additional commands to highlight in `remind-conf-mode'.")

(defconst remind-conf-font-lock-keywords-3
(append remind-conf-font-lock-keywords-2
(list
'("\\<\\(INT\\|STRING\\|TIME\\|DATE\\)\\>" . remind-conf-type-face )
'(" \$[A-Za-z]+" . remind-conf-variable-face)
))
"The ultimate in highlighting experiences for `remind-conf-mode'.")


(defvar remind-conf-font-lock-keywords remind-conf-font-lock-keywords-3
 "Default highlighting for `remind-conf-mode'.")


;; thank goodness we don't have to worry about indentation.

;; however I can do a skeleton for convenience of new users.

(define-skeleton rem-skel
  "Skeleton to insert a rem line in a remind configuration file."
  nil
  "REM "(skeleton-read "Date? " )
  ("Optional: How many days ahead? " " +" str )
  ("Optional: At what time? " " AT " str)
  ("Optional: How many minuts ahead? " " +" str )
  ("Optional: A what priority? " " PRIORITY " str )
  " MSG %\"" (skeleton-read " message? " )"%b%\"%" \n
  )

(setq skeleton-end-hook nil)


;; finally the derived mode. If this doesn't work use the normal way.

;;;###autoload
(define-derived-mode remind-conf-mode text-mode "remind-conf-mode"
  "Major mode for editing remind calendar configuration files."
  :syntax-table remind-conf-syntax-table
  (set (make-local-variable 'font-lock-defaults) '(remind-conf-font-lock-keywords))
  (set (make-local-variable 'font-lock-keywords-case-fold-search) 't)
  (set (make-local-variable 'comment-start) "#;")
  (set (make-local-variable 'comment-end) "\n")
  (use-local-map remind-conf-mode-map))

(provide 'remind-conf-mode)
;;; remind-conf-mode.el ends here



More information about the Remind-fans mailing list