GNU bug report logs - #76759
[PATCH] 31.0.50; makefile-mode: incorrectly highlights make-instructions as make targets

Previous Next

Package: emacs;

Reported by: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>

Date: Wed, 5 Mar 2025 09:34:02 UTC

Severity: normal

Tags: confirmed, patch

Merged with 17400, 33681, 33900, 35299, 36245, 37934, 45037, 46052, 46221, 48052

Found in version 26.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 76759 in the body.
You can then email your comments to 76759 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#76759; Package emacs. (Wed, 05 Mar 2025 09:34:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 05 Mar 2025 09:34:04 GMT) Full text and rfc822 format available.

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

From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
To: bug-gnu-emacs <at> gnu.org
Cc: "Ergus via Emacs development discussions." <emacs-devel <at> gnu.org>
Subject: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 5 Mar 2025 10:32:39 +0100
[Message part 1 (text/plain, inline)]
Hey everyone.

I found a bug in makefile-mode fontification.

Currently shell-commands/make-instructions within a target may get fontified as make-targets if they contain a : (colon) sign.

Consider the following make-target:

------- Makefile ------

run-docker: build-docker
	docker run -p 8080:8080 imagename

--------------------------

This defined a make-target called "run-docker" which depends on "build-docker", which runs the command "docker run -p 8080:8080 imagename".

In the current code, since the command contains a ":" the whole text up to that point ("docker run -p 8080") gets fontified as a make-target, even though it's clearly not declared at the beginning of the line.

Based on my digging, this seems to be due to the matching criteria defined in makefile-dependency-regex.

A common pattern used in this regex is "[^\n$#]" (with slight variations), which (from how I read regexps) aims to match anything which is not a lineshift, a $-sign or a #-sign.

"Anything" in this case would then also include whitespace, which IMO is the source of the bug.

I've tried changing this part of the statement in parts of the regex to "[^\n\s$#]", like in the attached patch. Ie also exclude leading whitespace. From what I've tested, it does not seem to have any adverse effects, although I may not have tested all areas affected by this change.

Feel free to test the suggested changes, and let me know if they can be improved in any way.


—
Kind Regards
Jostein Kjønigsen


In GNU Emacs 31.0.50 (build 19, aarch64-apple-darwin24.3.0, NS
 appkit-2575.40 Version 15.3.1 (Build 24D70)) of 2025-03-03 built on
 SOK67R3KWV97
Repository revision: 38ed2238316a83ad2c95db04f115c38ade48514f
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.3.1

Configured using:
 'configure --with-tree-sitter --with-native-compilation
 --with-imagemagick --with-harfbuzz'

Configured features:
ACL GLIB GNUTLS IMAGEMAGICK LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: BSDmakefile

Minor modes in effect:
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-hide-gitignored-files-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  electric-pair-mode: t
  highlight-symbol-mode: t
  flycheck-mode: t
  editorconfig-mode: t
  indent-bars-mode: t
  completion-preview-mode: t
  which-function-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  poetry-tracking-mode: t
  all-the-icons-completion-mode: t
  marginalia-mode: t
  vertico-mode: t
  global-nlinum-mode: t
  nlinum-mode: t
  override-global-mode: t
  server-mode: t
  global-hl-line-mode: t
  pixel-scroll-precision-mode: t
  doom-modeline-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  hs-minor-mode: t

Load-path shadows:
/Users/josteink/.emacs.d/elpa/transient-20250301.2218/transient hides /Users/josteink/build/emacs/lisp/transient

