aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark E. Shoulson <mark@kli.org>2019-12-18 07:58:42 -0500
committerMark E. Shoulson <mark@kli.org>2020-05-11 10:58:46 -0400
commit4256bf4962faa614169fdd88a92e935cb4448d0f (patch)
treeef053a236fa94511edd1941dc73e5a8c02ced263
parentFixed some .py utils to use python3; added a few chars. (diff)
downloaddotXCompose-4256bf4962faa614169fdd88a92e935cb4448d0f.tar.gz
dotXCompose-4256bf4962faa614169fdd88a92e935cb4448d0f.tar.bz2
dotXCompose-4256bf4962faa614169fdd88a92e935cb4448d0f.zip
Start playing with an xcompose-mode.el
-rw-r--r--xcompose-mode.el90
1 files changed, 90 insertions, 0 deletions
diff --git a/xcompose-mode.el b/xcompose-mode.el
new file mode 100644
index 0000000..769b68e
--- /dev/null
+++ b/xcompose-mode.el
@@ -0,0 +1,90 @@
+;; Blah blah add headers here.
+;; Playing with the notion of a major mode for .XCompose files.
+;; Maybe eventually smart enough to keep columns lined up.
+;; For now, settling for pretty colors.
+
+(defface xcompose-angle-face
+ '((t (:inherit font-lock-keyword-face)))
+ "Face for the <>s"
+ :group 'xcompose-mode)
+
+(defface xcompose-keys-face
+ '((t (:inherit font-lock-constant-face)))
+ "Face for the key names"
+ :group 'xcompose-mode)
+
+(defface xcompose-string-face
+ '((t (:inherit font-lock-string-face
+ :height 1.2
+ :box "black")))
+ "Face for the strings. Not straight font-lock-string-face in case I want
+to make it big or something."
+ :group 'xcompose-mode)
+(defface xcompose-quotemark-face
+ '((t (:inherit font-lock-string-face
+ :foreground "dark orchid")))
+ "Face for quotes around strings"
+ :group 'xcompose-mode)
+
+(defface xcompose-num-face
+ '((t (:inherit font-lock-preprocessor-face :weight bold)))
+ "Face for the hex numbers"
+ :group 'xcompose-mode)
+
+(defface xcompose-U-face
+ '((t (:inherit font-lock-preprocessor-face)))
+ "Face for the U before the hex numbers"
+ :group 'xcompose-mode)
+
+(defface xcompose-colon-face
+ '((t (:inherit bold)))
+ "Face for the \":\"."
+ :group 'xcompose-mode)
+
+
+(defvar xcompose-mode-syntax-table
+ (let ((st (make-syntax-table text-mode-syntax-table)))
+ (modify-syntax-entry ?< "(> " st)
+ (modify-syntax-entry ?> ")< " st)
+ (modify-syntax-entry ?# "< " st)
+ (modify-syntax-entry ?_ "_ " st)
+ (modify-syntax-entry ?\n "> " st)
+ st)
+ "Syntax table for xcompose-mode")
+
+(defvar xcompose-mode-map
+ (let ((map (make-sparse-keymap)))
+ ;; ADD BINDINGS
+ map)
+ "Keymap for xcompose-mode")
+
+(defvar xcompose-font-lock-keywords
+ '(
+ ("[<>]" . 'xcompose-angle-face)
+ ("<\\([a-zA-Z0-9_]*\\)>" . (1 'xcompose-keys-face))
+ ;; ("\"[^\"]*\"" . 'xcompose-string-face)
+ ("\"\\([^\"]*\\)\"" . (1 'xcompose-string-face))
+ ("\"" . 'xcompose-quotemark-face)
+ ("\\(U\\)\\([0-9A-Fa-f]*\\)" .
+ ((1 'xcompose-U-face) (2 'xcompose-num-face)))
+ (":" . 'xcompose-colon-face)
+ (" #.*" . 'glyphless-char)
+ ))
+
+(define-derived-mode xcompose-mode text-mode "XCompose"
+ "Major mode for .XCompose files"
+ (font-lock-add-keywords nil xcompose-font-lock-keywords)
+ (setq-local comment-start "#")
+ (setq-local comment-end "\n")
+ (setq-local comment-continue " *")
+ (setq-local comment-start-skip "/[*/]+[ \t]*")
+ (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
+ ;; Bizarrely enough, this actually works.
+ ;; But I think I might not want to use it.
+ ;; (setq-local font-lock-comment-face
+ ;; '(:height 0.95 :inherit font-lock-comment-face))
+ ;; But lighten the color a little, since there's so much comment text...
+ (setq-local font-lock-comment-face
+ '(:inherit font-lock-comment-face :foreground "light coral"))
+ )
+