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 ms5.migadu.com with LMTPS id IOEHGiy5/GL6+QAAbAwnHQ (envelope-from ) for ; Wed, 17 Aug 2022 11:47:24 +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 oO28GSy5/GJ5QgAAauVa8A (envelope-from ) for ; Wed, 17 Aug 2022 11:47:24 +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 381C91DE10 for ; Wed, 17 Aug 2022 11:47:24 +0200 (CEST) Received: from localhost ([::1]:53276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOFdz-0002X8-0g for larch@yhetil.org; Wed, 17 Aug 2022 05:47:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOFVH-0006bg-UR for emacs-orgmode@gnu.org; Wed, 17 Aug 2022 05:38:24 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:36774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOFVG-0006yl-4Q for emacs-orgmode@gnu.org; Wed, 17 Aug 2022 05:38:23 -0400 Received: by mail-pg1-x52d.google.com with SMTP id s206so11534353pgs.3 for ; Wed, 17 Aug 2022 02:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc; bh=HnsAzw+25xGkyI9P7v3ntDmR4ziOb7eZwlFeiThycZ4=; b=dlGf9FbTn+CcufyiRsR9DCYyMKR64S7ixe+QBdaCf2oaPpKbM8sX0jwwMQS9LjxksF adQ9+L63vnWhw7GuurLDghg77lFNi40V4Fjui/K0oix1BVzZhYIKAkgXHNTtkOmrZ+1o /XoeUAzuZ17qYL6tf+gcVjppqp+wBFfZyhJv/E9xAmo6tuxuL1Nhr9ZXmUoWla5OHUZh +qFX6uLJ+uxEsmH2OHH9cSTmQOJyXBnwhGb78SxYbya9e41Z5VsCxR0Hr9iW0zIYrLdV xVIoA1tfhti45ewy3/5PGjl19zNMIG+Ao0u9V0EdUXr1Vy0w2BBZBLiu+wD/MDro3pqu 5AJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc; bh=HnsAzw+25xGkyI9P7v3ntDmR4ziOb7eZwlFeiThycZ4=; b=KfwhocKNpn5m1HdS05iQloRIhJBG0raZ7u+46nke6Z5yFjEh5scZBOs9zl2V32o7YZ a4ywCOVDS/znXa+jOuxqNfc7Y38LseSXa0+a95ovqhtO3tnkzHUMhlwbFgC9vWmfzYed ypZMSkOD8GwJDc8GPejwsAho2DJ4jaHZnPA2xVms7bGerCOopD6PWSz0+PZ4uIArT5gU 6IJ+rcVZXPbXA7rpOFJg2UzZNxTDRoa95bnWQgpwqIejIQKoaxJn0DN1AbCPXRyMd91L 0t0xNgPtZ4/OBSm7t+ipYDrc9NHKHRZ8fPOlJGUYZP9xuLMXp85KxjDiu64WWxvv6SBQ LZxg== X-Gm-Message-State: ACgBeo3aeXCjbw/Xn+WMX9O/hBtDkNw2ifhKbTWZEBJomjTcnNmBghb5 IRLY5HnVctk34kXGxAWRhzU= X-Google-Smtp-Source: AA6agR7pTcBpN9hpJYtaVnOE7F1J+sRoIqjm/AcpznJGQ8XmFuk2cR9y4mAeVIuPRYO5rnBXy/1auQ== X-Received: by 2002:a05:6a00:24c2:b0:52e:7181:a8a0 with SMTP id d2-20020a056a0024c200b0052e7181a8a0mr24752010pfv.57.1660729100641; Wed, 17 Aug 2022 02:38:20 -0700 (PDT) Received: from localhost ([115.154.175.57]) by smtp.gmail.com with ESMTPSA id y192-20020a6264c9000000b0052dce4edceesm9959506pfb.169.2022.08.17.02.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 02:38:19 -0700 (PDT) From: Ihor Radchenko To: Bhavin Gandhi Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] Incorrect fontification of src blocks for indentation sensitive language modes In-Reply-To: References: Date: Wed, 17 Aug 2022 17:39:24 +0800 Message-ID: <87czcz1a5v.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, 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: 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1660729644; 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=HnsAzw+25xGkyI9P7v3ntDmR4ziOb7eZwlFeiThycZ4=; b=nnoqfDEEOrbApm/Gnl16Li/IijarxtosXfo5PaZJrsHZaVftEIxSea2A1QcByCjDTxInWe GBXHF8J70NwVR7mBb5rwTHa2aUam1kvzbCLEkJo2UhdlxcJ1qqZZDiFJ7MYmuntbqkaTXq JpgTUWsQjxWOlRrYbbIJ5RLzN1xbauOz5yNXBnK1p9aCv1KKu4dVv7yDcC9ZvtxXxL8i1U qKmFTu41/oEyV6n0MYJG8iev1aEIvEQ7ulUionXIwbXWydLtbxhjbgEh1iRzDNaFgkCpk2 sNHIgWIRRGIkOThN9iqvIHDKjlUMhT8kmToWJkpd5DR2jpQPhRZ7zbHm1YJ+SA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660729644; a=rsa-sha256; cv=none; b=FcIHs7YpfP6KehDctprhE/P+dCtRPFCiJNK0Vc1Tn+zmdRqCH0mErVmTvWL8xSrue6C4y+ QE1LruxSt1llyJojjiC1SslruYdstvNNHeVrYlUzSXUdtnTVXyFoeBBma36gNBHtB04ZQS ZBVZrRiZQbOCQZd7S5hj8WsiVAqwXgZ8m+1B3i5fhUJIS0ayhjkWtXU3yQZQx9VA+IrgLt BnvdpbBEHiHFFZqp/Bn6RVvA8lF4ly5AjqOWwx5LFiWDhnIUTvusf1Yy2EjY5K1giMEESS sTINrPdzc0b81nJPcZRRcmeb0noU2zlj9Htr0aC1LZbGOBo2d5fAzp0MlaOhGg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dlGf9FbT; dmarc=pass (policy=none) header.from=gmail.com; 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: -3.66 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dlGf9FbT; dmarc=pass (policy=none) header.from=gmail.com; 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-Queue-Id: 381C91DE10 X-Spam-Score: -3.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: N193GucuOni9 Bhavin Gandhi writes: > In the following Org mode file, the Ledger mode source block is not > highlighted correctly. > > How to reproduce: > ... Confirmed. Another example is https://www.reddit.com/r/orgmode/comments/wi0jq9/highlight_doesnt_work_for_src_block_of_diff_with/ > PS: I haven't looked at the code of org-src-font-lock-fontify-block in > detail, so I could be wrong with this analysis. `org-src-font-lock-fontify-block' is indeed the culprit. It copies the text between begin/end markers verbatim without adjusting the indentation. The proper way would be using an approach similar to `org-edit-src-code', but it may be tricky to map the fontification back into the original block without a need to delete/re-insert the code into Org buffer. Editing during fontification is a bad idea, so some kind of smarter approach should be used in order to fix this. P.S. I am genuinely surprised that this bug is only revealed now. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92