139 lines
4.4 KiB
EmacsLisp
139 lines
4.4 KiB
EmacsLisp
(defgroup agw nil
|
|
"Alison G. Watson's customizations."
|
|
:prefix "agw-"
|
|
:group 'convenience)
|
|
|
|
(defvar agw-mode-map (make-sparse-keymap)
|
|
"Global keymap for `agw-mode'.")
|
|
|
|
(defvar-local agw-no-fixes nil
|
|
"Fixes files before save if `t' in this buffer.")
|
|
|
|
(define-minor-mode agw-key-map-mode
|
|
"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))
|
|
|
|
(defun agw-prog-mode ()
|
|
"Sets up `prog-mode' and `text-mode'."
|
|
(setq-local tab-always-indent nil
|
|
tab-width 3
|
|
standard-indent 3
|
|
indent-tabs-mode t))
|
|
|
|
(defun agw-fp-mode ()
|
|
"Sets up lisp and other functional language major modes."
|
|
(setq-local indent-tabs-mode nil
|
|
standard-indent 2
|
|
tab-width 2))
|
|
|
|
(defun agw-org-mode ()
|
|
"Sets up `org-mode'."
|
|
(setq-local indent-tabs-mode nil
|
|
standard-indent 2
|
|
tab-width 2))
|
|
|
|
(defun agw-before-save ()
|
|
"Hook to be run before saving a file."
|
|
(unless agw-no-fixes
|
|
(copyright-update)
|
|
(delete-trailing-whitespace)))
|
|
|
|
(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))
|
|
|
|
(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) "Λ"))))
|
|
|
|
(defun agw-after-local-vars ()
|
|
(unless indent-tabs-mode (smart-tabs-mode 0)))
|
|
|
|
;; 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"
|
|
"script" "logon" "logoff" "pict" "info" "text"))
|
|
( keyword-regexp (regexp-opt keywords 'words))
|
|
(function-regexp (regexp-opt functions 'words)))
|
|
`(( ,keyword-regexp . font-lock-keyword-face)
|
|
(,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))
|
|
|
|
(define-derived-mode agw-lithdlg-mode prog-mode "lithdlg"
|
|
"Major mode for Lithium dialogues."
|
|
(setq font-lock-defaults '(agw-lithdlg-highlights))
|
|
(set-syntax-table agw-lithdlg-syntax))
|
|
|
|
(provide 'agw-lithdlg-mode)
|
|
|
|
;; 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)
|
|
|
|
;; Lithium text definition mode
|
|
(setq agw-lithtxt-highlights
|
|
'(("^\\(\\(==\\|%%\\|@@\\|\\+\\+\\|!![a-z]+\\) \\|@@$\\)" .
|
|
font-lock-keyword-face)
|
|
("^##.*$" . 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)))
|
|
|
|
(fset 'agw-create-mthd-link
|
|
(kmacro-lambda-form [?i ?\[ escape ?l ?v ?f ?\( ?h ?y ?f ?\( ?i
|
|
?\] ?\{ ?: ?# ?m ?t ?h ?d ?- escape ?p ?l
|
|
?i ?\} escape ?v ?F ?- ?g ?u]
|
|
0
|
|
"%d"))
|
|
|
|
(fset 'agw-create-memb-link
|
|
(kmacro-lambda-form [?v ?$ ?h ?y ?i ?\[ escape ?A ?\] ?\{ ?\}
|
|
escape ?i ?: ?# ?m ?e ?m ?b ?- escape ?p ?v
|
|
?F ?- ?g ?u]
|
|
0
|
|
"%d"))
|
|
|
|
(fset 'agw-create-back-link
|
|
(kmacro-lambda-form [?v ?f ?\] ?h ?y ?$ ?p ?v ?F ?- ?g ?u] 0 "%d"))
|
|
|
|
(provide 'agw-lithtxt-mode)
|
|
|
|
;; EOF
|