2020-02-01 18:25:57 -08:00
|
|
|
(defgroup agw nil
|
|
|
|
"Alison G. Watson's customizations."
|
|
|
|
:prefix "agw-"
|
|
|
|
:group 'convenience)
|
|
|
|
|
|
|
|
(defvar agw-mode-map (make-sparse-keymap)
|
|
|
|
"Global keymap for `agw-mode'.")
|
|
|
|
|
2020-04-20 18:20:16 -07:00
|
|
|
(defvar-local agw-no-fixes nil
|
|
|
|
"Fixes files before save if `t' in this buffer.")
|
|
|
|
|
2020-02-15 18:54:40 -08:00
|
|
|
(define-minor-mode agw-key-map-mode
|
2020-02-01 18:25:57 -08:00
|
|
|
"Minor mode for key bindings."
|
|
|
|
:global t
|
|
|
|
:keymap agw-mode-map)
|
|
|
|
|
|
|
|
(defun agw-set-key (key def)
|
|
|
|
"Binds a key into `agw-mode-map'."
|
|
|
|
(define-key agw-mode-map (kbd (concat "C-<tab> " key)) def))
|
|
|
|
|
2020-02-01 23:08:21 -08:00
|
|
|
(defun agw-prog-mode ()
|
2020-03-20 20:24:06 -07:00
|
|
|
"Sets up `prog-mode' and `text-mode'."
|
2020-02-15 18:49:50 -08:00
|
|
|
(setq-local tab-always-indent nil
|
|
|
|
tab-width 3
|
|
|
|
standard-indent 3
|
2020-03-20 20:22:31 -07:00
|
|
|
indent-tabs-mode t))
|
2020-02-01 23:08:21 -08:00
|
|
|
|
2020-02-01 18:25:57 -08:00
|
|
|
(defun agw-fp-mode ()
|
|
|
|
"Sets up lisp and other functional language major modes."
|
2020-02-15 18:49:50 -08:00
|
|
|
(setq-local indent-tabs-mode nil
|
|
|
|
standard-indent 2
|
|
|
|
tab-width 2))
|
2020-02-01 18:25:57 -08:00
|
|
|
|
|
|
|
(defun agw-org-mode ()
|
|
|
|
"Sets up `org-mode'."
|
2020-02-15 18:49:50 -08:00
|
|
|
(setq-local indent-tabs-mode nil
|
|
|
|
standard-indent 2
|
|
|
|
tab-width 2))
|
2020-02-01 18:25:57 -08:00
|
|
|
|
2020-04-20 18:20:16 -07:00
|
|
|
(defun agw-before-save ()
|
|
|
|
"Hook to be run before saving a file."
|
|
|
|
(unless agw-no-fixes
|
|
|
|
(copyright-update)
|
|
|
|
(delete-trailing-whitespace)))
|
|
|
|
|
2020-02-01 18:25:57 -08:00
|
|
|
(defun agw-remove-elc ()
|
|
|
|
"Removes an elc file if it exists."
|
|
|
|
(let ((elc (concat buffer-file-name "c")))
|
|
|
|
(if (file-exists-p elc)
|
|
|
|
(delete-file elc))))
|
|
|
|
|
|
|
|
(defun agw-el-mode ()
|
|
|
|
"Sets up `emacs-lisp-mode'."
|
|
|
|
(add-hook 'after-save-hook #'agw-remove-elc nil t))
|
|
|
|
|
2020-02-15 18:55:14 -08:00
|
|
|
(defun agw-evil-visual-state-tag (&optional selection)
|
|
|
|
"Displays the mode for the visual state."
|
|
|
|
(let ((selection (or selection evil-visual-selection)))
|
|
|
|
(cond ((eq selection 'char) "v")
|
|
|
|
((eq selection 'line) "V")
|
|
|
|
((eq selection 'screen-line) "ʌ")
|
|
|
|
((eq selection 'block) "Λ"))))
|
|
|
|
|
2020-03-16 18:29:43 -07:00
|
|
|
(defun agw-after-local-vars ()
|
|
|
|
(unless indent-tabs-mode (smart-tabs-mode 0)))
|
|
|
|
|
2020-03-17 16:30:49 -07:00
|
|
|
;; Lithium dialogues mode
|
|
|
|
(setq agw-lithdlg-highlights
|
|
|
|
(let* (( keywords '("dialogue" "terminal" "program" "page" "failure"
|
|
|
|
"finished" "unfinished" "if" "else"))
|
|
|
|
(functions '("option" "page" "name" "icon" "remote"
|
|
|
|
"teleport_interlevel" "teleport_intralevel"
|
2020-04-20 18:19:02 -07:00
|
|
|
"script" "logon" "logoff" "pict" "info" "text"))
|
2020-03-17 16:30:49 -07:00
|
|
|
( keyword-regexp (regexp-opt keywords 'words))
|
|
|
|
(function-regexp (regexp-opt functions 'words)))
|
2020-04-20 18:19:02 -07:00
|
|
|
`(( ,keyword-regexp . font-lock-keyword-face)
|
2020-03-17 16:30:49 -07:00
|
|
|
(,function-regexp . font-lock-function-name-face))))
|
|
|
|
|
|
|
|
(setq agw-lithdlg-syntax
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
(modify-syntax-entry ?/ ". 14n" table)
|
|
|
|
(modify-syntax-entry ?* ". 23n" table)
|
|
|
|
table))
|
|
|
|
|
2020-03-20 20:22:50 -07:00
|
|
|
(define-derived-mode agw-lithdlg-mode prog-mode "lithdlg"
|
2020-03-17 16:30:49 -07:00
|
|
|
"Major mode for Lithium dialogues."
|
|
|
|
(setq font-lock-defaults '(agw-lithdlg-highlights))
|
|
|
|
(set-syntax-table agw-lithdlg-syntax))
|
|
|
|
|
|
|
|
(provide 'agw-lithdlg-mode)
|
|
|
|
|
2020-03-20 20:24:28 -07:00
|
|
|
;; Lithium sound definition mode
|
|
|
|
(setq agw-lithsnd-highlights '(("\\$[a-z]+\\|==" . font-lock-keyword-face)))
|
|
|
|
|
|
|
|
(setq agw-lithsnd-syntax
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
(modify-syntax-entry ?# "<" table)
|
|
|
|
(modify-syntax-entry ?\n ">" table)
|
|
|
|
table))
|
|
|
|
|
|
|
|
(define-derived-mode agw-lithsnd-mode prog-mode "lithsnd"
|
|
|
|
"Major mode for Lithium sound definitions."
|
|
|
|
(setq font-lock-defaults '(agw-lithsnd-highlights))
|
|
|
|
(set-syntax-table agw-lithsnd-syntax))
|
|
|
|
|
|
|
|
(provide 'agw-lithsnd-mode)
|
|
|
|
|
2020-03-20 20:56:42 -07:00
|
|
|
;; Lithium text definition mode
|
|
|
|
(setq agw-lithtxt-highlights
|
2020-04-20 18:19:02 -07:00
|
|
|
'(("^\\(\\(==\\|%%\\|@@\\|\\+\\+\\|!![a-z]+\\) \\|@@$\\)" .
|
|
|
|
font-lock-keyword-face)
|
2020-03-20 20:56:42 -07:00
|
|
|
("^##.*$" . font-lock-comment-face)
|
|
|
|
("\\\\#" . font-lock-constant-face)))
|
|
|
|
|
|
|
|
(define-derived-mode agw-lithtxt-mode prog-mode "lithtxt"
|
|
|
|
"Major mode for Lithium sound definitions."
|
|
|
|
(setq font-lock-defaults '(agw-lithtxt-highlights)))
|
|
|
|
|
|
|
|
(provide 'agw-lithtxt-mode)
|
|
|
|
|
2020-02-01 18:25:57 -08:00
|
|
|
;; EOF
|