threads / patch / 19505

patch, 3 partsDocumentation/Makefile: add a commented-out ' to unconfuse Emacs

Subject: [PATCH 1/3] Documentation/Makefile: add a commented-out ' to unconfuse Emacs

## tl;dr

9 messages between May 25, 2009 and Dec 19, 2013. Diffs are folded; open one to read it.

replies: 8people: 4as markdown or json

Samuel Bronson· May 25, 2009, 22:07 UTC · lore
Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
 Documentation/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to Documentation/Makefile +1 −0
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 7a8037f..f5d670e 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -106,6 +106,7 @@ endif
 SHELL_PATH ?= $(SHELL)
 # Shell quote;
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+# unconfuse Emacs: '
 
 #
 # Please note that there is a minor bug in asciidoc.
-- 
1.6.3.1
Samuel Bronson· May 25, 2009, 22:07 UTC · re: Samuel Bronson · lore

[PATCH 2/3] Makefile: Add "make help" telling users to read INSTALL and Makefile

Without this, "make help" first builds "help.o", then tries to link it to make a "help" executable, which might take a while to fail in a clean tree.

Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
 Makefile |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Show changes to Makefile +6 −0
diff --git a/Makefile b/Makefile
index eaae45d..07a141d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,12 @@
 # The default target of this Makefile is...
 all::
 
+.PHONY: help
+help:
+	@echo 'Building:'
+	@echo '  For help on building, see the INSTALL file and the comments at'
+	@echo '  the top of Makefile'
+
 # Define V=1 to have a more verbose compile.
 #
 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
-- 
1.6.3.1
Samuel Bronson· May 25, 2009, 22:07 UTC · re: Samuel Bronson · lore

[PATCH 3/3] Makefile: add commented out 's for Emacs here, too

Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
 Makefile |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Show changes to Makefile +13 −0
diff --git a/Makefile b/Makefile
index 07a141d..b485c21 100644
--- a/Makefile
+++ b/Makefile
@@ -1190,6 +1190,13 @@ prefix_SQ = $(subst ','\'',$(prefix))
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
+# unconfuse Emacs: '
+
+# The above comment is in case there is an odd number of _SQ
+# definitions above, since they seem to confuse Emacs. If there is an
+# even number of such definitions, it does no harm, since emacs
+# doesn't recognize string delimiters inside recognized comments.
+
 
 LIBS = $(GITLIBS) $(EXTLIBS)
 
@@ -1437,6 +1444,8 @@ cscope:
 ### Detect prefix changes
 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
+# unconfuse Emacs: '
+# (see above comment about "unconfuse Emacs")
 
 GIT-CFLAGS: .FORCE-GIT-CFLAGS
 	@FLAGS='$(TRACK_CFLAGS)'; \
@@ -1457,6 +1466,8 @@ GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
 TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
+# unconfuse Emacs: '
+# (see above comment about "unconfuse Emacs")
 
 GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 	@VARS='$(TRACK_VARS)'; \
@@ -1540,6 +1551,8 @@ gitexec_instdir = $(prefix)/$(gitexecdir)
 endif
 gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
 export gitexec_instdir
+# unconfuse Emacs: '
+# (see above comment about "unconfuse Emacs")
 
 install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
-- 
1.6.3.1
Markus Heidelberg· May 30, 2009, 13:05 UTC · re: Samuel Bronson · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

Samuel Bronson, 26.05.2009:
Show 19 quoted lines
> Signed-off-by: Samuel Bronson <naesten@gmail.com>
> ---
>  Makefile |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 07a141d..b485c21 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1190,6 +1190,13 @@ prefix_SQ = $(subst ','\'',$(prefix))
>  SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
>  PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
>  TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
> +# unconfuse Emacs: '
> +
> +# The above comment is in case there is an odd number of _SQ
> +# definitions above, since they seem to confuse Emacs. If there is an
> +# even number of such definitions, it does no harm, since emacs
> +# doesn't recognize string delimiters inside recognized comments.

This doesn't only confuse Emacs, so the subject should be changed to something like "... to unconfuse editors' syntax highlighting" and be squashed with Patch 1/3, since this is exactly the same issue.

I think this is way too much comment and would prefer none at all. I also would remove the global 4-line comment.

But Vim for example is not satisfied with your fix above. It needs this workaround for every line and additionally needs a closing parenthesis, because the real one is hidden in the string. So this would work for Vim:

 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+#')
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
+#')

Maybe even behind the concerned line to avoid clutter, if this doesn't cause other problems:

-PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#') -TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) +TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))#')

But I'm not completely confident of this fix anyway and don't know whether it should be included at all.

Markus
Samuel Bronson· May 30, 2009, 18:37 UTC · re: Markus Heidelberg · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

On Sat, May 30, 2009 at 9:05 AM, Markus Heidelberg <markus.heidelberg@web.de> wrote:

Show 11 quoted lines
>> +# The above comment is in case there is an odd number of _SQ
>> +# definitions above, since they seem to confuse Emacs. If there is an
>> +# even number of such definitions, it does no harm, since emacs
>> +# doesn't recognize string delimiters inside recognized comments.
>
> This doesn't only confuse Emacs, so the subject should be changed to
> something like "... to unconfuse editors' syntax highlighting" and be
> squashed with Patch 1/3, since this is exactly the same issue.
>
> I think this is way too much comment and would prefer none at all. I
> also would remove the global 4-line comment.

Okay. I guess I'll save it for the commit message (rewritten to match the changes suggested below), maybe keep two words for the first one in each Makefile ...

