2

enter image description here

This is part of my general el config. As shown in the image, when I divide long line (that has lamda, interative) into multiple lines :which-key ...... changes color.`

  1. Why is this happening?
  2. Am I doing something wrong?
  3. What is your preferred way to execute functions that has arguments such as (org-latex-export-to-pdf nil t) in general el config.
(use-package general
  :config
  (general-evil-setup t)

  (general-create-definer rune/leader-keys
    :keymaps '(normal insert visual emacs)
    :prefix "SPC"
    :global-prefix "C-SPC")
  )



(rune/leader-keys


  "oxp"  '(org-latex-export-to-pdf                                      :which-key "(o)-(x)port-(p)df")
  "oxP"   '((lambda () (interactive) (org-latex-export-to-pdf nil t))   :which-key "(o)-(x)port-subtree-(P)df")
  "oxsp"  '((lambda () (interactive)
              (org-latex-export-to-pdf nil t))  :which-key "(o)-(x)port-subtree-(P)df")
  )

Update:

Running bare emacs -Q shows same syntax color break as image below: enter image description here

Update (2) Apparently, if nothing before :which-key then syntax color is OK. I guess.

enter image description here

2
  • (I'm assuming the highlighting is from font-lock.) Track down the font-lock rules for the major mode. If you feel the rules aren't up to the job: M-x report-emacs-bug if you see the same thing without your init file, or report it to whatever library your init file is using that might be imposing inadequate font-lock rules.
    – Drew
    Commented Apr 3, 2023 at 18:14
  • Apparently, if newline is just before the :which-key. (i.e. only spaces before :which-key) then syntax coloring won't break.
    – Garid
    Commented Apr 3, 2023 at 18:52

1 Answer 1

3

If you move to the red text and type C-h. (display-local-help), or alternatively hover the mouse pointer over the text, you will see the following message:

Easy to misread; consider moving the element to the next line

(Which comes from the help-echo text property on that text.)

You can also see that information by asking Emacs to tell you about the text at point with C-uC-x= (what-cursor-position; see also describe-char). This will additionally show you that the faces you expected to see are still present -- the initial syntax highlighting recognised everything correctly, but those faces are masked by the warning.

Essentially Emacs is pointing out that you have a sequence of expressions which are formatted over multiple lines and you haven't broken a line in a structurally-significant place between forms. If the forms are all one line that's ok; but if you have a form which is formatted over multiple lines (the lambda in this case) and you then append an additional form on the same line as the final line of that multi-line form, it points it out as potentially being visually confusing (as, depending on circumstances, the trailing form may well look like a part of the multi-line form).

You can see the same with just the following:

'((foo
   bar) baz)

The test which triggers this is named lisp--match-hidden-arg which gives you an idea of the thinking behind it.

1
  • Ah, I see thanks !
    – Garid
    Commented Apr 4, 2023 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.