2017-10-17 10:34:56 +03:00
|
|
|
;;; idec-mode.el --- This file part of GNU Emacs client for IDEC network
|
|
|
|
|
|
|
|
;; Copyright (c) 2017 Denis Zheleztsov
|
|
|
|
|
|
|
|
;; Author: Denis Zheleztsov <difrex.punk@gmail.com>
|
|
|
|
;; Keywords: lisp,network,IDEC
|
|
|
|
;; Version: 0.1
|
|
|
|
|
|
|
|
;; 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; In active developent.
|
|
|
|
;; Fetched node must be support modern IDEC extensions like /list.txt, /x/c, etc.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;; MODE
|
|
|
|
;; ;;;;
|
|
|
|
|
|
|
|
(defun idec-close-message-buffer ()
|
|
|
|
"Close buffer with message."
|
|
|
|
(kill-this-buffer))
|
|
|
|
|
|
|
|
(defvar idec-mode-hook nil)
|
|
|
|
|
|
|
|
(defvar idec-mode-map
|
2017-10-20 13:52:38 +03:00
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(define-key map ["C-c C-c"] 'kill-this-buffer)
|
|
|
|
(define-key map ["C-c C-n"] 'idec-next-message)
|
|
|
|
(define-key map ["C-c C-b"] 'idec-previous-message)
|
|
|
|
(define-key map ["C-c C-e"] 'idec-new-message)
|
2017-10-17 10:34:56 +03:00
|
|
|
map)
|
|
|
|
"Keymapping for IDEC mode.")
|
|
|
|
|
2017-10-20 13:52:38 +03:00
|
|
|
(defvar idec-mode-syntax-table
|
|
|
|
(let ((st (make-syntax-table)))
|
|
|
|
(modify-syntax-entry ?# "<" st)
|
|
|
|
(modify-syntax-entry ?\n ">" st)
|
|
|
|
st))
|
|
|
|
|
2017-10-17 10:34:56 +03:00
|
|
|
(defconst idec-font-lock-keywords-1
|
|
|
|
(list
|
|
|
|
'("\\(ID:.*\\)" . font-lock-function-name-face)
|
|
|
|
'("\\<\\(\\(?:Echo\\|From\\|Subj\\|T\\(?:ime\\|o\\)\\):\\)\\>" . font-lock-function-name-face))
|
|
|
|
"Minimal highlighting expressions for IDEC mode.")
|
|
|
|
|
|
|
|
(defconst idec-font-lock-keywords-2
|
|
|
|
(append idec-font-lock-keywords-1 (list
|
|
|
|
'("\\<\\(>>?.*\\)\s\\>" . font-lock-comment-face)))
|
|
|
|
"Quotes highligting for IDEC mode.")
|
|
|
|
|
2017-10-23 10:44:45 +03:00
|
|
|
(defvar idec-font-lock-keywords idec-font-lock-keywords-1
|
|
|
|
;; '(("ID" (1 font-lock-function-name-face)))
|
2017-10-17 10:34:56 +03:00
|
|
|
"Default highlighting expressions for IDEC mode.")
|
|
|
|
|
|
|
|
;; Mode function
|
2017-10-23 10:44:45 +03:00
|
|
|
(define-generic-mode
|
|
|
|
'idec
|
|
|
|
'("//" ">" "ЗЫ" "# ")
|
|
|
|
'("ii://" "ID" "$subj" "сабж" "субж"
|
|
|
|
"Subject" "From" "To" "Echo" "At")
|
|
|
|
'(("=" . 'font-lock-operator)
|
|
|
|
(";" . 'font-lock-builtin))
|
|
|
|
'("\\.idec$")
|
|
|
|
nil)
|
|
|
|
|
|
|
|
(define-derived-mode org-idec text-mode "IDEC"
|
2017-10-17 10:34:56 +03:00
|
|
|
"Major mode for view and editing IDEC messages."
|
2017-10-20 13:52:38 +03:00
|
|
|
:syntax-table idec-mode-syntax-table
|
2017-10-23 10:44:45 +03:00
|
|
|
(setq-local comment-start "/{2} ")
|
2017-10-20 13:52:38 +03:00
|
|
|
(setq-local font-lock-defaults
|
|
|
|
'(idec-font-lock-keywords))
|
2017-10-17 10:34:56 +03:00
|
|
|
(use-local-map idec-mode-map)
|
2017-10-20 13:52:38 +03:00
|
|
|
(setq-local indent-line-function 'org-indent-line)
|
2017-10-17 10:34:56 +03:00
|
|
|
(setq imenu-generic-expression "*IDEC")
|
2017-10-20 13:52:38 +03:00
|
|
|
(setq mode-name "[IDEC]")
|
2017-10-17 10:34:56 +03:00
|
|
|
(run-hooks 'idec-mode-hook))
|
|
|
|
|
2017-10-23 10:44:45 +03:00
|
|
|
(defun idec-mode ()
|
|
|
|
"Major mode for view and editing IDEC messages."
|
|
|
|
(interactive)
|
|
|
|
(kill-all-local-variables)
|
|
|
|
;; Mode definition
|
|
|
|
(set-syntax-table idec-mode-syntax-table)
|
|
|
|
(use-local-map idec-mode-map)
|
|
|
|
;; (font-lock-add-keywords 'idec-mode '(idec-font-lock-keywords))
|
|
|
|
;; (set (make-local-variable 'font-lock-defaults) '(idec-font-lock-keywords))
|
|
|
|
(setq major-mode 'idec-mode)
|
|
|
|
(setq mode-name "[IDEC]")
|
|
|
|
(setq imenu-generic-expression "*IDEC")
|
|
|
|
(run-hooks 'idec-mode-hook))
|
2017-10-20 13:52:38 +03:00
|
|
|
|
2017-10-17 10:34:56 +03:00
|
|
|
(provide 'idec-mode)
|
|
|
|
|
|
|
|
;;; idec-mode.el ends here
|