GNU bug report logs - #45747
27.1; mercury-mode font lock bug

Previous Next

Package: emacs;

Reported by: k3tu0isui <at> gmail.com

Date: Sat, 9 Jan 2021 15:11:02 UTC

Severity: normal

Tags: fixed, moreinfo

Found in version 27.1

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 45747 in the body.
You can then email your comments to 45747 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#45747; Package emacs. (Sat, 09 Jan 2021 15:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to k3tu0isui <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 09 Jan 2021 15:11:02 GMT) Full text and rfc822 format available.

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

From: k3tu0isui <at> gmail.com
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; mercury-mode font lock bug
Date: Sat, 9 Jan 2021 18:52:43 +0530
Mercury mode syntax high lighting is not working. mercury-mode is a derived mode under prolog-mode.
The only face active is `font-lock-comment-face`. 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45747; Package emacs. (Sat, 09 Jan 2021 15:31:01 GMT) Full text and rfc822 format available.

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

From: k3tu0isui <at> gmail.com
To: 45747 <at> debbugs.gnu.org
Subject: [PATCH] mercury-mode font lock fix
Date: Sat, 9 Jan 2021 20:59:49 +0530
[Message part 1 (text/plain, inline)]
The problem seems to be arising due to mercury-mode being defined as a major-mode rather than a different system under prolog mode. I changed a line in prolog-font-lock-keywords to work with mercury-mode and added a call to prolog-mode-variables in define-derived-mode mercury-mode to setup the required variables for font lock keywords.
[emacs-mercury.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45747; Package emacs. (Sun, 10 Jan 2021 12:52:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: k3tu0isui <at> gmail.com
Cc: 45747 <at> debbugs.gnu.org
Subject: Re: bug#45747: 27.1; mercury-mode font lock bug
Date: Sun, 10 Jan 2021 13:51:11 +0100
k3tu0isui <at> gmail.com writes:

> The problem seems to be arising due to mercury-mode being defined as a
> major-mode rather than a different system under prolog mode. I changed
> a line in prolog-font-lock-keywords to work with mercury-mode and
> added a call to prolog-mode-variables in define-derived-mode
> mercury-mode to setup the required variables for font lock keywords.

[...]

>  (define-derived-mode mercury-mode prolog-mode "Prolog[Mercury]"
>    "Major mode for editing Mercury programs.
>  Actually this is just customized `prolog-mode'."
> -  (setq-local prolog-system 'mercury))
> +  (setq-local prolog-system 'mercury)
> +  (prolog-mode-variables))

I'm not a Mercury mode user, but I don't quite understand this bit of
the patch -- mercury-mode is derived from prolog-mode, so
`prolog-mode-variables' should already be run at this point?  So is that
bit necessary/

> -      ((eq major-mode 'prolog-mode)
> +      ((or (eq major-mode 'prolog-mode)
> +           (eq major-mode 'mercury-mode))
>         (list
>          head-predicates
>          head-predicates-1

This could perhaps be:

diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index c8f6c12a3f..1ac0210f81 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -2082,7 +2082,7 @@ prolog-font-lock-keywords
     (delq
      nil
      (cond
-      ((eq major-mode 'prolog-mode)
+      ((derived-mode-p 'prolog-mode)
        (list
         head-predicates
         head-predicates-1


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




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 12:52:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45747; Package emacs. (Sun, 10 Jan 2021 13:29:02 GMT) Full text and rfc822 format available.

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

From: k3tu0isui <at> gmail.com
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 45747 <at> debbugs.gnu.org
Subject: Re: bug#45747: 27.1; mercury-mode font lock bug
Date: Sun, 10 Jan 2021 18:58:24 +0530
Maybe prolog-mode-variables has already been called, but maybe due to (setq-local prolog-system 'mercury) not being set, some variables like prolog-determinism-specifiers-i and prolog-types-i are not being set to mercury values. So quite a bit of keywords are ignored when syntax-highlighting happens.

Without (prolog-mode-variables) the variables prolog-determinism-specifiers-i and prolog-types-i are bound to nil and syntax-highlighting for mode and type declarations fails. But when I added this call to define-derived-mode they are bound to ("cc_multi" "cc_nondet" "det" "erroneous" "failure" "multi" "nondet" "semidet") and ("char" "float" "int" "io__state" "string" "univ") resp. and it works.

I do not really understand how everything works, but my patch is working somehow. I am just fixing the symptoms, if anyone has a better understanding please provide a patch.

I agree with replacing (eq major-mode 'prolog-mode) with (derived-mode-p 'prolog-mode) which covers all derived modes, rather than my current specific case of mercury mode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45747; Package emacs. (Sun, 10 Jan 2021 13:39:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: k3tu0isui <at> gmail.com
Cc: 45747 <at> debbugs.gnu.org
Subject: Re: bug#45747: 27.1; mercury-mode font lock bug
Date: Sun, 10 Jan 2021 14:38:14 +0100
k3tu0isui <at> gmail.com writes:

> Maybe prolog-mode-variables has already been called, but maybe due to
> (setq-local prolog-system 'mercury) not being set, some variables like
> prolog-determinism-specifiers-i and prolog-types-i are not being set
> to mercury values. So quite a bit of keywords are ignored when
> syntax-highlighting happens.

Ah, I missed that `prolog-find-value-by-system' (called by that
function) depended on `prolog-system', so I think your patch is correct,
and I've now applied it to Emacs 28.  (With the `derived-mode-p' tweak.)

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 13:39:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 45747 <at> debbugs.gnu.org and k3tu0isui <at> gmail.com Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 13:39: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. (Mon, 08 Feb 2021 12:24:05 GMT) Full text and rfc822 format available.

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

Previous Next


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