GNU bug report logs - #33247
makefile mode comment color

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sat, 3 Nov 2018 03:41:02 UTC

Severity: minor

Merged with 9407, 24380

To reply to this bug, email your comments to 33247 AT debbugs.gnu.org.

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#33247; Package emacs. (Sat, 03 Nov 2018 03:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 03 Nov 2018 03:41:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Subject: makefile mode comment color
Date: Sat, 03 Nov 2018 11:39:40 +0800
Makefile-mode should show comment color for both of
xxx:# yyyy
xxx: #zzzz
not just the last.




Merged 9407 24380 33247. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 03 Nov 2018 16:15:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33247; Package emacs. (Tue, 06 Nov 2018 09:48:01 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 33247 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#33247: makefile mode comment color
Date: 6 Nov 2018 09:47:21 -0000
Hello, Dan.

In article <mailman.3320.1541216477.1284.bug-gnu-emacs <at> gnu.org> you wrote:
> Makefile-mode should show comment color for both of
> xxx:# yyyy
> xxx: #zzzz
> not just the last.

Yes.  In make-mode.el, at line 525, there's a syntax-propertize-function
setting which decommentises a # unless the previous character was one of
|, &, ;, <, > (, ), `, \, ", ', <space>, <tab>, <newline>.  : is not in
that list.

The comment to this setting:

   ;; From sh-script.el.
   ;; A `#' begins a comment in sh when it is unquoted and at the beginning
   ;; of a word.  In the shell, words are separated by metacharacters.
   ;; The list of special chars is taken from the single-unix spec of the
   ;; shell command language (under `quoting') but with `$' removed.

confirms that the setting was taken over from shell-script-mode, and it
is essentially unchanged.

Why do we have this setting for makefiles at all?  Are there any such
restrictions on comments in Makefiles?  Stefan?

As a quick fix, please try the following (based off of master, though
it'll probably work on released versions, too):


diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index f67407f48e..27da624086 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -522,7 +522,7 @@ makefile-syntax-propertize-function
    ;; of a word.  In the shell, words are separated by metacharacters.
    ;; The list of special chars is taken from the single-unix spec of the
    ;; shell command language (under `quoting') but with `$' removed.
-   ("[^|&;<>()`\\\"' \t\n]\\(#+\\)" (1 "_"))
+   ;; ("[^|&;<>()`\\\"' \t\n]\\(#+\\)" (1 "_"))
    ;; Change the syntax of a quoted newline so that it does not end a comment.
    ("\\\\\n" (0 "."))))
 


-- 
Alan Mackenzie (Nuremberg, Germany).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33247; Package emacs. (Tue, 06 Nov 2018 10:02:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 33247 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#33247: makefile mode comment color
Date: Tue, 06 Nov 2018 18:01:46 +0800
Glad you found the bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33247; Package emacs. (Tue, 06 Nov 2018 13:26:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 33247 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#33247: makefile mode comment color
Date: Tue, 06 Nov 2018 08:25:39 -0500
> Why do we have this setting for makefiles at all?

That's to handle the /bin/sh comments on the command lines of rules,
where the code is run by /bin/sh and hence obeys the corresponding
rules.  E.g.

   foo.o: foo.c
   	echo This is#not a comment
   	$(CC) $(CFLAGS) -o $@ $<  #This is an sh comment

> Are there any such
> restrictions on comments in Makefiles?  Stefan?

Maybe we should conditionalize on the presence of a leading TAB at the
beginning of the line.

BTW, I recently saw that the above is wrong in cases like

   foo.o: foo.c
   	@#An sh comment not recognized by current makefile mode
   	$(CC) $(CFLAGS) -o $@ $<  #This is a comment

so if you can fix both of those while you're there, that'd be great!


-- Stefan




This bug report was last modified 6 years and 220 days ago.

Previous Next


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