From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: [PATCH] 27.0.50; font-lock-{append,prepend}-text-property and anonymous faces Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Apr 2019 17:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 35476@debbugs.gnu.org Cc: Stefan Monnier , Nicolas Goaziou X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155647149325534 (code B ref -1); Sun, 28 Apr 2019 17:12:02 +0000 Received: (at submit) by debbugs.gnu.org; 28 Apr 2019 17:11:33 +0000 Received: from localhost ([127.0.0.1]:37713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hKnKt-0006dk-Nd for submit@debbugs.gnu.org; Sun, 28 Apr 2019 13:11:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50288) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hKnKs-0006dY-9S for submit@debbugs.gnu.org; Sun, 28 Apr 2019 13:11:31 -0400 Received: from lists.gnu.org ([209.51.188.17]:56399) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hKnKj-0006zm-PK for submit@debbugs.gnu.org; Sun, 28 Apr 2019 13:11:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKnKh-00009F-Ix for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2019 13:11:21 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKnKd-0006y4-Pt for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2019 13:11:19 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:52459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hKnKb-0006w1-Rl for bug-gnu-emacs@gnu.org; Sun, 28 Apr 2019 13:11:15 -0400 Received: by mail-wm1-x344.google.com with SMTP id j13so10744044wmh.2 for ; Sun, 28 Apr 2019 10:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:cc:date:message-id:mime-version; bh=wcC6teh69ge56jScGNhpt8yWafpcB6oiI6oAALOV0Dg=; b=Ou9280v1Ua18CvZ7PcLzqdQckcccQbYrJVSUdUec5LDAgKdW4E9rcOyik69dwtcjwb z4K4b0UMlycswVyvsM9Ro87XEa2u989WRLKqV37DPvIM6Asi2Z235cfGVSS5Ohstavr1 2OE1DztlADbRxr2VWvP53cgwSCQgTQjbMX9vj5YMtuneIv/0N3OFzPJOCOn4D5Zif1Um X+7M+yPRK65GbsPCt8JC0dAE65SmyhOx4XoYkH5DS01oOTU2/suOB0iOm5GppF6GEwwY 9Tk2ml/YnwP6vAMoXmK9SIC4wbksSSOw+6dikiD1ftbq1nRi5uqvxzT/BCig2YlQCtCQ 4ELw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:cc:date:message-id:mime-version; bh=wcC6teh69ge56jScGNhpt8yWafpcB6oiI6oAALOV0Dg=; b=JTgpFWU7VfNzFzORCzJtn4ZzziGTSGOOOTs3bvYjg0rCiLuZMlZ0zfScADbzSCRqAJ xqNSgg7G/3quMhPkn5KIqthUd5LVYjWmB1sGSxWdke8J/W5Ds8VXdtNRcv2fxk4uky36 PuH6nW0f+t238z5GMjTJc7YsEN3WndElDriFASHtb9UMLboTkRoedYCYgvtXMS2NPZAS 7sl9lBg9iFv7M3FgtEPYCFC24id7NeYDKZCWMMVwzvXi8MSwyPJKDKMb/t2doMgovRYD ZkTzlr5aNlbshGgI1X30eKC09Sw7QVueNWpY7Ap1ZOTGE7237lrA8iZ6/F6M0C2Ennsg 2Htg== X-Gm-Message-State: APjAAAWvTPyoe6vxeJOgk3RX5cFzig/kJrpxGVHD3hRq4MjVO+CLKN2i tOdTSyornyPntRQ6ID4fYRg= X-Google-Smtp-Source: APXvYqwsec+QD3d+BgC6XYD9trTdayFsNsqpuWOXaWHgyBlpNnS2LzMeWEQ/G5OgpAMm5Glke/UOfQ== X-Received: by 2002:a1c:1a90:: with SMTP id a138mr8602293wma.81.1556471471381; Sun, 28 Apr 2019 10:11:11 -0700 (PDT) Received: from nc10-laptop ([109.190.253.11]) by smtp.gmail.com with ESMTPSA id x20sm7396198wrg.29.2019.04.28.10.11.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Apr 2019 10:11:10 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Date: Sun, 28 Apr 2019 19:11:06 +0200 Message-ID: <87lfzu9hsl.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, This is a follow-up to the mails I sent to emacs-orgmode[1] and help-gnu-emacs[2]. tl;dr I believe font-lock-{append,prepend}-text-property do not handle anonymous faces correctly: they splice their attributes, producing lists mixing keyword attributes and named faces such as this one: (:strike-through t org-level-1) The patch I attach changes this to: ((:strike-through t) org-level-1) To summarize my findings: 1. With org.el from Emacs's master branch (commit 88c91f53df), in an Org buffer with a heading such as this one: * *foo* /bar/ _baz_ +quux+ =20=20 foo (resp. bar and baz) show both the heading face and the bold (resp. italic and underline) decoration, whereas quux only shows the strike-through decoration, without the heading face. 2. C-u C-x =3D on quux says: > face (:strike-through t org-level-1) A hasty look at org.el showed that it used `font-lock-prepend-text-property`. I sent a trivial patch to emacs-orgmode which uses `font-lock-append-text-property` instead, although I wasn't sure that it was sound. With this patch, C-u C-x =3D says instead: =20=20=20 > face (org-level-1 :strike-through t) =E2=80=A6 and quux shows both the org-level-1 foreground and the strike-through decoration. 3. On help-gnu-emacs, Stefan confirmed that my patch relies on undefined behavior. 4. Meanwhile, Nicolas applied it to the org-mode repository (commit 42abf5c69). I have now come to the conclusion that a patch such as the one I attached in this report might be more appropriate. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Refrain-from-splicing-anonymous-faces-in-text-proper.patch Content-Transfer-Encoding: quoted-printable >From 7990c65193473784bae6769ae9a2baf233234269 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?K=3DC3=3DA9vin=3D20Le=3D20Gouguec?=3D Date: Sun, 28 Apr 2019 18:48:36 +0200 Subject: [PATCH] Refrain from splicing anonymous faces in text properties MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Otherwise named faces that follow are not displayed anymore. E.g. in an Org buffer with this content: * /foo/ *bar* _baz_ +quux+ Before this commit, the 'face property on quux was: (:strike-through t org-level-1) =E2=80=A6 and the org-level-1 foreground was not displayed. This commit ma= kes the 'face property become: ((:strike-through t) org-level-1) =E2=80=A6 which lets quux display both the strike-through decoration and the org-level-1 foreground. * lisp/font-lock.el (font-lock-append-text-property) (font-lock-prepend-text-property): Wrap anonymous faces in a single-elemnt list so that `append' does not splice them. --- lisp/font-lock.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 1475911195..e0e55d859d 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1392,16 +1392,23 @@ font-lock-prepend-text-property Arguments PROP and VALUE specify the property and value to prepend to the = value already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (listp value) value (list value))) next prev) + (let ((val (if (listp value) value (list value))) + (is-face-prop (memq prop '(face font-lock-face))) + next prev) (while (/=3D start end) (setq next (next-single-property-change start prop object end) prev (get-text-property start prop object)) ;; Canonicalize old forms of face property. - (and (memq prop '(face font-lock-face)) + (and is-face-prop (listp prev) (or (keywordp (car prev)) (memq (car prev) '(foreground-color background-color))) (setq prev (list prev))) + ;; Wrap an anonymous face into a single-element list, so that + ;; `append' does not splice it. + (and is-face-prop + (keywordp (car val)) + (setq val (list val))) (put-text-property start next prop (append val (if (listp prev) prev (list prev))) object) @@ -1412,16 +1419,23 @@ font-lock-append-text-property Arguments PROP and VALUE specify the property and value to append to the v= alue already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (listp value) value (list value))) next prev) + (let ((val (if (listp value) value (list value))) + (is-face-prop (memq prop '(face font-lock-face))) + next prev) (while (/=3D start end) (setq next (next-single-property-change start prop object end) prev (get-text-property start prop object)) ;; Canonicalize old forms of face property. - (and (memq prop '(face font-lock-face)) + (and is-face-prop (listp prev) (or (keywordp (car prev)) (memq (car prev) '(foreground-color background-color))) (setq prev (list prev))) + ;; Wrap an anonymous face into a single-element list, so that + ;; `append' does not splice it. + (and is-face-prop + (keywordp (car val)) + (setq val (list val))) (put-text-property start next prop (append (if (listp prev) prev (list prev)) val) object) --=20 2.20.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I am not an expert on font-lock though, so this patch might not be correct. Also, since I'm on a laptop running on battery power, I don't intend to run make check right now. I am sharing this patch in case someone well-versed in font-lock finds it "obviously correct". If that is the case, I have two more questions for additional patches: 1. Would it make sense to stuff most of these two functions's code into a third function called e.g. font-lock--add-text-property (start end prop value object append) in order to reduce duplication? 2. I guess some new automated tests would be appreciated? Thank you for your time. K=C3=A9vin [1]: http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00101.html [2]: http://lists.gnu.org/archive/html/help-gnu-emacs/2019-04/msg00240.html In GNU Emacs 27.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2019-04-18 built on nc10-laptop Repository revision: a18336a8dc754fa1c68e16dd8009466cf409271b Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.11902000 System Description: BunsenLabs GNU/Linux 9.8 (Helium) Recent messages: Saving file /home/peniblec/drafts/font-lock.md... Wrote /home/peniblec/drafts/font-lock.md Saving file /home/peniblec/drafts/font-lock.md... Wrote /home/peniblec/drafts/font-lock.md Mark set Saving file /home/peniblec/drafts/font-lock.md... Wrote /home/peniblec/drafts/font-lock.md next-line: End of buffer [4 times] Mark set [3 times] Undo! Configured using: 'configure --with-xwidgets' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS XWIDGETS JSON PDUMPER LCMS2 GMP Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Markdown Minor modes in effect: global-magit-file-mode: t magit-file-mode: t magit-auto-revert-mode: t global-git-commit-mode: t async-bytecomp-package-mode: t shell-dirtrack-mode: t show-paren-mode: t minibuffer-depth-indicate-mode: t icomplete-mode: t global-page-break-lines-mode: t page-break-lines-mode: t electric-pair-mode: t diff-hl-flydiff-mode: t global-diff-hl-mode: t diff-hl-mode: t delete-selection-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t auto-fill-function: do-auto-fill visual-line-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow emacsbug dired-aux help-fns radix-tree cl-print debug backtrace flyspell ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff vc-mtn vc-hg org-indent org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view jka-compr image-mode org-bibtex bibtex org-bbdb org-w3m org-element avl-tree generator org org-macro org-footnote org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs org-loaddefs find-func cal-menu calendar cal-loaddefs ispell magit-patch cus-edit whitespace bug-reference diff-hl-dired mailalias smtpmail sendmail nnir markdown-mode rx color thingatpt noutline outline misearch multi-isearch magit-extras executable magit-submodule magit-obsolete magit-blame magit-stash 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 which-func imenu magit-diff smerge-mode magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process magit-mode transient git-commit magit-git magit-section magit-utils crm log-edit pcvs-util add-log with-editor async-bytecomp async shell pcomplete server dash sort gnus-cite mail-extr gnus-async gnus-bcklg qp gnus-ml nndraft nnmh nnfolder utf-7 epa-file gnutls network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap nntp gnus-cache gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec epa derived epg mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search time-date mail-utils mm-util mail-prsvr wid-edit vc-git vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs project delight advice eighters-theme quail cl-extra help-mode rg rg-ibuffer rg-result wgrep-rg wgrep s rg-history rg-header rg-compat ibuf-ext ibuffer ibuffer-loaddefs grep compile comint ansi-color ring edmacro kmacro disp-table paren mb-depth icomplete page-break-lines elec-pair diff-hl-flydiff diff diff-hl vc-dir ewoc vc vc-dispatcher diff-mode easy-mmode delsel cus-start cus-load mule-util tex-site info package easymenu epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 8 340103 79587) (symbols 24 31862 1) (strings 16 105392 12481) (string-bytes 1 3497604) (vectors 8 55552) (vector-slots 4 1313923 80148) (floats 8 495 324) (intervals 28 3532 1391) (buffers 564 52)) --=-=-=-- From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: Test suite References: <87lfzu9hsl.fsf@gmail.com> In-Reply-To: <87lfzu9hsl.fsf@gmail.com> Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Apr 2019 06:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.15566045264293 (code B ref 35476); Tue, 30 Apr 2019 06:09:01 +0000 Received: (at 35476) by debbugs.gnu.org; 30 Apr 2019 06:08:46 +0000 Received: from localhost ([127.0.0.1]:40501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLLwc-00017B-2v for submit@debbugs.gnu.org; Tue, 30 Apr 2019 02:08:46 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]:35145) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLLwZ-00016u-UZ for 35476@debbugs.gnu.org; Tue, 30 Apr 2019 02:08:44 -0400 Received: by mail-wm1-f52.google.com with SMTP id y197so2440338wmd.0 for <35476@debbugs.gnu.org>; Mon, 29 Apr 2019 23:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=e47KIZsE3WwmC1gtZPWsEJ8X0ClVPxyj8vAO4GEl4rk=; b=uOipOhxX8NCW3KhxPaGXOB4JhQXuenifopCkEYV33ZvRZBP4NpOUP5slIfREI9zJdQ j9drBsM5mDEOKFPvhG+F3NE79YfikrtajKMGf6L/F0/fwOvwGSPG9xJlM0rsa0s243Ow RxFW0DYeqgelEDQK+13XHLnUy2R/mYSNu8KURBj2+Ta9tA6RUMbHOcRnfeMnupDVHR7x RS4o9Vcqe3LsRGVB6h694dvJhKCnxtEIn8yb2zyhlWek2gwrx/kPxlzOSFzzMz4V9WXs WhFw0faoKJ55LGP5uXQG0MtoIrv2dDwHbKBxjfrVNJq/QOzJ/mtvtvGY/LOZV3iZ82aY t1ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=e47KIZsE3WwmC1gtZPWsEJ8X0ClVPxyj8vAO4GEl4rk=; b=OfouBmEcLK4wdpXeLUhyA3aFyFLBU1i4tuF8qF7OzLEQtYpSngmfgeIo9OLvvhKaaT 9hYI+Tzs6ThvgHdhIEDCVNY3STV1in1cs3kVkVOn45+ZuvwWwAxrgoFlNBYk1H5GFeoo esPtWqWXy7QkQCZXbJteCYqHxdwnGt7Gg/XU5vB45QJ78V+ELbqvnKfEVooTjbuUiljt I2YSUJerDKb95/IcZkPFaRwliuAPGWEx/U+SPhcgPF02ElmyLkpLWB/c7BbC3V2q44JT mheRNZBwWjieTC5hZc4BPAoVVV36rUXx4tZ9olh9gkp3vIw04lxAnuHW5ok1vhjbgODz fl3A== X-Gm-Message-State: APjAAAXus/IOLv+VliaeQyoBEoZQXr4plhQ90qCnKSA9BbIxFXI39QPp ReZwUuN6PFG3EZ77iSB+ThlziPiu X-Google-Smtp-Source: APXvYqwVrNbW4g/acz3reyPqZU9eUm+/IjHoLrU0a3AyDT+mk8Ak/IaTRa7evyoop26CxVXdGHWRVA== X-Received: by 2002:a7b:c00e:: with SMTP id c14mr525215wmb.110.1556604516946; Mon, 29 Apr 2019 23:08:36 -0700 (PDT) Received: from my-little-tumbleweed (71.142.13.109.rev.sfr.net. [109.13.142.71]) by smtp.gmail.com with ESMTPSA id u8sm1574988wmj.27.2019.04.29.23.08.35 for <35476@debbugs.gnu.org> (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Apr 2019 23:08:35 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Date: Tue, 30 Apr 2019 08:08:33 +0200 Message-ID: <87a7g8owim.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain As part of the discussion on help-gnu-emacs[1], Stefan applied a simpler patch in commit f478082f9f, only for font-lock-prepend-text-property though. Does it make sense to do the same in font-lock-append-text-property? As a learning experience with ERT, I wrote the attached test suite; with the current master branch, only the prepend test passes, the other fails. Applying the same change in font-lock-append-text-property lets both tests pass. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-a-test-suite-for-anonymous-face-handling-in-text.patch >From 7bd1a551de8cef452a7ade7eaa055d38bf3a0800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Tue, 30 Apr 2019 08:00:34 +0200 Subject: [PATCH] Add a test suite for anonymous face handling in text properties * test/lisp/font-lock-tests.el: New test suite. Only font-lock-test-prepend-anonymous-face passes as of f478082f9f. --- test/lisp/font-lock-tests.el | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/lisp/font-lock-tests.el diff --git a/test/lisp/font-lock-tests.el b/test/lisp/font-lock-tests.el new file mode 100644 index 0000000000..ad282f6cad --- /dev/null +++ b/test/lisp/font-lock-tests.el @@ -0,0 +1,43 @@ +;;; font-lock-tests.el --- Test suite for font-lock. -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: +(require 'ert) + +(ert-deftest font-lock-test-append-anonymous-face () + "Ensure `font-lock-append-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-append-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '(italic (:strike-through t)))))) + +(ert-deftest font-lock-test-prepend-anonymous-face () + "Ensure `font-lock-prepend-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-prepend-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '((:strike-through t) italic))))) + +(provide 'font-lock-tests) + +;; font-lock-tests.el ends here -- 2.21.0 --=-=-= Content-Type: text/plain Apologies for posting all over the place. [1]: http://lists.gnu.org/archive/html/help-gnu-emacs/2019-04/msg00289.html --=-=-=-- From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: [BUMP] Some questions before closing Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 May 2019 05:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.155720667819607 (code B ref 35476); Tue, 07 May 2019 05:25:02 +0000 Received: (at 35476) by debbugs.gnu.org; 7 May 2019 05:24:38 +0000 Received: from localhost ([127.0.0.1]:58079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hNsak-00056A-Ck for submit@debbugs.gnu.org; Tue, 07 May 2019 01:24:38 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:33067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hNsai-00055p-Ij for 35476@debbugs.gnu.org; Tue, 07 May 2019 01:24:37 -0400 Received: by mail-wr1-f53.google.com with SMTP id e11so7257005wrs.0 for <35476@debbugs.gnu.org>; Mon, 06 May 2019 22:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-transfer-encoding; bh=V+sPR3uE24dAXGcGRwfJMDv8ed07CG6NOmBBjba2ZHk=; b=ThRByCWupuwJ9nLtdLOV+K2lP9FuTjKkWR6dlKwblcwsowGoz+YjPGRDLC3mI2a2FQ VOrbir2pokJofqeAwUfjNgxFekcbqRyUKUYPr30LimfwN+2y7VwzNztrLzUqzvn+j6o5 3OKe/lX3TUiVO/KC25Oachcb4ZuAGnpmlg4QChRDOkWO+oEv6KAHGnAWqakRGwE4t0Ob K7pUcAF9pG9vownooJ1WNRf+5+OlRfliTC0qBVhaD4dJtjD6qxDngLlHitEA20ul822i 4N/bmGzH1S2dL7FzrtqBXQed/PufGrYu/XPqjePNtUUR98Z9/+cZcwfgKmx2odHRkasR +N4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=V+sPR3uE24dAXGcGRwfJMDv8ed07CG6NOmBBjba2ZHk=; b=PBDKpFDe8RBgu/eFeSl78FGIQg+BRrgAhMIzQWbL6ssRM4WLwwFBabWE0i5WxuEO4G YNI+V79r4k8PWnVPwOLHEt0hKlB6PASgwRoAUXh/kpAPukNdbd7j5YHLdFGXdTNcn5kc e2mh7TL11MtjNvzPQtwQUgqPyQ9JqAFW1qaH65jB4hH99xQ8tD5FYOYunah/2uAYeUix Ct2higfic7VnLAI/lFHBfRV1w+dcpnyEj8TXvzvty6XPX7LgPJZAa3hHczGLez6UwU1O GK7SDAIfezW3naQaJqHPXUWyE3eNF2aWl30S84FaD0A2/L9U/xFnpAqjxBDNFO5qq15Z PAVA== X-Gm-Message-State: APjAAAXdenS2B+fl1uYhlZaqgTSvkE97h6cXu2DFBd2aqTeV0V/9EUs4 OgHGotedy5lG92Rw6VoP6qg/u5hB X-Google-Smtp-Source: APXvYqyh2hPZP4e43cXjWM6tXSIB7+f9xaRv7Wm2C7CvpiBflJwDYwU83CTRXH4Eabl2X/t5REmgew== X-Received: by 2002:adf:f851:: with SMTP id d17mr20257941wrq.312.1557206670603; Mon, 06 May 2019 22:24:30 -0700 (PDT) Received: from nc10-laptop (71.142.13.109.rev.sfr.net. [109.13.142.71]) by smtp.gmail.com with ESMTPSA id k205sm24129282wma.46.2019.05.06.22.24.29 for <35476@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2019 22:24:29 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> Date: Tue, 07 May 2019 07:24:26 +0200 In-Reply-To: <87a7g8owim.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Tue, 30 Apr 2019 08:08:33 +0200") Message-ID: <87ftpqq1kl.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi! Now that Stefan committed a fix to Emacs 27, and Nicolas a workaround to org-mode, this bug report can probably be closed; I just have a few questions left: 1. Shouldn't Stefan's fix also be applied to font-lock-append-text-property? 2. Is it worth adding the test suite I posted in bug#35476#8 to the Emacs repository? Thank your for your time. K=C3=A9vin From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 May 2019 12:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.155766412821527 (code B ref 35476); Sun, 12 May 2019 12:29:01 +0000 Received: (at 35476) by debbugs.gnu.org; 12 May 2019 12:28:48 +0000 Received: from localhost ([127.0.0.1]:42073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPnax-0005b8-Qs for submit@debbugs.gnu.org; Sun, 12 May 2019 08:28:47 -0400 Received: from mail-it1-f171.google.com ([209.85.166.171]:38442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPnaw-0005ar-Ci for 35476@debbugs.gnu.org; Sun, 12 May 2019 08:28:46 -0400 Received: by mail-it1-f171.google.com with SMTP id i63so9414099ita.3 for <35476@debbugs.gnu.org>; Sun, 12 May 2019 05:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=erVLO83jZX63efxzofUK1Mf66G/kk25ZABbF8ajc2h8=; b=kJEbldiFTNWEMKvq0nWzyoyS5Oepj9RGzZopDHBU1U8vmAW/kXtwxlIM3b2RKfqjcN yhjOBtBgMWBZ6I56zv/D+/HFehtO5YhyVD+N2Xg4Y2QO7HY/9DV30zdgcJ/7Ug2Ykk2G kFvkznIAYfuBuL51UVOaVbsLTlEKbgJ0ehQ33mikKDoV0k1YpXVw43eEXB8JKsbrQAjl g614omPQO/tu01tY+XgTtsjG/+JAReKr/hXCY6PVmQ8L4Rn4XM6dcJeJPA+5qqnuPnci +mDO0AvHTevmq3EcfyWlnoCFLKH+Fa061Xu6Yh6KUhY4yPJupe2yItwG+nsxrFSjdAOm XAwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=erVLO83jZX63efxzofUK1Mf66G/kk25ZABbF8ajc2h8=; b=JCh+oYaCMwZjjHE2HgbGXKwntgxbUzxr6oAywX95L9JD79CHEsrsa1HZ/S9IUf+lQw +Vx9jU7afHD5UaCiwd2k/7RGgWRyeVNwZIba6Cx6J85dPvjrQYrTbac8YkrHveVmKwwz 0V1A77teNQbM5zPmj1JlYMUp+8hZdUyyZrdTpVpY5gEUMwQUZymfJl51T1d3jU6hhrbv VBKpiK3cQRX9Ihl+KQib0edK8s3uMSqRV1LLeHUIzi4smL3v9CUFqiLnNMzZcDjvHvQU JRzGQBmG4+QLeU5tkuHT3uD+3xYh7xCHcphoQWlWTiFshuhKqySRXEr0WkGUhHg05Amr 5CLQ== X-Gm-Message-State: APjAAAW0KifaaQN5F7xOQhAFYY3wz0OUhmQO+0tl9IL14t3QEWfYHaCS 9g3uK6fDqkTmCXXHpUV4+FuZIRyQ X-Google-Smtp-Source: APXvYqy53Lqy/u/7KeNgkX9Obru1Y1y2GwKZ5qsDZuSVuG5eWUdTfKReAWwjans0eG1HHe5/+ev+xQ== X-Received: by 2002:a02:2b1d:: with SMTP id h29mr14947506jaa.76.1557664120402; Sun, 12 May 2019 05:28:40 -0700 (PDT) Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id q72sm2147050ita.26.2019.05.12.05.28.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 May 2019 05:28:39 -0700 (PDT) From: Noam Postavsky References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> Date: Sun, 12 May 2019 08:28:39 -0400 In-Reply-To: <87ftpqq1kl.fsf_-_@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Tue, 07 May 2019 07:24:26 +0200") Message-ID: <87a7frj1qg.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) K=C3=A9vin Le Gouguec writes: > Now that Stefan committed a fix to Emacs 27, and Nicolas a workaround > to org-mode, this bug report can probably be closed; I just have a few > questions left: > > 1. Shouldn't Stefan's fix also be applied to > font-lock-append-text-property? > > 2. Is it worth adding the test suite I posted in bug#35476#8 to the > Emacs repository? I'd say the answers are yes and yes. So would you mind adding the fix for font-lock-append-text-property to your patch? From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 May 2019 17:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Noam Postavsky Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.155768246127937 (code B ref 35476); Sun, 12 May 2019 17:35:01 +0000 Received: (at 35476) by debbugs.gnu.org; 12 May 2019 17:34:21 +0000 Received: from localhost ([127.0.0.1]:43228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPsMb-0007GT-W2 for submit@debbugs.gnu.org; Sun, 12 May 2019 13:34:21 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]:38506) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPsMZ-0007GG-Lj for 35476@debbugs.gnu.org; Sun, 12 May 2019 13:34:16 -0400 Received: by mail-wm1-f41.google.com with SMTP id f2so11541408wmj.3 for <35476@debbugs.gnu.org>; Sun, 12 May 2019 10:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=eXGXRA1oEe1xo+uVCGTrXmkDOFvA+1j28cSxSueyQzI=; b=kr4Ae2paaUOgf7sDQAiH5gfASv5tL2UaFSFaVxq/yn4ox+4c9DfGXYOwKbbpgKN4D2 aY+Seo8ttFORFskNFLbhitbhEzKk4WnWVqD+gGRDkabm0FE6Jnp8YummRwTSWB/s1Um0 /MBabCQobVVHDU+cYSjAczLa2sWyLd3dFn3+ke+joWYhYql9h3NsWuIDZuq322K1U5oN n8nOZpUZU+lPOalcXnZ/g0B6qpiClw8iwrHXMWudNxji5cdJ5chJnlAug9kaPO9ovYvL eqcpJnD8ppb7oczfslusbSYNLXim6K8+7j5m1f9qkReHwvljShLF3XA0BIta8yOKX7L+ Ef9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=eXGXRA1oEe1xo+uVCGTrXmkDOFvA+1j28cSxSueyQzI=; b=lXZPggAE+Tbhn4CsvpLM6Yhd5l87Elj89ZviDZZJOUu1gzIhFQxCDGX+mrSrGvz9eA TXGPPFX5jIi/db0w1Isw0zPuIofaJ+G250djyLScsJkuHMx/0hZ0zgjmJ3NzNpb0eTTT w3+y4kqJmVsYJgi/iFjmbTdWXc9CcFExgw9cjfg/pgYIVg6t3zf/Tg93Bm5Q96a6Q2fk f09WDav5QzOpSYSg74jT6gJJFXczLhIruj9ssR5s30EdSmBE0MAo1nC20wtuUqRlmON7 Wd88mFts0KaRsKrO/EC8kxQaIzCx7ntEttyDTGmZ2j30yKb+gkZIIYbBGfi1+0aJOtI0 ddrA== X-Gm-Message-State: APjAAAVDDc8QsPSSoYeKgWW+z6k9AuYMYXAV1V3DBSHTSJ+fZsbVR1iK VgHWfXO13q4XpUjjiPL4hKv3DqPK X-Google-Smtp-Source: APXvYqzrGTJF539K51oH55xUat95U3EaiLazcU5vOcIyKWTagHNnpo5tBMMKnNT2avHtR0vsCMfP5g== X-Received: by 2002:a1c:20c9:: with SMTP id g192mr12878102wmg.76.1557682449596; Sun, 12 May 2019 10:34:09 -0700 (PDT) Received: from nc10-laptop ([109.190.253.11]) by smtp.gmail.com with ESMTPSA id d17sm7713955wrw.73.2019.05.12.10.34.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 May 2019 10:34:08 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> <87a7frj1qg.fsf_-_@gmail.com> Date: Sun, 12 May 2019 19:34:01 +0200 In-Reply-To: <87a7frj1qg.fsf_-_@gmail.com> (Noam Postavsky's message of "Sun, 12 May 2019 08:28:39 -0400") Message-ID: <87d0knshkm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Noam Postavsky writes: > K=C3=A9vin Le Gouguec writes: > >> Now that Stefan committed a fix to Emacs 27, and Nicolas a workaround >> to org-mode, this bug report can probably be closed; I just have a few >> questions left: >> >> 1. Shouldn't Stefan's fix also be applied to >> font-lock-append-text-property? >> >> 2. Is it worth adding the test suite I posted in bug#35476#8 to the >> Emacs repository? > > I'd say the answers are yes and yes. So would you mind adding the fix > for font-lock-append-text-property to your patch? Fix and test suite: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Stop-splicing-anonymous-faces-in-font-lock-append-te.patch >From f5a4ad71152bee3c2ad15aa4d08b625d61bc6e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 May 2019 18:36:09 +0200 Subject: [PATCH 1/2] Stop splicing anonymous faces in font-lock-append-text-property This is the same fix as f478082, which was only applied to font-lock-prepend-text-property. * lisp/font-lock.el (font-lock-append-text-property): Distinguish list of faces from property list. * test/lisp/font-lock-tests.el: New test suite. (Bug#35476) --- lisp/font-lock.el | 7 +++++- test/lisp/font-lock-tests.el | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 test/lisp/font-lock-tests.el diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 7ff4e606fa..95ca2f99c2 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1417,7 +1417,12 @@ font-lock-append-text-property Arguments PROP and VALUE specify the property and value to append to the value already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (listp value) value (list value))) next prev) + (let ((val (if (and (listp value) (not (keywordp (car value)))) + ;; Already a list of faces. + value + ;; A single face (e.g. a plist of face properties). + (list value))) + next prev) (while (/= start end) (setq next (next-single-property-change start prop object end) prev (get-text-property start prop object)) diff --git a/test/lisp/font-lock-tests.el b/test/lisp/font-lock-tests.el new file mode 100644 index 0000000000..ad282f6cad --- /dev/null +++ b/test/lisp/font-lock-tests.el @@ -0,0 +1,43 @@ +;;; font-lock-tests.el --- Test suite for font-lock. -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: +(require 'ert) + +(ert-deftest font-lock-test-append-anonymous-face () + "Ensure `font-lock-append-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-append-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '(italic (:strike-through t)))))) + +(ert-deftest font-lock-test-prepend-anonymous-face () + "Ensure `font-lock-prepend-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-prepend-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '((:strike-through t) italic))))) + +(provide 'font-lock-tests) + +;; font-lock-tests.el ends here -- 2.20.1 --=-=-= Content-Type: text/plain Further refactoring (not really necessary; feel free to close the report without applying): --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Extract-common-code-for-adding-text-properties.patch >From c53e415941e67cd227902b5998e40b7ef88acedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 May 2019 18:55:01 +0200 Subject: [PATCH 2/2] Extract common code for adding text properties * lisp/font-lock.el (font-lock--add-text-property): New function. (font-lock-prepend-text-property) (font-lock-append-text-property): Use it. (Bug#35476) --- lisp/font-lock.el | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 95ca2f99c2..6be765d563 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1387,11 +1387,13 @@ font-lock-fontify-block ;; below and given a `font-lock-' prefix. Those that are not used are defined ;; in Lisp below and commented out. sm. -(defun font-lock-prepend-text-property (start end prop value &optional object) - "Prepend to one property of the text from START to END. -Arguments PROP and VALUE specify the property and value to prepend to the value -already in place. The resulting property values are always lists. -Optional argument OBJECT is the string or buffer containing the text." +(defun font-lock--add-text-property (start end prop value object append) + "Add an element to a property of the text from START to END. +Arguments PROP and VALUE specify the property and value to add to +the value already in place. The resulting property values are +always lists. Argument OBJECT is the string or buffer containing +the text. If argument APPEND is non-nil, VALUE will be appended, +otherwise it will be prepended." (let ((val (if (and (listp value) (not (keywordp (car value)))) ;; Already a list of faces. value @@ -1407,35 +1409,25 @@ font-lock-prepend-text-property (or (keywordp (car prev)) (memq (car prev) '(foreground-color background-color))) (setq prev (list prev))) - (put-text-property start next prop - (append val (if (listp prev) prev (list prev))) - object) + (let ((new-value (if append + (append (if (listp prev) prev (list prev)) val) + (append val (if (listp prev) prev (list prev)))))) + (put-text-property start next prop new-value object)) (setq start next)))) +(defun font-lock-prepend-text-property (start end prop value &optional object) + "Prepend to one property of the text from START to END. +Arguments PROP and VALUE specify the property and value to prepend to the value +already in place. The resulting property values are always lists. +Optional argument OBJECT is the string or buffer containing the text." + (font-lock--add-text-property start end prop value object nil)) + (defun font-lock-append-text-property (start end prop value &optional object) "Append to one property of the text from START to END. Arguments PROP and VALUE specify the property and value to append to the value already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (and (listp value) (not (keywordp (car value)))) - ;; Already a list of faces. - value - ;; A single face (e.g. a plist of face properties). - (list value))) - next prev) - (while (/= start end) - (setq next (next-single-property-change start prop object end) - prev (get-text-property start prop object)) - ;; Canonicalize old forms of face property. - (and (memq prop '(face font-lock-face)) - (listp prev) - (or (keywordp (car prev)) - (memq (car prev) '(foreground-color background-color))) - (setq prev (list prev))) - (put-text-property start next prop - (append (if (listp prev) prev (list prev)) val) - object) - (setq start next)))) + (font-lock--add-text-property start end prop value object t)) (defun font-lock-fillin-text-property (start end prop value &optional object) "Fill in one property of the text from START to END. -- 2.20.1 --=-=-= Content-Type: text/plain Both patches were only "lightly" tested, i.e. by C-x C-e'ing every function and test, then calling ert-run-tests-interactively; AFAICT the tests pass[1]. Haven't run a full 'make check' yet (M-: insert-excuse 'battery); I don't think anything broke when Stefan committed the fix to font-lock-prepend-text-property though. Still pretty new to this, so let me know if I messed up anything (e.g. commit message format, conventions when adding files, functions or tests). Thank you for your time. [1] Although running 'make lisp/font-lock-tests' in the test/ folder fails on the append test. Could it be that the Makefile runs the tests against the old font-lock.el that is installed on my system, rather than the new one in my repository? I took a look at the test_template in test/Makefile, but I could not understand what the machinery loads at a glance. --=-=-=-- From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 May 2019 19:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.15576881864830 (code B ref 35476); Sun, 12 May 2019 19:10:02 +0000 Received: (at 35476) by debbugs.gnu.org; 12 May 2019 19:09:46 +0000 Received: from localhost ([127.0.0.1]:43325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPtqz-0001Fp-L3 for submit@debbugs.gnu.org; Sun, 12 May 2019 15:09:46 -0400 Received: from mail-it1-f174.google.com ([209.85.166.174]:40890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPtqx-0001Fb-MM for 35476@debbugs.gnu.org; Sun, 12 May 2019 15:09:44 -0400 Received: by mail-it1-f174.google.com with SMTP id g71so17006457ita.5 for <35476@debbugs.gnu.org>; Sun, 12 May 2019 12:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=VfPS7JGFOI/Ei2myOCn6KZv3fMdcydBVX5vHpoe+V24=; b=qVXeD/TTM7WTTIRQ8/OyaWKHulUEpPubMj0cbkKNLUaIRDkiqD/a7ORJMF1QMUFhbC HuIlBrtWOzWRn62CCpMi3T/HN0oYiJ9JwYYWSgtowp+Y06MOgu1PkLVd8Ef8BMYjeXlJ OA11wsTJ3yJvDG9VF04Xx7Z1Fc+5myDTm9VgJV93EQDycHuGW8PfyKNtdLsEH1c+8MK2 UTjtAkIilxwvUQjsQe+inzYM8fzZja2gAap4J5+Ks2TX3vf6uz92nsfZmMbja3d5OLNy GYLetFyiVKEQIJmq791y0g0QtGWj5Y2m8WOC657Je1SAXwjgsYAoEtu4smi/1bGOxad9 28Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=VfPS7JGFOI/Ei2myOCn6KZv3fMdcydBVX5vHpoe+V24=; b=IIRTBtJYRJiYrkEgeCuwDu2An2iDmONdIsZ3Xt4Oy48Zo9d3rayAkg1qDrAx2YnqvL +K0OAqnhJqjNC7uuYb6mPyAaq3aNWvPE4nHZXpM7F0CSpma50UvEvB64CroioMmlG5Mb xaJ5CgI0CS3PIni+T7TxKr4iKtq7pUZjFF2+CejRKU82w00Mgo+ZLDAYayPuYXY9z6Bd na2yc1qtYDE+vtJ5miqisZ0tgxr/tFKUuI/4/yviPt93vErMsyxyat3ma6YYnMcDMuy/ 66oq/BiXhYNZujZEKVcE8rnKF/sylTql6I7yQTgTD4Jai5UfTvhwpJdTeokdGgzeUDTH vvfg== X-Gm-Message-State: APjAAAUuvDBBr0PvYG/yw/pCB8Ogzm+zzUPfjwGp4V3pv5mYzjbK5bU+ gMdeQM28cCERK8DCJDkrAJujh7yN X-Google-Smtp-Source: APXvYqw1jCYNrqHuc+8HQM9gHZo1RDDNLrw9rGOiO5yh7Ybvf17eBJBIE+fufrat59XWoemixiNsGA== X-Received: by 2002:a24:9414:: with SMTP id j20mr14983626ite.91.1557688178006; Sun, 12 May 2019 12:09:38 -0700 (PDT) Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id x74sm5401616itb.33.2019.05.12.12.09.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 May 2019 12:09:37 -0700 (PDT) From: Noam Postavsky References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> <87a7frj1qg.fsf_-_@gmail.com> <87d0knshkm.fsf@gmail.com> Date: Sun, 12 May 2019 15:09:36 -0400 In-Reply-To: <87d0knshkm.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Sun, 12 May 2019 19:34:01 +0200") Message-ID: <87pnonh4lr.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Looks basically good, I just have a few nitpicks below. > Subject: [PATCH 1/2] Stop splicing anonymous faces in > font-lock-append-text-property > > This is the same fix as f478082, which was only applied to It's best to avoid using hashes in commit messages, as they're translated to ChangeLog files which might read from the tarball (i.e., without a git repo to hand). CONTRIBUTE talks about using "action stamps" but I think date+title is more readable. Which would be: 2019-04-29 "Refrain from splicing anonymous faces in text properties". > +(provide 'font-lock-tests) I don't think there is any reason to `provide' a feature in a test file (I know some other test files do that, but I don't see why), test files are generally not loaded via require. > Subject: [PATCH 2/2] Extract common code for adding text properties > + (let ((new-value (if append > + (append (if (listp prev) prev (list prev)) val) > + (append val (if (listp prev) prev (list prev)))))) I would suggest to factor out the (if (listp prev) prev (list prev)) from these expressions. From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 May 2019 21:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Noam Postavsky Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.155769790328424 (code B ref 35476); Sun, 12 May 2019 21:52:01 +0000 Received: (at 35476) by debbugs.gnu.org; 12 May 2019 21:51:43 +0000 Received: from localhost ([127.0.0.1]:43559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPwNi-0007ON-ME for submit@debbugs.gnu.org; Sun, 12 May 2019 17:51:43 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:34385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPwNg-0007O7-Ve for 35476@debbugs.gnu.org; Sun, 12 May 2019 17:51:41 -0400 Received: by mail-wr1-f42.google.com with SMTP id f8so3423534wrt.1 for <35476@debbugs.gnu.org>; Sun, 12 May 2019 14:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=aQX1Wm4HdyaSZaJ26eKAkCeGNaOKr6iKk5ySRjxq5iA=; b=u+0sNThmi/jJN7Z2bWerryAjVa6Q+fTlNSoF39lrVr//7KeuuYB0wu56jNU4xBrUgM nycSHqKei8PqqiUYS98RtHG+TsCSaf9UFHQp/yLHUp/Nj0zyZlTBOFjT3G1zfSD1FnJj ykRI95va3CU1cnLODGNHOuRYyckbue/BrJ1YL2jI1YLvvE/Ikh4L14gt/mCZRHf1yFKP N9ouwynhW3x52638W1fSdRnOcaoB8vArw896Dy+lRvNU5p/GfdhRDYAzAnj0Vd18RPtr LkwNaxNCeljWzQjoAce6J3Tg4hV4MLO/ciYGRMK8XSrQsuSgaOuAGMuw5e/Vivw3Brwd xxew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=aQX1Wm4HdyaSZaJ26eKAkCeGNaOKr6iKk5ySRjxq5iA=; b=PCgpvHZtRwcOcYPm7GcKBTfULSS9JvmBaDLNeJy7nMduAep7Vgy7SPqqXj4e9bmS3W TTF1c9dVYVjObd3eidPveK5rjywAQQg0ymU+hWckEWVkTqt0ES3V/viP8jZJKKSP52Ja weqQbYdiSIISKB4//Be6tTgzcLO+EPNDFmthsT9QIkrI2a0hX1lDflH2Ua8mFTIVQeyz K2aGaUWORAHnzVr15Xh3lUBtk/PxDA7wi8eqgv9glOwti1aSXL6Qp/x4mx5XeMctJWCt vqV4WvR/74E39qeLl/v4mOQCacAJbpTXdJx0sEuzFgek5iY7XDqoKPKMNcMRmj0x/Ht5 u/sg== X-Gm-Message-State: APjAAAVW9llQJ+HW9hTgd/+FIUZd1CNMnGKrJXDsJEKxH4Z2FrWfnidi RyK1+UoDIOR9r4qfg7/2Q27+nDxP X-Google-Smtp-Source: APXvYqxYLIezQbnky0T9HrCLmxN2H7azFfNZWmiR8poFEbWvxe/DFs4+AI2Gz1YsZOTvwzkJKC06vw== X-Received: by 2002:a5d:4d11:: with SMTP id z17mr11825658wrt.308.1557697893621; Sun, 12 May 2019 14:51:33 -0700 (PDT) Received: from my-little-tumbleweed (71.142.13.109.rev.sfr.net. [109.13.142.71]) by smtp.gmail.com with ESMTPSA id d6sm11589694wrp.9.2019.05.12.14.51.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 May 2019 14:51:32 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> <87a7frj1qg.fsf_-_@gmail.com> <87d0knshkm.fsf@gmail.com> <87pnonh4lr.fsf@gmail.com> Date: Sun, 12 May 2019 23:51:29 +0200 In-Reply-To: <87pnonh4lr.fsf@gmail.com> (Noam Postavsky's message of "Sun, 12 May 2019 15:09:36 -0400") Message-ID: <87tvdz8hpa.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Noam Postavsky writes: > It's best to avoid using hashes in commit messages, as they're > translated to ChangeLog files which might read from the tarball (i.e., > without a git repo to hand). CONTRIBUTE talks about using "action > stamps" but I think date+title is more readable. Which would be: > 2019-04-29 "Refrain from splicing anonymous faces in text properties". Ah, right, didn't think of the children^WChangeLog. I went for date+title. =20=20 Can e.g. git-show(1) understand action stamps? I glanced at gitrevisions(7) but nothing suggests Git knows anything about this format. It sure would make a hypothetical vc-revision-at-point command easier to implement=E2=80=A6 (Or, going the opposite route, maybe the git-log-to-ChangeLog machinery could translate hashes to action stamps?) >> +(provide 'font-lock-tests) > > I don't think there is any reason to `provide' a feature in a test file > (I know some other test files do that, but I don't see why), test files > are generally not loaded via require. Done. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Stop-splicing-anonymous-faces-in-font-lock-append-te.patch >From 6a0a431fb0ed7ccfe27daf853eed48ac73017e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 May 2019 18:36:09 +0200 Subject: [PATCH 1/2] Stop splicing anonymous faces in font-lock-append-text-property This is the same fix as 2019-04-29 "Refrain from splicing anonymous faces in text properties", which was only applied to font-lock-prepend-text-property. * lisp/font-lock.el (font-lock-append-text-property): Distinguish list of faces from property list. * test/lisp/font-lock-tests.el: New test suite. (Bug#35476) --- lisp/font-lock.el | 7 +++++- test/lisp/font-lock-tests.el | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/lisp/font-lock-tests.el diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 7ff4e606fa..95ca2f99c2 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1417,7 +1417,12 @@ font-lock-append-text-property Arguments PROP and VALUE specify the property and value to append to the value already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (listp value) value (list value))) next prev) + (let ((val (if (and (listp value) (not (keywordp (car value)))) + ;; Already a list of faces. + value + ;; A single face (e.g. a plist of face properties). + (list value))) + next prev) (while (/= start end) (setq next (next-single-property-change start prop object end) prev (get-text-property start prop object)) diff --git a/test/lisp/font-lock-tests.el b/test/lisp/font-lock-tests.el new file mode 100644 index 0000000000..5d127039ff --- /dev/null +++ b/test/lisp/font-lock-tests.el @@ -0,0 +1,41 @@ +;;; font-lock-tests.el --- Test suite for font-lock. -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: +(require 'ert) + +(ert-deftest font-lock-test-append-anonymous-face () + "Ensure `font-lock-append-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-append-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '(italic (:strike-through t)))))) + +(ert-deftest font-lock-test-prepend-anonymous-face () + "Ensure `font-lock-prepend-text-property' does not splice anonymous faces." + (with-temp-buffer + (insert "foo") + (add-text-properties 1 3 '(face italic)) + (font-lock-prepend-text-property 1 3 'face '(:strike-through t)) + (should (equal (get-text-property 1 'face (current-buffer)) + '((:strike-through t) italic))))) + +;; font-lock-tests.el ends here -- 2.21.0 --=-=-= Content-Type: text/plain >> Subject: [PATCH 2/2] Extract common code for adding text properties > >> + (let ((new-value (if append >> + (append (if (listp prev) prev (list prev)) val) >> + (append val (if (listp prev) prev (list prev)))))) > > I would suggest to factor out the (if (listp prev) prev (list prev)) > from these expressions. And done. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Extract-common-code-for-adding-text-properties.patch >From bd45ee71a3880e681f637ea6a2b11fd9e06e51ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 May 2019 18:55:01 +0200 Subject: [PATCH 2/2] Extract common code for adding text properties * lisp/font-lock.el (font-lock--add-text-property): New function. (font-lock-prepend-text-property) (font-lock-append-text-property): Use it. (Bug#35476) --- lisp/font-lock.el | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 95ca2f99c2..3991a4ee8e 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1387,11 +1387,13 @@ font-lock-fontify-block ;; below and given a `font-lock-' prefix. Those that are not used are defined ;; in Lisp below and commented out. sm. -(defun font-lock-prepend-text-property (start end prop value &optional object) - "Prepend to one property of the text from START to END. -Arguments PROP and VALUE specify the property and value to prepend to the value -already in place. The resulting property values are always lists. -Optional argument OBJECT is the string or buffer containing the text." +(defun font-lock--add-text-property (start end prop value object append) + "Add an element to a property of the text from START to END. +Arguments PROP and VALUE specify the property and value to add to +the value already in place. The resulting property values are +always lists. Argument OBJECT is the string or buffer containing +the text. If argument APPEND is non-nil, VALUE will be appended, +otherwise it will be prepended." (let ((val (if (and (listp value) (not (keywordp (car value)))) ;; Already a list of faces. value @@ -1407,35 +1409,26 @@ font-lock-prepend-text-property (or (keywordp (car prev)) (memq (car prev) '(foreground-color background-color))) (setq prev (list prev))) - (put-text-property start next prop - (append val (if (listp prev) prev (list prev))) - object) + (let* ((list-prev (if (listp prev) prev (list prev))) + (new-value (if append + (append list-prev val) + (append val list-prev)))) + (put-text-property start next prop new-value object)) (setq start next)))) +(defun font-lock-prepend-text-property (start end prop value &optional object) + "Prepend to one property of the text from START to END. +Arguments PROP and VALUE specify the property and value to prepend to the value +already in place. The resulting property values are always lists. +Optional argument OBJECT is the string or buffer containing the text." + (font-lock--add-text-property start end prop value object nil)) + (defun font-lock-append-text-property (start end prop value &optional object) "Append to one property of the text from START to END. Arguments PROP and VALUE specify the property and value to append to the value already in place. The resulting property values are always lists. Optional argument OBJECT is the string or buffer containing the text." - (let ((val (if (and (listp value) (not (keywordp (car value)))) - ;; Already a list of faces. - value - ;; A single face (e.g. a plist of face properties). - (list value))) - next prev) - (while (/= start end) - (setq next (next-single-property-change start prop object end) - prev (get-text-property start prop object)) - ;; Canonicalize old forms of face property. - (and (memq prop '(face font-lock-face)) - (listp prev) - (or (keywordp (car prev)) - (memq (car prev) '(foreground-color background-color))) - (setq prev (list prev))) - (put-text-property start next prop - (append (if (listp prev) prev (list prev)) val) - object) - (setq start next)))) + (font-lock--add-text-property start end prop value object t)) (defun font-lock-fillin-text-property (start end prop value &optional object) "Fill in one property of the text from START to END. -- 2.21.0 --=-=-= Content-Type: text/plain Thank you for the review! Let me know if there are further nits to pick. --=-=-=-- From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 May 2019 01:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.1557795706643 (code B ref 35476); Tue, 14 May 2019 01:02:02 +0000 Received: (at 35476) by debbugs.gnu.org; 14 May 2019 01:01:46 +0000 Received: from localhost ([127.0.0.1]:46658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQLpC-0000AI-G8 for submit@debbugs.gnu.org; Mon, 13 May 2019 21:01:46 -0400 Received: from mail-io1-f44.google.com ([209.85.166.44]:38188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQLp7-00009n-AE; Mon, 13 May 2019 21:01:41 -0400 Received: by mail-io1-f44.google.com with SMTP id x24so4208774ion.5; Mon, 13 May 2019 18:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=Ss+16aKfmjKAp3yMw0M0zJo07MRe2mraZKZyVS4MO20=; b=f/87kGGJkUOoQHZ4dYfz74+D7WetJceDUKkoT4EWCL2fpU22c5rcjgkvRWEs1FFlda 84wVExDuFQBayq855vHa5+RvSQE6Q1MUixv60LVNZ57eI/4nsYU8cyaZAlpj+tJTSZHR +7WNSwazYSrQspDCHQ5X6T79wofTeqfLSEDL824NwjzL/bEZjSIdEh01rHbzoRMG3FkY ve1OvfCeqbbrTVoINDaIFvpddIJX95nHH87UlgbzewXuM4puc2BMqp2wJAOrZ0y0bmzg jg5nRL2zmQ098XKg5oJqD51WLzhkZRvXlJkIk/qWGNS4n9p2e+A99ww564LxYmdhM5JS 6Kfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=Ss+16aKfmjKAp3yMw0M0zJo07MRe2mraZKZyVS4MO20=; b=ZQTm/p8PU0s+d1ebHd0T8dC+CN0TcbjPkaOeEijhzYj/XDKi8cno+N5hPg7kpmSuT4 phoQgZjfuoNjAjCAJVe3BY4hEyswR4lzZ/kt0MgbXp2CACXI6LLGoKia6eXGjmKJ11Tp 9MIM5y3MOfGu1SuplNwxuuc8+bWRNuhg4LEXMkXlOYEHX4r5RihlSN/ZtRT875AA7FOB zgNmVZaCAZ3rcA7ij8aUbG77dgZiI0VvWcnNlhefepbzVU1Ro+ijm8dI/zF2SLpfZUPm CVjBWzl88AmiGAvcW3FQAwJLEyaVeFJkV47CeafohBJHHl0SW2T5jevLFQbrsO4A+A/8 iRpA== X-Gm-Message-State: APjAAAXfxcWHfuUe/eZb0qkUoD6ssVxNctH17j46U9YsPssvI2nE2QJQ n5GpAVFU8RJgEqct69sQxZmHzWUz X-Google-Smtp-Source: APXvYqxcf5sF2bah7LV/gQrjkeR1V+uQEqlST/BayGknxZ4aUVHMHMxMbpVnQzT5afkRfsaSy4+pkA== X-Received: by 2002:a6b:8bc8:: with SMTP id n191mr17028622iod.86.1557795695256; Mon, 13 May 2019 18:01:35 -0700 (PDT) Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id t63sm591637ita.42.2019.05.13.18.01.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 18:01:34 -0700 (PDT) From: Noam Postavsky References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> <87a7frj1qg.fsf_-_@gmail.com> <87d0knshkm.fsf@gmail.com> Date: Mon, 13 May 2019 21:01:33 -0400 In-Reply-To: <87d0knshkm.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Sun, 12 May 2019 19:34:01 +0200") Message-ID: <87v9ydg87m.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 35476 fixed close 35476 27.1 quit K=C3=A9vin Le Gouguec writes: > [1] Although running 'make lisp/font-lock-tests' in the test/ folder > fails on the append test. Could it be that the Makefile runs the > tests against the old font-lock.el that is installed on my system, > rather than the new one in my repository? I took a look at the > test_template in test/Makefile, but I could not understand what the > machinery loads at a glance. I forgot to answer this before. There's two issues here: 1. The default value of load-prefer-newer means that of you change a .el file without recompiling it, Emacs will load the .elc file instead. 2. For font-lock.el in particular, it's preloaded, so even if you recompile it, font-lock.elc isn't loaded again, you need to redump Emacs. So generally, the way to test changes is make && make -C test font-lock-tests Although it should also work to load the modified .el file explicitly (untested, but): make -C test EMACS_EXTRAOPT=3D'-l font-lock.el' font-lock-tests >> It's best to avoid using hashes in commit messages, as they're >> translated to ChangeLog files which might read from the tarball (i.e., >> without a git repo to hand). CONTRIBUTE talks about using "action >> stamps" but I think date+title is more readable. Which would be: >> 2019-04-29 "Refrain from splicing anonymous faces in text properties". > > Ah, right, didn't think of the children^WChangeLog. :D =20=20 > Can e.g. git-show(1) understand action stamps? I glanced at > gitrevisions(7) but nothing suggests Git knows anything about this > format. I don't think so. The last time I brought this up on emacs-devel there was some suggestion that cgit (a git web frontend) would learn to recognize them eventually, but I'm not sure if anything is really moving in that direction. > (Or, going the opposite route, maybe the git-log-to-ChangeLog machinery > could translate hashes to action stamps?) Maybe, although personally, as a human reader, I prefer date+title to both hashes and action stamps, even when reading from git. Yes, it's quicker to find a commit given a hash, but that still requires at least pressing RET or clicking or something like that. Quite often, just seeing the title is enough to understand what's meant and I don't need to dig further. > Thank you for the review! Let me know if there are further nits to > pick. I think we're good here, pushed to master. 417c52b0b7 2019-05-13T20:41:02-04:00 "Extract common code for adding text p= roperties" https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3D417c52b0b7fbf5cb02= d229e81b7aaaacf2082bde 59ad303e8f 2019-05-13T20:41:02-04:00 "Stop splicing anonymous faces in font= -lock-append-text-property" https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3D59ad303e8f3bb174ce= 326c76a9e7649f602120db From unknown Fri Jun 13 11:31:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35476: font-lock-{append, prepend}-text-property and anonymous faces Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 May 2019 06:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35476 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch fixed To: Noam Postavsky Cc: 35476@debbugs.gnu.org Received: via spool by 35476-submit@debbugs.gnu.org id=B35476.155781367720981 (code B ref 35476); Tue, 14 May 2019 06:02:02 +0000 Received: (at 35476) by debbugs.gnu.org; 14 May 2019 06:01:17 +0000 Received: from localhost ([127.0.0.1]:46933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQQV3-0005SK-C5 for submit@debbugs.gnu.org; Tue, 14 May 2019 02:01:17 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:51704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQQV1-0005S7-G5 for 35476@debbugs.gnu.org; Tue, 14 May 2019 02:01:16 -0400 Received: by mail-wm1-f42.google.com with SMTP id o189so1435846wmb.1 for <35476@debbugs.gnu.org>; Mon, 13 May 2019 23:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=DiTd2397WgI6ec83YrNyvbx/KeDyWQ32fCmmCWD/hWA=; b=Uw7/X+TZgEGD4x2N3JQAXkQUpXRMx/+kZcCLzZaiGQIzLpAkPScmOu7SmeMCmlH1ss WjIPSMd2sSDALVVH1s3XlPULIXVuFGdSqNCmwsAajvQvRJYb5WDP32qWp7UDxIW2LQH4 /rHLnomsoqsg2xdhP9p8abxC3OfXjn9q7zg5mcRU9pvjWmKjbuMRZfEV8VwxCenvkjOF CNrb9TNNU8EtI/3Fu+cMVHghPSdg4/t6KxgPWMUYruo1pFYRslFyVxOxHYKZopZWXpBR 7lwpwSSFme68aPinb1wozHG2WbffWLr11JK/hJjNyXoOFIhViJ0XjloLEMZEAWTURk5q aDew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=DiTd2397WgI6ec83YrNyvbx/KeDyWQ32fCmmCWD/hWA=; b=RhHu9UJywzdCKg0T70D/UQdf/AdAdKjePel+q0JpEQ/AypK9f1GtVSvkjGsU997iBc O4AHv6v31OJiqjBQbOBx9jhZtX3kFfdAeFoFLlg0Thu/ZV3SOy5D49mb8SXqWwSsCWFG +HlYJDV9Ua3bAGAcHvFwlCykRcPxzcMa0RD50cjMMGHPVEjQtF/H58uUusY5a36bCIF0 9MnLzoJN7kGCo0aIC1sMBvmRHnN9eogm0qIqcFyFKrolPOglO/nv45vb361F4EGYs2dq DhOjr8hRf0EvA44j/zNehrbAOZT+kr487xODswo0XWFx9ipBEYjnCtgqu/n+If+B/smi q7ew== X-Gm-Message-State: APjAAAWNQyAy6AgmWngjIMFMI2pHAHgooSR2zBbQu3K1fdpQW7L7CW2p dV2qyeZjptTNRDuWs67O3eFzZXbA X-Google-Smtp-Source: APXvYqxlAYluJtYOWEwjYYdD3YXKlweRWMDWBlm2TyGkJJr3ACJTNRvtbM8EdaZPJvefvsLZxC++7w== X-Received: by 2002:a1c:20c9:: with SMTP id g192mr17466698wmg.76.1557813669409; Mon, 13 May 2019 23:01:09 -0700 (PDT) Received: from nc10-laptop (71.142.13.109.rev.sfr.net. [109.13.142.71]) by smtp.gmail.com with ESMTPSA id a15sm20018491wru.88.2019.05.13.23.01.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 23:01:07 -0700 (PDT) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec References: <87lfzu9hsl.fsf@gmail.com> <87a7g8owim.fsf@gmail.com> <87ftpqq1kl.fsf_-_@gmail.com> <87a7frj1qg.fsf_-_@gmail.com> <87d0knshkm.fsf@gmail.com> <87v9ydg87m.fsf@gmail.com> Date: Tue, 14 May 2019 08:01:04 +0200 In-Reply-To: <87v9ydg87m.fsf@gmail.com> (Noam Postavsky's message of "Mon, 13 May 2019 21:01:33 -0400") Message-ID: <87bm05inhb.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Noam Postavsky writes: > K=C3=A9vin Le Gouguec writes: > >> [1] Although running 'make lisp/font-lock-tests' in the test/ folder >> fails on the append test. Could it be that the Makefile runs the >> tests against the old font-lock.el that is installed on my system, >> rather than the new one in my repository? I took a look at the >> test_template in test/Makefile, but I could not understand what the >> machinery loads at a glance. > > I forgot to answer this before. There's two issues here: > > 1. The default value of load-prefer-newer means that of you change a .el > file without recompiling it, Emacs will load the .elc file instead. > > 2. For font-lock.el in particular, it's preloaded, so even if you > recompile it, font-lock.elc isn't loaded again, you need to redump > Emacs. Duly noted, I'll watch out for that in the future. > So generally, the way to test changes is > > make && make -C test font-lock-tests > > Although it should also work to load the modified .el file explicitly > (untested, but): > > make -C test EMACS_EXTRAOPT=3D'-l font-lock.el' font-lock-tests Just tried with and without EMACS_EXTRAOPT, and it does seem to work around the problem. >> Can e.g. git-show(1) understand action stamps? I glanced at >> gitrevisions(7) but nothing suggests Git knows anything about this >> format. > > I don't think so. The last time I brought this up on emacs-devel there > was some suggestion that cgit (a git web frontend) would learn to > recognize them eventually, but I'm not sure if anything is really moving > in that direction. > >> (Or, going the opposite route, maybe the git-log-to-ChangeLog machinery >> could translate hashes to action stamps?) > > Maybe, although personally, as a human reader, I prefer date+title to > both hashes and action stamps, even when reading from git. Yes, it's > quicker to find a commit given a hash, but that still requires at least > pressing RET or clicking or something like that. Quite often, just > seeing the title is enough to understand what's meant and I don't need > to dig further. OK. FWIW, since I like to give context to my messages and I expect to be doing the hash =E2=86=A6 date+title dance a lot, this command seems to d= o the job adequately for commit $c: git show --no-patch --date=3Dshort --format=3Dformat:'%ad "%s"' $c Now to write some Lisp to make that available from vc and magit buffers=E2= =80=A6 (one-liner for action stamps left as exercise to the reader) > I think we're good here, pushed to master. Thanks!