Skip to content

Commit

Permalink
Fixes for COMPILE-RULES implementation and usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fiveisky committed Sep 25, 2023
1 parent 1d2139a commit b9b22fd
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions extensions/vi-mode/options.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
(:set-hook (new-value)
(setf (lem:variable-value 'lem/line-numbers:line-numbers :global) new-value)))

(defun compile-rules (value)
(defun compile-rules (value option-name)
(apply #'disjoin
(mapcar (lambda (rule)
(check-type rule string)
Expand All @@ -341,8 +341,8 @@
(progn
(unless (= (length rule) 1)
(error 'option-error
:format-control "Invalid rule in iskeyword: ~A"
:format-arguments (list rule)))
:format-control "Invalid rule in ~A: ~A"
:format-arguments (list option-name rule)))
(let ((rule-char (aref rule 0)))
(lambda (c)
(char= c rule-char))))))))
Expand All @@ -351,7 +351,7 @@
(defvar *default-iskeyword* '("@" "48-57" "_" "192-255"))

(defun compile-iskeyword (value)
(compile-rules value))
(compile-rules value "iskeyword"))

(define-option "iskeyword" ((cons *default-iskeyword*
(compile-iskeyword *default-iskeyword*))
Expand Down Expand Up @@ -381,19 +381,23 @@

(defvar *default-non-broad-word-char* (mapcar #'string '(#\Newline #\Space #\Tab)))

(define-option "non-broad-word-char" ((cons *default-non-broad-word-char*
(compile-rules *default-non-broad-word-char*))
:type list
:aliases ("nbwc")
:scope :buffer)
(defun compile-non-broad-word-char (value)
(compile-rules value "non-broad-word-char"))

(define-option "non-broad-word-char"
((cons *default-non-broad-word-char*
(compile-non-broad-word-char *default-non-broad-word-char*))
:type list
:aliases ("nbwc")
:scope :buffer)
(:documentation "Comma-separated string to specify the characters that should be recognized as non broad word characters. (buffer local)
Aliases: nbwc")
(:getter (option)
(car (option-raw-value option)))
(:setter (new-value option)
(setf (option-%value option)
(cons new-value
(compile-rules new-value))))
(compile-non-broad-word-char new-value))))
(:initializer (option)
(let ((syntax-table (lem:mode-syntax-table (lem:buffer-major-mode (lem:current-buffer)))))
(setf (option-value option)
Expand Down

0 comments on commit b9b22fd

Please sign in to comment.