* bug#45747: 27.1; mercury-mode font lock bug
@ 2021-01-09 13:22 k3tu0isui
2021-01-09 15:29 ` bug#45747: [PATCH] mercury-mode font lock fix k3tu0isui
0 siblings, 1 reply; 5+ messages in thread
From: k3tu0isui @ 2021-01-09 13:22 UTC (permalink / raw)
To: 45747
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`.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#45747: [PATCH] mercury-mode font lock fix
2021-01-09 13:22 bug#45747: 27.1; mercury-mode font lock bug k3tu0isui
@ 2021-01-09 15:29 ` k3tu0isui
2021-01-10 12:51 ` bug#45747: 27.1; mercury-mode font lock bug Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: k3tu0isui @ 2021-01-09 15:29 UTC (permalink / raw)
To: 45747
[-- Attachment #1: Type: text/plain, Size: 338 bytes --]
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.
[-- Attachment #2: emacs-mercury.patch --]
[-- Type: text/plain, Size: 813 bytes --]
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index c8f6c12a3f..742274a479 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -1201,7 +1201,8 @@ mercury-mode-map
(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))
\f
;;-------------------------------------------------------------------
@@ -2082,7 +2083,8 @@ prolog-font-lock-keywords
(delq
nil
(cond
- ((eq major-mode 'prolog-mode)
+ ((or (eq major-mode 'prolog-mode)
+ (eq major-mode 'mercury-mode))
(list
head-predicates
head-predicates-1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#45747: 27.1; mercury-mode font lock bug
2021-01-09 15:29 ` bug#45747: [PATCH] mercury-mode font lock fix k3tu0isui
@ 2021-01-10 12:51 ` Lars Ingebrigtsen
2021-01-10 13:28 ` k3tu0isui
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-10 12:51 UTC (permalink / raw)
To: k3tu0isui; +Cc: 45747
k3tu0isui@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#45747: 27.1; mercury-mode font lock bug
2021-01-10 12:51 ` bug#45747: 27.1; mercury-mode font lock bug Lars Ingebrigtsen
@ 2021-01-10 13:28 ` k3tu0isui
2021-01-10 13:38 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: k3tu0isui @ 2021-01-10 13:28 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 45747
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#45747: 27.1; mercury-mode font lock bug
2021-01-10 13:28 ` k3tu0isui
@ 2021-01-10 13:38 ` Lars Ingebrigtsen
0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-10 13:38 UTC (permalink / raw)
To: k3tu0isui; +Cc: 45747
k3tu0isui@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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-10 13:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-09 13:22 bug#45747: 27.1; mercury-mode font lock bug k3tu0isui
2021-01-09 15:29 ` bug#45747: [PATCH] mercury-mode font lock fix k3tu0isui
2021-01-10 12:51 ` bug#45747: 27.1; mercury-mode font lock bug Lars Ingebrigtsen
2021-01-10 13:28 ` k3tu0isui
2021-01-10 13:38 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).