summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-06-28 04:21:38 +0300
committerThanos Apollo <[email protected]>2024-06-28 04:21:38 +0300
commit0749549451eddf3ccc9a758d9a55a9c67a5d5ea5 (patch)
tree4659ab4c3b2272bacf7feb602188101164ca933e /gnosis.el
parent11cc9e9efe808a73e740d96235f875721f634429 (diff)
[Feature] Add gnosis-apply-syntax-overlay
Adds org-mode like syntax highlighting
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index 89150fc..e6ab7fa 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -349,6 +349,23 @@ This will not be applied to sentences that start with double space."
(gnosis-center-current-line)
(forward-line 1))))
+(defun gnosis-apply-syntax-overlay ()
+ "Apply custom font overlays for syntax highlighting, and remove delimiters."
+ (let ((syntax-highlights '(("\\*\\([^*[:space:]][^*]*[^*[:space:]]\\)\\*" . bold)
+ ("/\\([^/[:space:]][^/]*[^/[:space:]]\\)/" . italic)
+ ("=\\([^=[:space:]][^=]*[^=[:space:]]\\)=" . font-lock-constant-face)
+ ("~\\([^~[:space:]][^~]*[^~[:space:]]\\)~" . font-lock-keyword-face))))
+ (save-excursion
+ (cl-loop for (regex . face) in syntax-highlights
+ do (progn
+ (goto-char (point-min))
+ (while (re-search-forward regex nil t)
+ (let ((start (match-beginning 1))
+ (end (match-end 1)))
+ (overlay-put (make-overlay start end) 'face face)
+ (delete-region end (match-end 0))
+ (delete-region (match-beginning 0) start))))))))
+
(defun gnosis-display-mcq-options (id)
"Display answer options for mcq note ID."