summaryrefslogtreecommitdiff
path: root/llama.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-01-17 17:28:23 +0100
committerJonas Bernoulli <jonas@bernoul.li>2025-01-17 17:28:23 +0100
commit3d9b59e1125e85137346b4c866e8a0a58464acb8 (patch)
tree7071218354691c018c937ba43e76c53468a1ff17 /llama.el
parente6938b60e117057f5c1f28546bd823903aa1b2eb (diff)
Hide incompatible code from older compilers
Diffstat (limited to 'llama.el')
-rw-r--r--llama.el131
1 files changed, 67 insertions, 64 deletions
diff --git a/llama.el b/llama.el
index 342aca9..b242aa7 100644
--- a/llama.el
+++ b/llama.el
@@ -386,72 +386,75 @@ expansion, and the looks of this face should hint at that.")
face))
(defun llama--match-and-fontify (re end)
- (and (re-search-forward re end t)
- (prog1 t
- (save-excursion
- (goto-char (match-beginning 0))
- (when-let (((save-match-data (not (nth 8 (syntax-ppss)))))
- ((fboundp 'read-positioning-symbols))
- (expr (ignore-errors
- (read-positioning-symbols (current-buffer)))))
- (put-text-property (match-beginning 0) (point)
- 'font-lock-multiline t)
- (llama--fontify (cdr expr) nil nil t))))))
+ (static-if (fboundp 'bare-symbol)
+ (and (re-search-forward re end t)
+ (prog1 t
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (when-let (((save-match-data (not (nth 8 (syntax-ppss)))))
+ (expr (ignore-errors
+ (read-positioning-symbols (current-buffer)))))
+ (put-text-property (match-beginning 0) (point)
+ 'font-lock-multiline t)
+ (llama--fontify (cdr expr) nil nil t)))))
+ (list re end))) ; Silence compiler.
(defun llama--fontify (expr &optional fnpos backquoted top)
- (cond
- ((null expr) expr)
- ((eq (car-safe expr) 'quote))
- ((eq (ignore-errors (bare-symbol (car-safe expr))) 'quote))
- ((and (memq (ignore-errors (bare-symbol (car-safe expr)))
- (list (intern "") 'llama))
- (not top)))
- ((and backquoted (symbol-with-pos-p expr)))
- ((and backquoted
- (memq (car-safe expr)
- (list backquote-unquote-symbol
- backquote-splice-symbol)))
- (llama--fontify expr))
- ((symbol-with-pos-p expr)
- (save-match-data
- (when-let*
- ((name (symbol-name (bare-symbol expr)))
- (face (cond
- ((and (string-match
- "\\_<\\(?:\\(_\\)?%\\([1-9]\\)?\\)\\_>" name)
- (or (not fnpos) (match-end 2)))
- 'llama-mandatory-argument)
- ((and (string-match
- "\\_<\\(?:\\(_\\)?&\\([1-9*]\\)?\\)\\_>" name)
- (or (not fnpos) (match-end 2)))
- 'llama-optional-argument))))
- (when (match-end 1)
- (setq face (list 'llama-deleted-argument face)))
- (let ((beg (symbol-with-pos-pos expr)))
- (put-text-property
- beg (save-excursion (goto-char beg) (forward-symbol 1))
- 'face face)))))
- ((or (listp expr)
- (vectorp expr))
- (let* ((vectorp (vectorp expr))
- (expr (if vectorp (append expr ()) expr))
- (fnpos (and (not vectorp)
- (not backquoted)
- (ignore-errors (length expr)))))
- (catch t
- (while t
- (cond ((eq (car expr) backquote-backquote-symbol)
- (setq expr (cdr expr))
- (llama--fontify (car expr) t t))
- ((llama--fontify (car expr) fnpos backquoted)))
- (setq fnpos nil)
- (setq expr (cdr expr))
- (unless (and expr
- (listp expr)
- (not (eq (car expr) backquote-unquote-symbol)))
- (throw t nil))))
- (when expr
- (llama--fontify expr fnpos))))))
+ (static-if (fboundp 'bare-symbol)
+ (cond
+ ((null expr) expr)
+ ((eq (car-safe expr) 'quote))
+ ((eq (ignore-errors (bare-symbol (car-safe expr))) 'quote))
+ ((and (memq (ignore-errors (bare-symbol (car-safe expr)))
+ (list (intern "") 'llama))
+ (not top)))
+ ((and backquoted (symbol-with-pos-p expr)))
+ ((and backquoted
+ (memq (car-safe expr)
+ (list backquote-unquote-symbol
+ backquote-splice-symbol)))
+ (llama--fontify expr))
+ ((symbol-with-pos-p expr)
+ (save-match-data
+ (when-let*
+ ((name (symbol-name (bare-symbol expr)))
+ (face (cond
+ ((and (string-match
+ "\\_<\\(?:\\(_\\)?%\\([1-9]\\)?\\)\\_>" name)
+ (or (not fnpos) (match-end 2)))
+ 'llama-mandatory-argument)
+ ((and (string-match
+ "\\_<\\(?:\\(_\\)?&\\([1-9*]\\)?\\)\\_>" name)
+ (or (not fnpos) (match-end 2)))
+ 'llama-optional-argument))))
+ (when (match-end 1)
+ (setq face (list 'llama-deleted-argument face)))
+ (let ((beg (symbol-with-pos-pos expr)))
+ (put-text-property
+ beg (save-excursion (goto-char beg) (forward-symbol 1))
+ 'face face)))))
+ ((or (listp expr)
+ (vectorp expr))
+ (let* ((vectorp (vectorp expr))
+ (expr (if vectorp (append expr ()) expr))
+ (fnpos (and (not vectorp)
+ (not backquoted)
+ (ignore-errors (length expr)))))
+ (catch t
+ (while t
+ (cond ((eq (car expr) backquote-backquote-symbol)
+ (setq expr (cdr expr))
+ (llama--fontify (car expr) t t))
+ ((llama--fontify (car expr) fnpos backquoted)))
+ (setq fnpos nil)
+ (setq expr (cdr expr))
+ (unless (and expr
+ (listp expr)
+ (not (eq (car expr) backquote-unquote-symbol)))
+ (throw t nil))))
+ (when expr
+ (llama--fontify expr fnpos))))))
+ (list expr fnpos backquoted top)) ; Silence compiler.
(defvar llama-fontify-mode-lighter nil)