From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oJ0MAcB6LWQAbAAASxT56A (envelope-from ) for ; Wed, 05 Apr 2023 15:42:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id oMY1O796LWQWRwAAG6o9tA (envelope-from ) for ; Wed, 05 Apr 2023 15:42:23 +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 1815E3C907 for ; Wed, 5 Apr 2023 15:42:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pk3OA-0004yn-Py; Wed, 05 Apr 2023 09:41:26 -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 1pk3O8-0004yY-Jk for emacs-orgmode@gnu.org; Wed, 05 Apr 2023 09:41:24 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pk3O3-0007tu-DW for emacs-orgmode@gnu.org; Wed, 05 Apr 2023 09:41:23 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 496C3240314 for ; Wed, 5 Apr 2023 15:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1680702077; bh=ICs7gXobJSo4tpxsBACA+9avHNyZ3LGDslgg0Hyxp48=; h=From:To:Cc:Subject:Date:From; b=L2QUiIYZYdUvRSvse1/eS8NWSWelBLnyhfVlBwy3omNx++rbS5nziaQnePKyjjxPT yG0hiin8J5qt2AH7am+aVt1UQ+mokTVKX3BrOAPd+Alkmbc+VlQfF+NKr6rkBDODdK HVrLW6e1FhllMvBPw5Q77DAJ+TlBQL9QuUrA65WHqOdf1FlojRqHP3yIO76ItiIZr/ OLnJjCHbWGeB204yxRIe9Hc7gEnQalE8FPk2NDWLA7EM18WRI9RBQO86P/HXuqDBxi JWsie6ZsGNfeoP7K6DyUKHmQEfT7jSixRl61DGtdK3M22EzZEl0nAbZqiDJwdSEPbg A20vGPNO9D9gA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ps5Pm5R6Hz6tx9; Wed, 5 Apr 2023 15:41:16 +0200 (CEST) From: Ihor Radchenko To: Nathaniel Nicandro Cc: emacs-orgmode Subject: Re: [PATCH] ANSI color on example blocks and fixed width elements In-Reply-To: <874jpuijpc.fsf@gmail.com> References: <874jpuijpc.fsf@gmail.com> Date: Wed, 05 Apr 2023 13:43:39 +0000 Message-ID: <87y1n6igvo.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680702143; a=rsa-sha256; cv=none; b=Nz8LhIykPfD7/aDCGrJh2xbaozQxKL/IGn/8B2Q8BXYtwhMMCgFn5uyjWQ+Yw6Oetul/5K W5ncQPvd8I/nIl0Q/S+dEdOQ+OSVclqqB7JRdqW5dXw/HkaK3ECo/224lIaqNx8DrFJv4I AZJH0qFioQXxSIyYq49QhIzqZK3IpwDRfSEFoI9z1EItnZ26u77sIYrVTbsM70XiK3fxkJ KoivbWU8V74cWdYiBarEjHtIJQCfjI08folbfpuND+aFD5g2B0dW78KPnP4IguRKResGfi 2OM5pvHEB9VJ+VuRNZouV9FySO4zOcc8S3v4AJg0x8nRmiCX9HV9Ko/wNQbsYg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=L2QUiIYZ; 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=1680702143; 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=U3AQAwRBacj8RAd/C233nzfw6WH2Z+xs8qnsF/NglGA=; b=qXK6hRyfMFnwnFHtmf1+GcfKncSkBCzf6kmSSFeXWafx/KN9kdp+dtWJh9Cf9ww2AecePR myBXEjMaXxK82ZTXDzn1GwqOtPJOoQQxzXZ6vHh7GjAQvpA9YM8/G+TGeyLUrjIzVkZ5oH 5VkAxNY7jMaw9s8v86PGhkSek7SHc0yYoLCar3AR8gV40zSVDZXQh8KSX98vlGxC2woCn5 hhV8bEvJJFGDdY418vIaMZqg08xSWshOuiWXuNN/L9/UosphSqnAsbX87d+W/LWnvdjyMA Uj05bXcBJglYn1q276g/M6ioGh9RXERIcIgTsp1wyb48tCk4hJ82QCbpsprxXQ== X-Migadu-Spam-Score: -6.21 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=L2QUiIYZ; 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-Spam-Score: -6.21 X-Migadu-Queue-Id: 1815E3C907 X-TUID: Yoz6+eYSuwGO Nathaniel Nicandro writes: > Attached is the patch. Without this patch, ANSI escape sequences > generated by the output of a source block will be left in the buffer > without any fontification. With this patch, the escaped text is nicely > colored and escape sequences hidden using overlays. > > It works for Emacs versions which have the `PRESERVE-SEQUENCES` argument > to the `ansi-color-apply-on-region` function. It's a bit slow due to > the use of overlays. My implementation of this feature in Emacs-Jupyter > supports older versions of Emacs without that argument, it relies on a > custom version of that function though and uses text properties instead > of overlays. > > Let me know what else could be done on my end to get this patch in. > Thanks. Thanks for the patch! This is an interesting idea, but I am not sure if we want to use this colouring by default. At least, it should be a minor mode. Probably enabled by default. Because not every possible user may want to have the escape sequences hidden away. Further, your patch only allows fontifying ANSI sequences in fixed-width elements, example blocks, export blocks, and src blocks without known major mode that does the fontification. I doubt that fontifying ANSI sequences in this specific subset of elements always makes sense - example blocks are not always used as src block output; bash code blocks may purposely contain escape sequences, but your patch will not handle them; inline src block output is not covered at all. Ideally, fontifying ANSI sequences should be fully controlled by users: 1. We may not want to touch src blocks by default, when `org-src-fontify-natively' is set to t. Only, maybe, provide an option. Or you may better publish a minor mode that does this for shell scripts. 2. We may allow all the ANSI sequences to be fontified in the whole buffer. 3. We may limit ANSI sequence fontification to results and only results. Or just certain types of results. The easiest will be implementing fontification in the whole buffer, early during fontification (and early in org-font-lock-keywords; see org-font-lock-set-keywords-hook). -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at