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.
View this message in rfc822 format
From: help-debbugs <at> gnu.org (GNU bug Tracking System) To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net> Subject: bug#76759: closed (Re: bug#76759: [PATCH] 31.0.50; makefile-mode: incorrectly highlights make-instructions as make targets) Date: Mon, 10 Mar 2025 02:17:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report #76759: [PATCH] 31.0.50; makefile-mode: incorrectly highlights make-instructions as make targets which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 76759 <at> debbugs.gnu.org. -- 76759: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76759 GNU Bug Tracking System Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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
[Message part 3 (message/rfc822, inline)]
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 4 (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 5 (text/html, inline)][0001-Fix-fontification-error-in-makefile-mode.patch (application/octet-stream, attachment)][Message part 7 (text/html, inline)]
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.