From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id wIArJRVxW2RsPAEASxT56A (envelope-from ) for ; Wed, 10 May 2023 12:25:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id CGzuJBVxW2RLrgAAauVa8A (envelope-from ) for ; Wed, 10 May 2023 12:25:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9631229A42 for ; Wed, 10 May 2023 12:25:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwgzt-0000mG-K1; Wed, 10 May 2023 06:24:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwgzr-0000lp-NM for emacs-orgmode@gnu.org; Wed, 10 May 2023 06:24:35 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwgzp-0006Kb-Df for emacs-orgmode@gnu.org; Wed, 10 May 2023 06:24:35 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8A673240981 for ; Wed, 10 May 2023 12:24:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683714271; bh=tOqLRknQinsuXOZV3V7o5gLvinOtgX1sIwpBtoUVtRw=; h=From:To:Cc:Subject:Date:From; b=qOIl/uHbdbBxUKMJxpVDo/TKDusQKYwH26+XwzsZS6hpv+ji+Y3stnMbgj62zSxay Lpc+qw08WKzUta+k95mCsbNVaiMRluaRqMvsvrSFaFbWufj0r1CvDSsoml10mtiDbz VZzXNFsUndSvnKUm6XDN+iie8VqB3ijfYnOVKtBtqDaeqYUTbWXjQCmno5V/goY14m XCjPxsSIvqj32GT+oBnjEKvF+hQezW3j9A1/ISbUApOmZ8KiiVaWHNuZhkd7CtRs5R V6dGaqmWBEMmdoh0c4delxO4qZAg7sAHnrFZRExkCN/m6o5eQp1J6uhVlvbGQF3c23 qbhkx4PyfsQsA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QGWNb0b1bz6trm; Wed, 10 May 2023 12:24:31 +0200 (CEST) From: Ihor Radchenko To: Nathaniel Nicandro Cc: emacs-orgmode Subject: Re: [PATCH] Highlight ANSI sequences in the whole buffer (was [PATCH] ANSI color on example blocks and fixed width elements) In-Reply-To: <87zg6dez93.fsf@gmail.com> References: <874jpuijpc.fsf@gmail.com> <87y1n6igvo.fsf@localhost> <878rev1q0k.fsf@gmail.com> <877cueonkj.fsf@localhost> <87zg6dez93.fsf@gmail.com> Date: Wed, 10 May 2023 10:27:49 +0000 Message-ID: <871qjobhwa.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683714324; a=rsa-sha256; cv=none; b=n8Z7LB/HZDNg2gyNymwCc3BnvlZ0nuPEQwI1YdvRz75puc3ilVy1WRCn+P4x9UgpeJPkHW LMUSE6Yti/yfZJNaW//LD5dvnEF9fuB5aU9If9YBlw/Hyxmjp7TT8BBPUFRMpkzhx9Tb50 D0o+MHj8fAlScdZFgNTq59E0tSU56x2Acmq4eY3GnnQrgXSMRQVkcRGzgFCfbNGZ6iH3Gv 2JyaKuZHrAKoRjWtx4I/Ik4ttg+8yHUTIqyN52Kz0/gPYwXYYzLk9K5bpKONcCv8DQgaWX p3qMjFaV8GmY7+Dm6N6EkU3G9PaxEGXvFGFrSulQXOY7B7rcJTN/GjRpgaT5Dw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="qOIl/uHb"; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683714324; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=0U7JiksBUa7uX7yWfRTsrzl+jTeYkG5UlJJz2yK+h1g=; b=DXcYrxyyoqwTvFA1lDq07rV6KJRRVrWrawMdNI4Z//KPS9yyT/ZV6IzeFbnAtkxxiaby48 Jshen2EqeFEf19Gu7DMjySYt6E/jQ8BpToy5EPtD2hb7q/ZeSB0Ekv0YOe36foe73nlwL1 akrC5w+goYd7umRO+t0yvr9iq44Ho5uTjX9Vc4NhWcUUdZr13BbDxh2fkRDWBmexoAlJui /YqMkU9PDreb3oRj+qTpKxvCMzkW2OK2JyDVAeN8+mLYLMDIgAGZBe77i6NSQWLxAGAL+k 3IaCyEfNh4CnKrWp1CoR5iuvUDS9LLgd26XYYfh9rTmALEA83+19O2LIpNOUwQ== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="qOIl/uHb"; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.15 X-Spam-Score: -6.15 X-Migadu-Queue-Id: 9631229A42 X-TUID: XOfkWnZA7WGB Nathaniel Nicandro writes: > The attached patch now uses `org-element-at-point' and > `org-element-context' to query for the bounds of elements. Thanks! > Note, I've also attached an updated example file which shows that the > escape sequences in inline source blocks are now handled similarly to > regular source blocks, i.e. they are not fontified. I do not think that a single exception - source blocks is good enough. When having something like ANSI opening term is ==, and closing term is == it will be not expected to get things fontified. A better approach will be: 1. Do not allow ANSI sequences to intersect markup boundaries of the same AST depth: *bold * plain text should not trigger fontification *bold /italic/ * should trigger plain text *bold* plain text also should 2. Disallow fontification is certain contexts - 'inline-src-block Further, your current code will do something weird when encountering greater element: :DRAWER: Paragraph Another paragraph :END: You should not consider greater elements when fontifying. > + (cl-letf (((symbol-function #'delete-region) > + (lambda (beg end) > + (add-text-properties beg end '(invisible t)))) This is fragile and relies on internal implementation details of ansi-color.el. Is there another way? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at