obsolete/dict-c5-mode.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Tue, 20 Dec 2011 23:28:29 +0200
changeset 327 21124e46bf6e
parent 326 7b4a2a55729a
child 328 80146b5ba6e6
permissions -rw-r--r--
Return non-nil if region was adjusted.

;;; dict-mode.el --- major mode for dict dictionary source files

;; Copyright (C) 2011 by Oleksandr Gavenko <gavenkoa@gmail.com>

;; You can do anything with this file without any warranty.

;; Author: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Created: 2011-09-04
;; Version: 0.1
;; Keywords: dict, dictionary

;;; Commentary:
;;
;; Very pure release.

;;; Code:

(setq dict-c5-mode-map (make-sparse-keymap))
;; (define-key dict-c5-mode-map (kbd "RET") 'my-xxx)

(defvar dict-c5-font-lock-keywords
;; (setq dict-c5-font-lock-keywords
      '(
        ("^\\(_\\{5,\\}\\)\n\n\\(\\w[^\n]*\\)$"
         (1 font-lock-function-name-face) (2 font-lock-keyword-face))
        ("\\[[^]]+]" . font-lock-type-face)
        ))

(defun dict-c5-font-lock-extend-region ()
  "Look for '_____' expression and extend `font-lock-beg' and `font-lock-end'."
  (let ((changed nil))
    (save-excursion
      ;; (message "%d, %d:%d" point font-lock-beg font-lock-end)
      (goto-char font-lock-beg)
      (beginning-of-line)
      (when (eq (char-after (point)) ?_)
        (forward-line 3)
        (setq font-lock-end (point))
        (setq changed t))
      (goto-char font-lock-beg)
      (forward-line -2)
      (when (eq (char-after (point)) ?_)
        (setq font-lock-beg (point))
        (setq changed t))
      )
    changed
    ))

;;;###autoload
(define-derived-mode dict-c5-mode fundamental-mode "Dict-c5"
  "Derived mode for editing C5 dictd source file."
  (add-to-list 'auto-mode-alist (cons "\\.dict-c5$" 'dict-c5-mode))
  (setq font-lock-defaults
        '(dict-c5-font-lock-keywords
          t nil nil nil
          (font-lock-multiline . t)
          ))
  (use-local-map dict-c5-mode-map)
  (modify-syntax-entry ?' ".")
  (modify-syntax-entry ?\" ".")
  (add-hook 'font-lock-extend-region-functions 'dict-c5-font-lock-extend-region t)
  )

;;; dict-mode.el ends here