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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49197 in the body.
You can then email your comments to 49197 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49197; Package emacs. (Wed, 23 Jun 2021 21:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Porter <jporterbugs <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 23 Jun 2021 21:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49197; Package emacs. (Thu, 24 Jun 2021 16:09:01 GMT) Full text and rfc822 format available.

Message #8 received at 49197 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 49197 <at> debbugs.gnu.org
Subject: Re: bug#49197: [PATCH] 28.0.50; Inability to find "diff" prevents
 `font-lock-add-keywords' from working in `diff-mode'
Date: Thu, 24 Jun 2021 18:07:54 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

> 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.

Makes sense to me.  Pushed to Emacs 28 now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 49197 <at> debbugs.gnu.org and Jim Porter <jporterbugs <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 24 Jun 2021 16:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Jul 2021 11:24:09 GMT) Full text and rfc822 format available.

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

Previous Next


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