Commit 2715e4c1 authored by João Távora's avatar João Távora

Rework jit-lock-antiblink-grace after Stefan's comments

* lisp/jit-lock.el (jit-lock--antiblink-l-b-p): Rename from
jit-lock--antiblink-l-l-b.
(jit-lock--antiblink-grace-timer): Add period to docstring.
(jit-lock--antiblink-post-command): Rework after Stefan's
comments.
parent bd13cae1
Pipeline #2682 passed with stage
in 60 minutes and 41 seconds
...@@ -168,9 +168,9 @@ If nil, contextual fontification is disabled.") ...@@ -168,9 +168,9 @@ If nil, contextual fontification is disabled.")
"List of buffers that are being fontified stealthily.") "List of buffers that are being fontified stealthily.")
(defvar jit-lock--antiblink-grace-timer nil (defvar jit-lock--antiblink-grace-timer nil
"Idle timer for fontifying unterminated string or comment, or nil") "Idle timer for fontifying unterminated string or comment, or nil.")
(defvar jit-lock--antiblink-l-l-b (make-marker) (defvar jit-lock--antiblink-l-b-p (make-marker)
"Last line beginning (l-l-b) position after last command (a marker).") "Last line beginning position (l-b-p) after last command (a marker).")
(defvar jit-lock--antiblink-i-s-o-c nil (defvar jit-lock--antiblink-i-s-o-c nil
"In string or comment (i-s-o-c) after last command (a boolean).") "In string or comment (i-s-o-c) after last command (a boolean).")
...@@ -691,22 +691,22 @@ will take place when text is fontified stealthily." ...@@ -691,22 +691,22 @@ will take place when text is fontified stealthily."
(min jit-lock-context-unfontify-pos jit-lock-start)))))) (min jit-lock-context-unfontify-pos jit-lock-start))))))
(defun jit-lock--antiblink-post-command () (defun jit-lock--antiblink-post-command ()
(let* ((new-l-l-b (set-marker (make-marker) (line-beginning-position))) (let* ((new-l-b-p (copy-marker (line-beginning-position)))
(new-i-s-o-c (l-b-p-2 (line-beginning-position 2))
(nth 8 (save-excursion (syntax-ppss (line-end-position)))))
(same-line (same-line
(and jit-lock-antiblink-grace (and jit-lock-antiblink-grace
(eq (marker-buffer jit-lock--antiblink-l-l-b) (current-buffer)) (not (= new-l-b-p l-b-p-2))
(= new-l-l-b jit-lock--antiblink-l-l-b)))) (eq (marker-buffer jit-lock--antiblink-l-b-p) (current-buffer))
(= new-l-b-p jit-lock--antiblink-l-b-p)))
(new-i-s-o-c
(and same-line
(nth 8 (save-excursion (syntax-ppss l-b-p-2))))))
(cond (;; opened a new multiline string... (cond (;; opened a new multiline string...
(and same-line (and same-line
(null jit-lock--antiblink-i-s-o-c) new-i-s-o-c) (null jit-lock--antiblink-i-s-o-c) new-i-s-o-c)
;; assert that the grace timer is null and schedule it ;; assert that the grace timer is null and schedule it
(when jit-lock--antiblink-grace-timer (when jit-lock--antiblink-grace-timer
(display-warning (message "internal warning: `jit-lock--antiblink-grace-timer' not null"))
'font-lock :level
"`jit-lock--antiblink-grace-timer' not null" :warning))
(setq jit-lock--antiblink-grace-timer (setq jit-lock--antiblink-grace-timer
(run-with-idle-timer jit-lock-antiblink-grace nil (run-with-idle-timer jit-lock-antiblink-grace nil
(lambda () (lambda ()
...@@ -721,9 +721,7 @@ will take place when text is fontified stealthily." ...@@ -721,9 +721,7 @@ will take place when text is fontified stealthily."
;; `jit-lock-context-timer' as usual. ;; `jit-lock-context-timer' as usual.
(when jit-lock--antiblink-grace-timer (when jit-lock--antiblink-grace-timer
(cancel-timer jit-lock--antiblink-grace-timer) (cancel-timer jit-lock--antiblink-grace-timer)
(setq jit-lock--antiblink-grace-timer nil)) (setq jit-lock--antiblink-grace-timer nil)))
)
(same-line (same-line
;; in same line, but no state change, leave everything as it was ;; in same line, but no state change, leave everything as it was
) )
...@@ -739,7 +737,7 @@ will take place when text is fontified stealthily." ...@@ -739,7 +737,7 @@ will take place when text is fontified stealthily."
(cancel-timer jit-lock--antiblink-grace-timer) (cancel-timer jit-lock--antiblink-grace-timer)
(setq jit-lock--antiblink-grace-timer nil)))) (setq jit-lock--antiblink-grace-timer nil))))
;; update variables ;; update variables
(setq jit-lock--antiblink-l-l-b new-l-l-b (setq jit-lock--antiblink-l-b-p new-l-b-p
jit-lock--antiblink-i-s-o-c new-i-s-o-c))) jit-lock--antiblink-i-s-o-c new-i-s-o-c)))
(provide 'jit-lock) (provide 'jit-lock)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment