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

9 messages from 2009-05-25 to 2013-12-19. Participants: Samuel Bronson, Markus Heidelberg, Junio C Hamano, Jonathan Nieder.
Thread: https://gitlist.dev/t/19505

## Samuel Bronson, 2009-05-25 22:07

Subject: [PATCH 1/3] Documentation/Makefile: add a commented-out ' to unconfuse Emacs
Message-ID: <1243289231-32500-1-git-send-email-naesten@gmail.com>
URL: https://gitlist.dev/e/1243289231-32500-1-git-send-email-naesten%40gmail.com

```
Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
 Documentation/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

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, 2009-05-25 22:07

Subject: [PATCH 2/3] Makefile: Add "make help" telling users to read INSTALL and Makefile
Message-ID: <1243289231-32500-2-git-send-email-naesten@gmail.com>
URL: https://gitlist.dev/e/1243289231-32500-2-git-send-email-naesten%40gmail.com
In-Reply-To: <1243289231-32500-1-git-send-email-naesten@gmail.com>

```
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(-)

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, 2009-05-25 22:07

Subject: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <1243289231-32500-3-git-send-email-naesten@gmail.com>
URL: https://gitlist.dev/e/1243289231-32500-3-git-send-email-naesten%40gmail.com
In-Reply-To: <1243289231-32500-2-git-send-email-naesten@gmail.com>

```
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.
+
 
 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, 2009-05-30 13:05

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <200905301505.38016.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200905301505.38016.markus.heidelberg%40web.de
In-Reply-To: <1243289231-32500-3-git-send-email-naesten@gmail.com>

```
Samuel Bronson, 26.05.2009:
> 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, 2009-05-30 18:37

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <db65a1cd0905301137o482d9b14se0c438678fb4e4dd@mail.gmail.com>
URL: https://gitlist.dev/e/db65a1cd0905301137o482d9b14se0c438678fb4e4dd%40mail.gmail.com
In-Reply-To: <200905301505.38016.markus.heidelberg@web.de>

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

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

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

> 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, 2009-05-30 19:07

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <7vr5y6z9xp.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr5y6z9xp.fsf%40alter.siamese.dyndns.org
In-Reply-To: <200905301505.38016.markus.heidelberg@web.de>

```
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, 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, 2009-05-30 22:01

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <200905310001.44532.markus.heidelberg@web.de>
URL: https://gitlist.dev/e/200905310001.44532.markus.heidelberg%40web.de
In-Reply-To: <7vr5y6z9xp.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano, 30.05.2009:
> 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, 2013-12-19 23:37

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <CAJYzjmcbQVgRk9pjyWSqaDPz6=kFQ9spE14Bq5aG4dnuo-t=oA@mail.gmail.com>
URL: https://gitlist.dev/e/CAJYzjmcbQVgRk9pjyWSqaDPz6%3DkFQ9spE14Bq5aG4dnuo-t%3DoA%40mail.gmail.com
In-Reply-To: <200905310001.44532.markus.heidelberg@web.de>

```
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, 2013-12-19 23:52

Subject: Re: [PATCH 3/3] Makefile: add commented out 's for Emacs here, too
Message-ID: <20131219235221.GG20443@google.com>
URL: https://gitlist.dev/e/20131219235221.GG20443%40google.com
In-Reply-To: <CAJYzjmcbQVgRk9pjyWSqaDPz6=kFQ9spE14Bq5aG4dnuo-t=oA@mail.gmail.com>

```
Hi,

Samuel Bronson wrote:
> Markus Heidelberg 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?

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

```
