contrib/gadict.el
changeset 380 f0e2c538bf85
parent 379 c336b3ebd9df
child 381 1729e4655e4d
equal deleted inserted replaced
379:c336b3ebd9df 380:f0e2c538bf85
    27      ("^\\(?:topic\\|ant\\|syn\\): " . font-lock-doc-face)
    27      ("^\\(?:topic\\|ant\\|syn\\): " . font-lock-doc-face)
    28      ("^ +\\(?:v1\\|v2\\|v3\\|s\\|pl\\|male\\|female\\)$" . font-lock-doc-face)
    28      ("^ +\\(?:v1\\|v2\\|v3\\|s\\|pl\\|male\\|female\\)$" . font-lock-doc-face)
    29      ("^\\(?:n\\|v\\|phr\\.v\\|adj\\|adv\\|pron\\|prep\\|num\\|conj\\|int\\)$" . font-lock-type-face) ))
    29      ("^\\(?:n\\|v\\|phr\\.v\\|adj\\|adv\\|pron\\|prep\\|num\\|conj\\|int\\)$" . font-lock-type-face) ))
    30 
    30 
    31 (defun gadict-setup-fontlock ()
    31 (defun gadict-setup-fontlock ()
       
    32   "Setup gadict fontlock."
    32   (setq font-lock-defaults
    33   (setq font-lock-defaults
    33         '(gadict-font-lock-keywords
    34         '(gadict-font-lock-keywords
    34           t nil nil nil
    35           t nil nil nil
    35           (font-lock-multiline . t) ))
    36           (font-lock-multiline . t) ))
    36   (add-hook 'font-lock-extend-region-functions 'gadict-font-lock-extend-region t) )
    37   (add-hook 'font-lock-extend-region-functions 'gadict-font-lock-extend-region t) )
    37 
    38 
    38 (defun gadict-setup-comment ()
    39 (defun gadict-setup-comment ()
       
    40   "Setup gadict comment commands."
    39   (set (make-local-variable 'comment-start)  "#")
    41   (set (make-local-variable 'comment-start)  "#")
    40   (set (make-local-variable 'comment-continue)  nil)
    42   (set (make-local-variable 'comment-continue)  nil)
    41   (set (make-local-variable 'comment-end)  "")
    43   (set (make-local-variable 'comment-end)  "")
    42   (set (make-local-variable 'comment-end-skip)  nil)
    44   (set (make-local-variable 'comment-end-skip)  nil)
    43   (set (make-local-variable 'comment-multi-line)  nil)
    45   (set (make-local-variable 'comment-multi-line)  nil)
    44   (set (make-local-variable 'comment-use-syntax)  nil) )
    46   (set (make-local-variable 'comment-use-syntax)  nil) )
    45 
    47 
    46 (defun gadict-setup-paragraph ()
    48 (defun gadict-setup-paragraph ()
       
    49   "Setup gadict paragraph definition."
    47   (set (make-local-variable 'paragraph-separate)  "__$")
    50   (set (make-local-variable 'paragraph-separate)  "__$")
    48   (set (make-local-variable 'paragraph-start)  "__$") )
    51   (set (make-local-variable 'paragraph-start)  "__$") )
    49 
    52 
    50 (defun gadict-setup-page ()
    53 (defun gadict-setup-page ()
       
    54   "Setup gadict page definition."
    51   (set (make-local-variable 'page-delimiter)  "__$") )
    55   (set (make-local-variable 'page-delimiter)  "__$") )
    52 
    56 
    53 (defun gadict-setup-syntax ()
    57 (defun gadict-setup-syntax ()
       
    58   "Setup gadict characters syntax."
    54   (modify-syntax-entry ?' "w"))
    59   (modify-syntax-entry ?' "w"))
    55 
    60 
    56 (defun gadict-mark-article ()
    61 (defun gadict-mark-article ()
       
    62   "Mark current article."
    57   (end-of-line)
    63   (end-of-line)
    58   (re-search-backward "^__$")
    64   (re-search-backward "^__$")
    59   (set-mark (point))
    65   (set-mark (point))
    60   (forward-line)
    66   (forward-line)
    61   (if (re-search-forward "^__$" nil t)
    67   (if (re-search-forward "^__$" nil t)
    93   "Translation markers as string separated by comma. Define own
    99   "Translation markers as string separated by comma. Define own
    94   values in .dir-local.el or as -*- gadict-tr: \"...\" -*- file prelude")
   100   values in .dir-local.el or as -*- gadict-tr: \"...\" -*- file prelude")
    95 (put 'gadict-tr 'safe-local-variable 'string-or-null-p)
   101 (put 'gadict-tr 'safe-local-variable 'string-or-null-p)
    96 
   102 
    97 (defun gadict-new-entry ()
   103 (defun gadict-new-entry ()
    98   "Insert new entry template."
   104   "Insert new article template."
    99   (interactive)
   105   (interactive)
   100   (if (re-search-forward "^__" nil t)
   106   (if (re-search-forward "^__" nil t)
   101       (beginning-of-line)
   107       (beginning-of-line)
   102     (goto-char (point-max)))
   108     (goto-char (point-max)))
   103   (while (eq (char-before) ?\n)
   109   (while (eq (char-before) ?\n)
   114     (insert-char ?\n)
   120     (insert-char ?\n)
   115     (re-search-backward "^$"))
   121     (re-search-backward "^$"))
   116   (backward-char))
   122   (backward-char))
   117 
   123 
   118 (defun gadict-setup-keymap ()
   124 (defun gadict-setup-keymap ()
       
   125   "Setup gadict keymap."
   119   (define-key gadict-mode-map [C-return] 'gadict-new-entry))
   126   (define-key gadict-mode-map [C-return] 'gadict-new-entry))
   120 
   127 
   121 ;;;###autoload
   128 ;;;###autoload
   122 (define-derived-mode gadict-mode fundamental-mode "gadict"
   129 (define-derived-mode gadict-mode fundamental-mode "gadict"
   123   "Derived mode for editing gadict dictionary source files."
   130   "Derived mode for editing gadict dictionary source files."