Features:
(shadow sort mail-extr emacsbug lisp-mnt re-builder make-mode
dockerfile-ts-mode conf-mode em-unix em-term term ehelp em-script
em-prompt em-pred em-ls em-hist em-glob em-extpipe em-cmpl em-dirs
em-basic em-banner em-alias esh-mode esh-var expand-region
text-mode-expansions the-org-mode-expansions
python-el-fgallina-expansions html-mode-expansions er-basic-expansions
expand-region-core expand-region-custom whitespace hydra lv
treemacs-hydras tabify treemacs-mouse-interface treemacs
treemacs-header-line treemacs-compatibility treemacs-mode
treemacs-bookmarks treemacs-tags treemacs-interface treemacs-persistence
treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering
treemacs-annotations treemacs-async treemacs-workspaces treemacs-dom
treemacs-visuals treemacs-fringe-indicator treemacs-faces treemacs-icons
treemacs-scope treemacs-themes treemacs-core-utils pfuture ht
treemacs-logging treemacs-customization treemacs-macros ido yaml-ts-mode
display-line-numbers misearch multi-isearch help-fns radix-tree
bicep-ts-mode magit-gitignore git-rebase goto-addr magit-extras vc-hg
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference
magit-bookmark magit-submodule magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log magit-diff smerge-mode
git-commit log-edit pcvs-util magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor magit-mode benchmark magit-git
magit-base magit-section cursor-sensor crm llama markdown-mode add-log
elec-pair json-ts-mode vc-git vc-dispatcher tramp-cache time-stamp
tramp-sh pulse org-duration diary-lib diary-loaddefs cal-iso disp-table
oc-basic ol-eww ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art
mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group
gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source
utf7 nnoo gnus-spec gnus-int gnus-range message sendmail yank-media
rfc822 mml mml-sec epa derived epg rfc6068 epg-config mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus-win ol-docview doc-view jka-compr
image-mode exif dired dired-loaddefs ol-bibtex bibtex ol-bbdb ol-w3m
ol-doi org-link-doi org-agenda elisp-slime-nav etags fileloop paredit
highlight-symbol flycheck editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch indent-bars-ts indent-bars
cus-edit cus-start cus-load face-remap color eglot tree-widget
external-completion jsonrpc flymake diff ert ewoc debug backtrace
compile completion-preview which-func hideshow eww vtable url-queue shr
pixel-fill kinsoku url-file svg xml puny mm-url gnus nnheader gnus-util
mail-utils range wid-edit mm-util mail-prsvr tramp trampver
tramp-integration tramp-message tramp-compat shell parse-time iso8601
tramp-loaddefs imenu ob-plantuml delsel autorevert filenotify embark-org
org-element org-persist org-id org-refile org-element-ast inline
avl-tree org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src sh-script smie executable ob-comint org-pcomplete org-list
org-footnote org-faces org-entities time-date noutline outline
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar
cal-loaddefs org-version org-compat org-macs poetry pyvenv eshell
esh-cmd esh-ext esh-proc esh-opt esh-io esh-arg pcomplete esh-module
esh-module-loaddefs esh-util embark-consult consult bookmark
text-property-search embark ffap orderless all-the-icons-completion
marginalia vertico nlinum linum use-package-bind-key bind-key server
hl-line pixel-scroll cua-base all-the-icons all-the-icons-faces
data-material data-weathericons data-octicons data-fileicons
data-faicons data-alltheicons doom-modeline doom-modeline-segments
doom-modeline-env doom-modeline-core shrink-path f s dash nerd-icons
nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon
nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon
nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon
nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon dracula-theme
use-package-ensure use-package-core finder-inf
all-the-icons-completion-autoloads all-the-icons-autoloads
bmx-mode-autoloads cargo-autoloads cmake-mode-autoloads
combobulate-autoloads combobulate-go combobulate-json combobulate-yaml
combobulate-css combobulate-js-ts combobulate-python combobulate-html
combobulate-toml combobulate-cursor multiple-cursors
mc-separate-operations rectangular-region-mode mc-mark-pop mc-edit-lines
mc-hide-unmatched-lines-mode mc-mark-more sgml-mode facemenu dom
thingatpt mc-cycle-cursors multiple-cursors-core advice comp comp-cstr
cl-extra help-mode warnings comp-run comp-common rect combobulate-query
savehist xref files-x scheme combobulate-ui transient pp format-spec
edmacro kmacro combobulate-display combobulate-ztree
combobulate-envelope combobulate-manipulation python rx project compat
comint ansi-osc ring ansi-color combobulate-procedure
combobulate-navigation combobulate-misc combobulate-setup tempo
combobulate-interface combobulate-settings diff-mode track-changes
easy-mmode treesit generator combobulate-rules company-autoloads
copilot-mode-autoloads crontab-mode-autoloads dap-mode-autoloads
bui-autoloads doom-modeline-autoloads dracula-theme-autoloads
elisp-slime-nav-autoloads embark-consult-autoloads consult-autoloads
embark-autoloads expand-region-autoloads flycheck-autoloads
highlight-symbol-autoloads indent-bars-autoloads lsp-docker-autoloads
lsp-treemacs-autoloads lsp-mode-autoloads magit-autoloads pcase
magit-section-autoloads llama-autoloads marginalia-autoloads
markdown-mode-autoloads multiple-cursors-autoloads nerd-icons-autoloads
nlinum-autoloads orderless-autoloads paredit-autoloads poetry-autoloads
powershell-autoloads pyvenv-autoloads shrink-path-autoloads f-autoloads
spinner-autoloads transient-autoloads treemacs-autoloads cfrs-autoloads
posframe-autoloads ht-autoloads hydra-autoloads lv-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads s-autoloads
dash-autoloads undo-tree-autoloads queue-autoloads vertico-autoloads
wgrep-autoloads info with-editor-autoloads wsd-mode-autoloads
yaml-autoloads package browse-url xdg url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads kqueue cocoa ns lcms2 multi-tty make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 1136723 236110) (symbols 48 57070 3)
 (strings 32 315761 12126) (string-bytes 1 9424642)
 (vectors 16 112250) (vector-slots 8 2121204 187375)
 (floats 8 1899 10828) (intervals 56 21125 6631) (buffers 992 88))

