bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49197: [PATCH] 28.0.50; Inability to find "diff" prevents `font-lock


From: Jim Porter
Subject: bug#49197: [PATCH] 28.0.50; Inability to find "diff" prevents `font-lock-add-keywords' from working in `diff-mode'
Date: Wed, 23 Jun 2021 14:00:05 -0700

This is a very minor issue that I happened to stumble upon. On systems
without "diff", adding a new font-lock rule via
`font-lock-add-keywords' doesn't do anything. This is (if I'm
understanding things correctly) because the diff-refined code will
signal an error, terminating the font-lock code early. Since
`diff--font-lock-refined' is normally the last element in the list,
this only causes issues when a user has added more font-lock rules. To
see the problem in action, you can do the following:

  emacs -Q
  (setq diff-command "nonexist")
  (add-hook 'diff-mode-hook
            (lambda ()
              (font-lock-add-keywords
               nil
               '(("^..*?\\([[:blank:]]+\\)$" 1
                  'trailing-whitespace prepend))
               t)))
  C-x C-f diff-trailing-ws.patch ;; Attached
  ;; The added line should be highlighted with `trailing-whitespace',
  ;; but it isn't.

I've attached a patch for this which ignores `file-missing' errors
when using diff-refined during font-locking. With the patch, running
the above steps correctly highlights trailing whitespace.

Attachment: 0001-Ignore-file-missing-errors-during-diff-refined-font-.patch
Description: Binary data

Attachment: diff-trailing-ws.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]