[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] externals/colorful-mode 0ebfa75fe1: Use jit-lock instead font
From: |
Stefan Monnier |
Subject: |
Re: [elpa] externals/colorful-mode 0ebfa75fe1: Use jit-lock instead font-lock-add-keywords. |
Date: |
Mon, 31 Mar 2025 09:16:23 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> + ;; Remove full colorful overlay instead only the part where
> + ;; the region is.
> (dolist (ov (overlays-in beg end))
> (when (overlay-get ov 'colorful--overlay)
> - (remove-overlays beg end 'colorful--overlay t))))))
> + (remove-overlays (overlay-start ov) (overlay-end ov)
> 'colorful--overlay t))))))
Makes sense, but then you want to use `delete-overlay` rather than
`remove-overlays`, no?
> +;;; Fontify functions
> +(defun colorful-mode-fontify-region (start end)
> + ;; Clean up colorful overlays if found
> + (setq start (progn (goto-char start) (line-beginning-position)))
> + (setq end (progn (goto-char end) (line-end-position)))
> +
> + (save-excursion
> + (remove-overlays (or start (point-min)) (or end (point-max))
> 'colorful--overlay t)
At this point `start` and `end` cannot be nil, so you can drop the `or`s.
> + (cond
> + ((stringp keywords)
> + (while (re-search-forward keywords end t)
> + (funcall #'colorful--colorize type (match-string-no-properties
> match)
> + (match-beginning match) (match-end match))))
> + ((functionp keywords)
> + (while (funcall keywords end)
> + (funcall #'colorful--colorize type (match-string-no-properties
> match)
> + (match-beginning match) (match-end match)))))))
Why the `funcall`s?
> + `(jit-lock-bounds ,start . ,end)))
Thanks, I appreciate this detail.
Stefan
- Re: [elpa] externals/colorful-mode 0ebfa75fe1: Use jit-lock instead font-lock-add-keywords.,
Stefan Monnier <=