[Message part 2 (text/html, inline)]
[0001-Fix-fontification-error-in-makefile-mode.patch (application/octet-stream, attachment)]
[Message part 4 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Wed, 05 Mar 2025 11:56:01 GMT) Full text and rfc822 format available.

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

From: "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
Cc: bug-gnu-emacs <at> gnu.org,
 "Ergus via Emacs development discussions." <emacs-devel <at> gnu.org>
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 05 Mar 2025 12:54:41 +0100
[Message part 1 (text/plain, inline)]
Hi Jostein,

Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> writes:

> A common pattern used in this regex is "[^\n$#]" (with slight variations), which (from how I read regexps) aims to match anything which is not a
> lineshift, a $-sign or a #-sign.
>
> "Anything" in this case would then also include whitespace, which IMO is the source of the bug.
>
> I've tried changing this part of the statement in parts of the regex to "[^\n\s$#]", like in the attached patch. Ie also exclude leading whitespace.
> From what I've tested, it does not seem to have any adverse effects, although I may not have tested all areas affected by this change.

From the Makefile format, I think this should not be leading whitespace,
but only leading tabs. Leading spaces in rules are a syntax error.

Can you check whether \t instead of \s also works?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Wed, 05 Mar 2025 13:02:02 GMT) Full text and rfc822 format available.

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

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>,
 76759 <at> debbugs.gnu.org
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 5 Mar 2025 10:00:50 -0300
Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> writes:

> Hey everyone.
>
> I found a bug in makefile-mode fontification.
>
> Currently shell-commands/make-instructions within a target may get
> fontified as make-targets if they contain a : (colon) sign.
>
> Consider the following make-target:
>
> ------- Makefile ------
>
> run-docker: build-docker
> docker run -p 8080:8080 imagename
>
> --------------------------
>
> This defined a make-target called "run-docker" which depends on
> "build-docker", which runs the command "docker run -p 8080:8080
> imagename".
>
> In the current code, since the command contains a ":" the whole text up
> to that point ("docker run -p 8080") gets fontified as a make-target, 
even
> though it's clearly not declared at the beginning of the line.
>

Looks like the 10th duplicate of Bug#17400.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Wed, 05 Mar 2025 13:20:01 GMT) Full text and rfc822 format available.

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

From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>,
 "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>
Cc: 76759 <at> debbugs.gnu.org
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 5 Mar 2025 14:19:12 +0100
[Message part 1 (text/plain, inline)]
> From the Makefile format, I think this should not be leading whitespace, but only leading tabs. Leading spaces in rules are a syntax error. Can you check whether \t instead of \s also works?


Good catch, Arne. Will check.

> Looks like the 10th duplicate of Bug#17400.


Also good catch, Mauro. Can someone merge these 2 bugs?

But honestly: A more than 10 year old bug!!! About time we get it fixed!

I'll report back as soon as I have a new patch!

—
Kind Regards
Jostein Kjønigsen

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Wed, 05 Mar 2025 13:29:01 GMT) Full text and rfc822 format available.

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

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
Cc: "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>, 76759 <at> debbugs.gnu.org
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 5 Mar 2025 10:28:17 -0300
merge 17400 76759
quit


Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> writes:

>  Looks like the 10th duplicate of Bug#17400.
>
> Also good catch, Mauro. Can someone merge these 2 bugs?

Thanks for confirming.  Merging the bugs now.

> But honestly: A more than 10 year old bug!!! About time we get it fixed!
>
> I'll report back as soon as I have a new patch!

Thanks for working on this.





Merged 17400 33681 33900 35299 36245 37934 45037 46052 46221 48052 76759. Request was from Mauro Aranda <maurooaranda <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 05 Mar 2025 13:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Wed, 05 Mar 2025 13:30:04 GMT) Full text and rfc822 format available.

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

From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>,
 "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>
Cc: 76759 <at> debbugs.gnu.org,
 "Ergus via Emacs development discussions." <emacs-devel <at> gnu.org>
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Wed, 5 Mar 2025 14:28:49 +0100
[Message part 1 (text/plain, inline)]
Tested with \t and that works too. Attached is a patch containing these changes and which fixes this (these) bug(s).


—
Kind Regards
Jostein Kjønigsen

> On 5 Mar 2025, at 14:19, Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> wrote:
> 
>> From the Makefile format, I think this should not be leading whitespace, but only leading tabs. Leading spaces in rules are a syntax error. Can you check whether \t instead of \s also works?
> 
> 
> Good catch, Arne. Will check.
> 
>> Looks like the 10th duplicate of Bug#17400.
> 
> 
> Also good catch, Mauro. Can someone merge these 2 bugs?
> 
> But honestly: A more than 10 year old bug!!! About time we get it fixed!
> 
> I'll report back as soon as I have a new patch!
> 
> —
> Kind Regards
> Jostein Kjønigsen
> 

[Message part 2 (text/html, inline)]
[0001-Fix-fontification-error-in-makefile-mode.patch (application/octet-stream, attachment)]
[Message part 4 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Sat, 08 Mar 2025 21:55:01 GMT) Full text and rfc822 format available.

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

From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>,
 "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>
Cc: 76759 <at> debbugs.gnu.org,
 "Ergus via Emacs development discussions." <emacs-devel <at> gnu.org>
Subject: Re: [PATCH] 31.0.50; makefile-mode: incorrectly highlights
 make-instructions as make targets
Date: Sat, 8 Mar 2025 22:54:22 +0100
[Message part 1 (text/plain, inline)]
Any news on this one?

Has anyone tested this? Anyone have any objection to the change?

—
Kind Regards
Jostein Kjønigsen

> On 5 Mar 2025, at 14:28, Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> wrote:
> 
> Tested with \t and that works too. Attached is a patch containing these changes and which fixes this (these) bug(s).
> 
> <0001-Fix-fontification-error-in-makefile-mode.patch>
> —
> Kind Regards
> Jostein Kjønigsen
> 
>> On 5 Mar 2025, at 14:19, Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> wrote:
>> 
>>> From the Makefile format, I think this should not be leading whitespace, but only leading tabs. Leading spaces in rules are a syntax error. Can you check whether \t instead of \s also works?
>> 
>> 
>> Good catch, Arne. Will check.
>> 
>>> Looks like the 10th duplicate of Bug#17400.
>> 
>> 
>> Also good catch, Mauro. Can someone merge these 2 bugs?
>> 
>> But honestly: A more than 10 year old bug!!! About time we get it fixed!
>> 
>> I'll report back as soon as I have a new patch!
>> 
>> —
>> Kind Regards
>> Jostein Kjønigsen
>> 
> 

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76759; Package emacs. (Sun, 09 Mar 2025 06:35:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, Paul Smith <psmith <at> gnu.org>
Cc: arne_bab <at> web.de, 76759 <at> debbugs.gnu.org, maurooaranda <at> gmail.com,
 emacs-devel <at> gnu.org
Subject: Re: bug#76759: [PATCH] 31.0.50;
 makefile-mode: incorrectly highlights make-instructions as make
 targets
Date: Sun, 09 Mar 2025 08:34:40 +0200
[Message part 1 (text/plain, inline)]
> Cc: 76759 <at> debbugs.gnu.org,
>  "Ergus via Emacs development discussions." <emacs-devel <at> gnu.org>
> From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
> Date: Sat, 8 Mar 2025 22:54:22 +0100
> 
> Any news on this one?
> 
> Has anyone tested this? Anyone have any objection to the change?

The Makefile syntax is tricky wrt whitespace, and target names can
include colons, definitely on MS-Windows, but also on Posix systems.
Also, there are various old formats, like that of Imakefile, that
should still be supported, AFAIK.  And we don't have a test suite for
this mode.  So I very much wonder whether this change will introduce
regressions.

Maybe Paul Smith, the maintainer of GNU Make (CC'ed), could help us
here.  Or maybe Stefan has comments?  For their convenience, I
re-attach the proposed patch below.

Thanks.

[0001-Fix-fontification-error-in-makefile-mode.patch (text/x-patch, attachment)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:03 GMT) Full text and rfc822 format available.

Notification sent to Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:03 GMT) Full text and rfc822 format available.

Message #33 received at 76759-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
Cc: "Dr. Arne Babenhauserheide" <arne_bab <at> web.de>, "Ergus via Emacs
 development discussions." <emacs-devel <at> gnu.org>,
 Mauro Aranda <maurooaranda <at> gmail.com>, 76759-done <at> debbugs.gnu.org
Subject: Re: bug#76759: [PATCH] 31.0.50; makefile-mode: incorrectly
 highlights make-instructions as make targets
Date: Sun, 09 Mar 2025 22:08:04 -0400
> Any news on this one?

Looks OK, tho I think it's a bit more strict than necessary: the TABs we
need to avoid can be only at the beginning of the line, so not inside
the $(...).

So it's only one of the [^...] that needs the \t.

Here's what I did:

- Start from the current monster:

    "^\\(\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#:=]\\)+?\\)\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)"

- Change the `\\(?:[^({]\\|.` to `\\(?:[^({]\\|[({]` because I think
  the `.` was just an optimization.  And since the two alternatives are
  now mutually exclusive, swap them:

    \\(?:[^({]\\|.[^\n$#})]+?[})]\\)

=>

    \\(?:[({][^\n$#})]+?[})]\\|[^({]\\)

- Now the regexp has become:

    "^\\(\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[({][^\n$#})]+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#:=]\\)+?\\)\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)"

- Make the nested construction explicit, so it's a bit more manageable:

    (letrec ((elems-re
              (lambda (n &optional outer)
                (if (< n 1)
                     "[^\n$#})]+?"
                  (concat "\\(?:\\$\\(?:"
                          "[({]" (funcall elems-re (- n 1)) "[})]"
                          "\\|[^({]\\)"
                          "\\|[^\n$#" (if outer ":=" ")}") "]\\)+?")))))
      (concat
       ;; Allow for two nested levels $(v1:$(v2:$(v3:a=b)=c)=d)
       "^\\(" (funcall elems-re 3 'outer)
       "\\)\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)"))

- Disallow TABs in the outer case by replacing ":=" with "\t:=" (that's
  one of the TABs you added in your version of the patch).

This is still not quite right, since AFAIK TABs are allowed to appear
outside of $(...) as long as they're not at BOL, but I think it's better
than what we've had so far (and the regexp still has several other
limitations anyway).

Pushed to `master`.


        Stefan





Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:04 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:04 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:04 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:04 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:05 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:05 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:05 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:05 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:06 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:06 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:06 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:06 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:07 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:07 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:07 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:07 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:08 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:08 GMT) Full text and rfc822 format available.

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 10 Mar 2025 02:17:08 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Mon, 10 Mar 2025 02:17:09 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, 07 Apr 2025 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 71 days ago.

Previous Next


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