From bd1844395752dce33587dfb6d9b76586217e3035 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 17 Jul 2024 08:23:37 +0300 Subject: display: Add gnosis-apply-highlighting-p * New variable: When non-nil applies syntax gnosis syntax highlighting. --- gnosis.el | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index e444dfb..cfd2f2d 100644 --- a/gnosis.el +++ b/gnosis.el @@ -191,6 +191,9 @@ Seperate the question/stem from options." "Non-nil means center content." :type 'boolean :group 'gosis) + +(defcustom gnosis-apply-highlighting-p t + "Non-nil means apply syntax highlighting." :type 'boolean :group 'gosis) @@ -400,16 +403,17 @@ This will not be applied to sentences that start with double space." ("=\\([^=[:space:]][^=\n]*[^=[:space:]]\\)=" . font-lock-constant-face) ("~\\([^~[:space:]][^~\n]*[^~[:space:]]\\)~" . font-lock-keyword-face) ("_\\([^_[:space:]][^_\n]*[^_[:space:]]\\)_" . underline)))) - (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)))))))) + (when gnosis-apply-highlighting-p + (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-question (id &optional fill-paragraph-p) "Display main row for note ID. -- cgit v1.2.3