GNU bug report logs - #49197
[PATCH] 28.0.50; Inability to find "diff" prevents `font-lock-add-keywords' from working in `diff-mode'

Previous Next

Package: emacs;

Reported by: Jim Porter <jporterbugs <at> gmail.com>

Date: Wed, 23 Jun 2021 21:01:02 UTC

Severity: normal

Tags: patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Porter <jporterbugs <at> gmail.com>
To: 49197 <at> debbugs.gnu.org
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
[Message part 1 (text/plain, inline)]
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.
[0001-Ignore-file-missing-errors-during-diff-refined-font-.patch (application/octet-stream, attachment)]
[diff-trailing-ws.patch (application/octet-stream, attachment)]

This bug report was last modified 3 years and 330 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.