Show 9 quoted lines
> But Vim for example is not satisfied with your fix above. It needs this
> workaround for every line and additionally needs a closing parenthesis,
> because the real one is hidden in the string. So this would work for
> Vim:
>
>  PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
> +#')
>  TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
> +#')

Yeah, emacs would work better that way too -- I was going for a low-disruption patch, and was mostly interested in making sure unrelated portions of the Makefile didn't get swallowed by string-coloring. I didn't particularly care about the parentheses -- does Vim care about that for indentation, or just paren-matching?

I wonder why emacs and vim both have the same problem with that construct ... and how hard it would be to fix. (Thankfully, this approach to dealing with the breakage will not confuse corrected versions, since they will basically ignore the contents of the comments for syntax highlighting purposes :-).

Show 7 quoted lines
> Maybe even behind the concerned line to avoid clutter, if this doesn't
> cause other problems:
>
> -PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
> +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#')
> -TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
> +TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))#')

That should at least work a lot better than my initial attempt at 1/3, where I had a space before the # -- the space broke the build, which is actually how I ended up noticing the need for 2/3 .

Junio C Hamano· May 30, 2009, 19:07 UTC · re: Markus Heidelberg · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

Markus Heidelberg <markus.heidelberg@web.de> writes:
Show 9 quoted lines
>> +# unconfuse Emacs: '
>> +
>> +# The above comment is in case there is an odd number of _SQ
>> +# definitions above, since they seem to confuse Emacs. If there is an
>> +# even number of such definitions, it does no harm, since emacs
>> +# doesn't recognize string delimiters inside recognized comments.
> ...
> I think this is way too much comment and would prefer none at all. I
> also would remove the global 4-line comment.

I personally do not like contaminating our source files with this kind of magic crufts just to please broken tools, be they emacs or vim. I would hate them even more if they are not clearly commented why they exist for two reasons.

 (1) without clear instructions ("odd number of ..." is not quite enough),
     people who do *not* use broken tools cannot keep them up-to-date when
     they make modifications;
 (2) when broken tools are finally fixed, nobody would remember why the
     magic crufts exist, and they will end up staying in the source for a
     long time.
Markus Heidelberg· May 30, 2009, 22:01 UTC · re: Junio C Hamano · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

Junio C Hamano, 30.05.2009:
Show 14 quoted lines
> Markus Heidelberg <markus.heidelberg@web.de> writes:
> 
> >> +# unconfuse Emacs: '
> >> +
> >> +# The above comment is in case there is an odd number of _SQ
> >> +# definitions above, since they seem to confuse Emacs. If there is an
> >> +# even number of such definitions, it does no harm, since emacs
> >> +# doesn't recognize string delimiters inside recognized comments.
> > ...
> > I think this is way too much comment and would prefer none at all. I
> > also would remove the global 4-line comment.
> 
> I personally do not like contaminating our source files with this kind of
> magic crufts just to please broken tools [...]

Neither do I like it. That's why I wrote, I wasn't sure whether this should be applied.

In the buildroot project (it consists of Makefiles) there a lots of those workarounds. There was a patch on the list to replace all $(strip $(subst ",,$(FOO))) with $(call strip_dquotes, $(FOO)), but $(call) is not allowed in git for compatibility reasons.

Markus
Samuel Bronson· Dec 19, 2013, 23:37 UTC · re: Markus Heidelberg · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

On Sat, May 30, 2009 at 6:01 PM, Markus Heidelberg <markus.heidelberg@web.de> wrote:

> In the buildroot project (it consists of Makefiles) there a lots of
> those workarounds. There was a patch on the list to replace all
> $(strip $(subst ",,$(FOO))) with $(call strip_dquotes, $(FOO)), but
> $(call) is not allowed in git for compatibility reasons.
Hmm.  What compatibility reasons, and are they still applicable?

[If you're wondering why I'm revisiting this, I was looking through my branches for anything outstanding and found this patch series there.]

Jonathan Nieder· Dec 19, 2013, 23:52 UTC · re: Samuel Bronson · lore

Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too

Hi,
Samuel Bronson wrote:
> Markus Heidelberg wrote:
Show 6 quoted lines
>> In the buildroot project (it consists of Makefiles) there a lots of
>> those workarounds. There was a patch on the list to replace all
>> $(strip $(subst ",,$(FOO))) with $(call strip_dquotes, $(FOO)), but
>> $(call) is not allowed in git for compatibility reasons.
>
> Hmm.  What compatibility reasons, and are they still applicable?
Good question.
  $ git log -1 -S'$(call ' -- Makefile 
  commit 39c015c556f285106931e0500f301de462b0e46e
  Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
  Date:   Sat Feb 18 12:40:22 2006 +0100
      Fixes for ancient versions of GNU make
      Some versions of GNU make do not understand $(call), and have problems to
      interpret rules like this:
      some_target: CFLAGS += -Dsome=defs
      [jc: simplified substitution a bit. ]
      Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
      Signed-off-by: Junio C Hamano <junkio@cox.net>

A quick gmane search finds [1], which suggests the "make" where this problem came up was on IRIX. I don't have a strong opinion either way about whether such ancient 'make' is worth supporting (as a practical matter, it's hard to keep testing and make sure such support still works).

Would $(call) simplify the makefile much?

Thanks, Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/16344 http://thread.gmane.org/gmane.comp.version-control.git/16345/focus=16375 http://thread.gmane.org/gmane.comp.version-control.git/48968/focus=49117

← back to recent threads