From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.help Subject: Re: [prettify-symbols-mode] Two consecutive matches don't work? Date: Wed, 18 May 2022 14:28:30 +0200 Message-ID: <878rqz10up.fsf@gmail.com> References: <8f817c96-9a19-45a6-9eef-2e598755970d@www.fastmail.com> <83h75nf3zu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9131"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 18 14:30:01 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrIoS-00026o-QX for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 18 May 2022 14:30:00 +0200 Original-Received: from localhost ([::1]:57026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrIoR-0003Th-Hw for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 18 May 2022 08:29:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrIn7-0003Pt-MT for help-gnu-emacs@gnu.org; Wed, 18 May 2022 08:28:37 -0400 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:42990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nrIn5-0006xR-AA; Wed, 18 May 2022 08:28:36 -0400 Original-Received: by mail-wm1-x331.google.com with SMTP id r6-20020a1c2b06000000b00396fee5ebc9so968041wmr.1; Wed, 18 May 2022 05:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:mime-version; bh=u3mVmvb0f6po5TF2CgHDW0A+EorDikZt0wwHyR4eRxA=; b=be7p90hQPnhdPENz6YdDyV34LCKzysx8DQgQj6vbnoj8tEN5EMD6HRnwgffFti5GZE P3tvelpj9p93bmUcBvUs9b5SMa8MkHmd8QffoUFQ3MrCplCeQwBGq/eon/23kehcjdcw 1fVTUQwE+RkpnLLv1b83scUvhV6mxSVQ33MlIJ1JZGjcRIFccLbmHKCApAaXzj3bVe7N IhEA+rTr2JxBQWwC+b2gG6Ooh9kIdhiMTkANFMHTaQ29Mz76qqU0fw2LxJPLNVsONfzC jnrEPNKZQk1yETGPCrJTUzy21J6ncvhgY/pSjODFYhX7tDybxH/HFDaa9CZUonmbfa3f /N3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:mime-version; bh=u3mVmvb0f6po5TF2CgHDW0A+EorDikZt0wwHyR4eRxA=; b=aWRbAchY82XtG8jR82EZsf8WzihopJ8giZnCS8iRgeDzL77sT+Oy5UiOBnhXpbSXpS 8bPv9K5+0DCtJiXj9ZdhKVt/qUV88lnQ6aSgV5QmrFbtOlv7awonVmN5fU/i+68toC2M hKiJ6/n3m1bntQJNd6uQg00hJ25Tcy2ylVLt74QPzZvrzuhkg7keiqHlrM7a8GQ7Ak3N US3irpA4AS21gSophcM5v5NfBF1QVTWH5sfKkhGnyCrCWVP5MGynisRrzPIyxQ864cyR C+9cB+IflHzDsY3DsuvabXPd2izyBDGpLdGWo+kos3yeRF96cbHOWb2C00qF4ty0QCRJ s68A== X-Gm-Message-State: AOAM5317s6iXOHl0kiPkWmQQimqwlda0JK5mZ0FVS2YFdZ3JQBt6IXh8 gDTHu92LW42OrXSkUVrmKy7E39c9PNs= X-Google-Smtp-Source: ABdhPJx7OF5gbGm6Eys/g6C5Le4NDmuKw838j7Qprrg5RK4VEzENyZoM44cDHze/kleyJiyHXBSo6g== X-Received: by 2002:a05:600c:1e13:b0:394:5cdd:e8e6 with SMTP id ay19-20020a05600c1e1300b003945cdde8e6mr35814591wmb.108.1652876911949; Wed, 18 May 2022 05:28:31 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb50:cd02:384a:6bea:3e81]) by smtp.gmail.com with ESMTPSA id p24-20020a1c7418000000b0039729309a84sm35694wmc.20.2022.05.18.05.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 05:28:31 -0700 (PDT) Gmane-Reply-To-List: yes In-Reply-To: <83h75nf3zu.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 18 May 2022 14:56:53 +0300") Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=rpluim@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137305 Archived-At: >>>>> On Wed, 18 May 2022 14:56:53 +0300, Eli Zaretskii said: >> Feedback-ID: ie15541ac:Fastmail >> Date: Wed, 18 May 2022 11:32:07 +0200 >> From: Joost >> >> I'm dealing with some `.xml` files that contain data which uses the >> sequence `<> LESS-THAN sign needs to be encoded as `<`, yielding `<<!`. >> >> So I thought this would be the ideal use case for >> `prettify-symbols-mode`. I added `("<" . ?<)` to >> `prettify-symbols-alist` and activated the mode. >> >> Unfortunately, only the first `<` in each sequence is >> prettified. This seems to be due to the fact that the second `<` >> is followed by the exclamation mark: if I insert a space in between, >> prettification works. >> >> Is there any way to remedy this? Eli> prettify-symbols-mode is not general-purpose enough, its defaults are Eli> tailored to prettifying keywords of programming languages, not just Eli> any arbitrary strings of characters. Yes, it by default does a lot of stuff based on the syntax tables of the buffer. Eli> I think you will need to tailor prettify-symbols-default-compose-p or Eli> roll your own predicate and bind prettify-symbols-compose-predicate to Eli> that predicate, if you want to support such sequences. (setq prettify-symbols-alist '(("<" . "<")) prettify-symbols-compose-predicate (lambda (s e m) (string-match-p "<" m))) seems to do the trick. You could even generalize it to: (setq prettify-symbols-alist '(("<" . "<")) prettify-symbols-compose-predicate (lambda (s e m) t)) :-) Robert --