all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Mauro Aranda <maurooaranda@gmail.com>
Cc: 43265@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode
Date: Fri, 22 Jan 2021 20:32:38 +0100	[thread overview]
Message-ID: <87mtx0ydgp.fsf@gnus.org> (raw)
In-Reply-To: <CABczVwdPmH8JBGdvTC6QhZwPpOEeyPK_Jv4DiieY-ok=yZDzJw@mail.gmail.com> (Mauro Aranda's message of "Mon, 7 Sep 2020 17:05:01 -0300")

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





  reply	other threads:[~2021-01-22 19:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 20:05 bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode Mauro Aranda
2021-01-22 19:32 ` Lars Ingebrigtsen [this message]
2021-01-22 20:11   ` Mauro Aranda
2021-01-22 22:32   ` Stefan Monnier
2021-01-23 18:42     ` Lars Ingebrigtsen
2021-01-23 19:54       ` Stefan Monnier
2021-01-24 19:58         ` Lars Ingebrigtsen
2021-01-24 19:59           ` Lars Ingebrigtsen
2021-01-24 20:09           ` Eli Zaretskii
2021-01-24 20:16             ` Lars Ingebrigtsen
2021-01-24 21:58               ` bug#43265: [External] : " Drew Adams
2021-01-25  6:30                 ` Tassilo Horn
2021-01-25  6:39                   ` Lars Ingebrigtsen
2021-01-25  6:46                     ` Tassilo Horn
2021-01-25 13:59                       ` Stefan Monnier
2021-01-25 23:34                         ` Lars Ingebrigtsen
2021-01-25 16:09                       ` Drew Adams
2021-01-25 16:14                         ` Drew Adams
2021-01-25 16:01                   ` Drew Adams
2021-01-24 21:25           ` Stefan Monnier
2021-01-26  0:19 ` Lars Ingebrigtsen
2021-01-26  0:27   ` Mauro Aranda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtx0ydgp.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=43265@debbugs.gnu.org \
    --cc=maurooaranda@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.