[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode
From: |
Lars Ingebrigtsen |
Subject: |
bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode |
Date: |
Fri, 22 Jan 2021 20:32:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Mauro Aranda <maurooaranda@gmail.com> writes:
> To reproduce:
>
> emacs -Q
> In the scratch buffer type:
>
> (condition-case nil
> (fail-badly)
> (error (when foo t)))
>
> I don't see WHEN with font-lock-keyword-face. However:
>
> (condition-case nil
> (fail-badly)
> (error (if foo t)))
>
> IF has font-lock-keyword-face.
This is the bit that determines whether to give something a keyword-face:
(defun lisp--el-match-keyword (limit)
;; FIXME: Move to elisp-mode.el.
(catch 'found
(while (re-search-forward
(eval-when-compile
(concat "(\\(" lisp-mode-symbol-regexp "\\)\\_>"))
limit t)
(let ((sym (intern-soft (match-string 1))))
(when (or (special-form-p sym)
(and (macrop sym)
(not (get sym 'no-font-lock-keyword))
(not (lisp--el-non-funcall-position-p
(match-beginning 0)))))
(throw 'found t))))))
All special forms get it (`if' is a special form), but macros (like
`when') only gets it if we're in a funcall position:
(defun lisp--el-non-funcall-position-p (pos)
"Heuristically determine whether POS is an evaluated position."
[...]
(and (eq parent 'condition-case)
(progn
(forward-sexp 2)
(< (point) pos))))))))))
And this doesn't count any of the error clauses as being in a funcall
position, so no macros in those get a keyword-face.
I think. I've added Stefan M to the CCs.
If that's the correct analysis, then fixing this shouldn't be too hard,
I think? Just add some extra code in the `condition-case' bit to catch
this case?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode,
Lars Ingebrigtsen <=
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Mauro Aranda, 2021/01/22
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Stefan Monnier, 2021/01/22
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Lars Ingebrigtsen, 2021/01/23
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Stefan Monnier, 2021/01/23
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Lars Ingebrigtsen, 2021/01/24
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Lars Ingebrigtsen, 2021/01/24
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Eli Zaretskii, 2021/01/24
- bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Lars Ingebrigtsen, 2021/01/24
- bug#43265: [External] : bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Drew Adams, 2021/01/24
- bug#43265: [External] : bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode, Tassilo Horn, 2021/01/25