From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Font lock in org+elisp confused with ?\[ Date: Thu, 01 Apr 2021 17:44:48 +0200 Message-ID: References: <20210401090411.GB16534@tuxteam.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22030"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt) Cc: Tom Gillespie , emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 01 18:04:08 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lRzni-0005aa-7L for ged-emacs-devel@m.gmane-mx.org; Thu, 01 Apr 2021 18:04:06 +0200 Original-Received: from localhost ([::1]:50888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRznh-0004qR-43 for ged-emacs-devel@m.gmane-mx.org; Thu, 01 Apr 2021 12:04:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRzjp-0002Z6-8k for emacs-devel@gnu.org; Thu, 01 Apr 2021 12:00:05 -0400 Original-Received: from mail-oln040092072015.outbound.protection.outlook.com ([40.92.72.15]:24293 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRzjh-00047T-GK for emacs-devel@gnu.org; Thu, 01 Apr 2021 12:00:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0pvTWJqs3n7Y1EsUiZM8UOCT2yXqEzFAQE90CCagu6fGT7e9ukIaM571kFGpbC0UHpXP+ay8riDlssb1nmOOFJ0ifWyPvnPcqEg4+BWYIodRsMxfKs1ZpyA4+L5av71z607gDt5s40djsH9Z21rHqnw13PTDK9xUfln4YK5ivsDFEL8ieFDtKs2P7ejExXI4SYaeiOEycuYFWTNeZhqC/RCDzH7HWnEoCIlUo6AhLbQyWPhk9LsiNN6V577B2mZDBV8TCnmCp3uj1R2GRMEi4YY9RFFcOVFqiZ+HQRju/P4JCMwfI+lhcyhl+iUZTIS9bATBC+HYb8PsN9ji5ymyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ZuKh6QbUX5a5OvMMARAqTHo2l5KUqVAINGZKuIPlzM=; b=XeyCJwTYBkOVT13yjq/jNSRe/6Cd2KZP8Ov8StgayDOAIrFTJ4wZVy4lyLbbU7mX74I7zeWD0eQAHJYxs/6uCRQHVFjiCs2+ikQwYceyoMHWNaGfZFzLal5+TEgCxJXj5Lm0u/X8DdRXWbaHIx4VU5TeSz2o+MxWyu8Ql/0oDOhznZEICUAuUU8LJAR86DQdVcg3/wsaH9r7FUKv9x44tpmOQzq5IbwyQJ+6X9w1S2qvsDy+iGDFyTzY///GStY/TUYAOWz0gO7VdtYQB5EMUYKfuNOkGHZa1PqDJ6Fx5B8T8vMG2A23iaiIy/wSgDS5iZK4jIvY5siC6YTRUdrgDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ZuKh6QbUX5a5OvMMARAqTHo2l5KUqVAINGZKuIPlzM=; b=MoM4KzhFbbs7wqFvJA2JeAnSta3/Fnk4B/XXZ2ZG1eS/BbogljtvSwcx/YBMtuUbnz66uuPeVj0yj5pAHkeMqhkqo4me9WT9ixBxEnPsRK6EeAzbvdw0wR74u9T3fq/dGukrtdvgnOcE3QzV2Yy6w3MdosIANs5kp/eEdiscdmmHjtHO7hXkzp1hyhewCen6OqXljYFyW6XMtFmL3rolat/EEDX/xB7Mm3KIHKx7I4Ulk0Ue2YDPeUCV/0M2LrGNXpJhBL88cIOnAZ4No8BnCx23jkAF5rNmaNLygTlEmTrUHBpAOcbQ7+kvMRGI9xjA8Vs8d963Lqi66hr1skGVKw== Original-Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e08::49) by AM5EUR03HT115.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e08::187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Thu, 1 Apr 2021 15:44:52 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e08::4f) by AM5EUR03FT012.mail.protection.outlook.com (2a01:111:e400:7e08::161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Thu, 1 Apr 2021 15:44:52 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:EF6AF2B4D335AF547FB328A310A3BBE81DCADAD0B309F1294A5A89104307479C; UpperCasedChecksum:924823685D387E01977C9B1281D121D1ED5B71000D33D8D8A3DB2F297834D4F9; SizeAsReceived:7599; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b%6]) with mapi id 15.20.3999.029; Thu, 1 Apr 2021 15:44:52 +0000 In-Reply-To: <20210401090411.GB16534@tuxteam.de> (tomas@tuxteam.de's message of "Thu, 1 Apr 2021 11:04:11 +0200") X-TMN: [liKiRpLAYaILGZ4r3pIj0D3By1oFPTi/] X-ClientProxiedBy: AM6P194CA0004.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::17) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <82czvem2kv.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from HP-Laptop.homepc (81.232.177.30) by AM6P194CA0004.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Thu, 1 Apr 2021 15:44:51 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 57cdeac0-d1a4-4c8e-deb9-08d8f52516b8 X-MS-TrafficTypeDiagnostic: AM5EUR03HT115: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jd8CrfhR+ocOZ60zwfL6QtSBW7evUaSUDOwEJX8796D0OIUDbNxdsl0heYcInhlkCrs/BMlGZhzV6+WIaL1ap+rRlV4O1kq9ujnqVzX9mS2RlykrinVbJcU4QIH4lQxLFGqCiI9IgmgKWrbHMzyimBx9j37nmSMKxiHix08IeZ60QLkkbGJGBJA2qlKa0X01335ehfBssC1NlCF3dEn4PnBlE2YwtgHe7s4aaATfe8aCvmP1BFKNqsTCK/UFFx5pqxiHZUll5LeRI0zHLRWHzvSMHpBGC4+p3szw1n+2AfeZQyqjoHIVId9iEe5mQ6ixed6e7RkG5o61d3PISgcdc5M/LZl4uj9J0yQCEPFv71Nl8KdCi+NKGVE5uUL0XEcE2jEVnBp4OIGKEPD2b3XXqg== X-MS-Exchange-AntiSpam-MessageData: w/Z2BJ9OWHTMZX1nyEY7UHJqQrT8thn9OEKzsifmhUEvXjSK7nc7mvEJ+AvIqx8Mh0he1yg8Vq3M0iszamVDiCy5XS82LV94zuVMMK/VORLQnogfG37A5avv0fyN7/2czwjZ2EjtoZvlRnplxcPzXg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57cdeac0-d1a4-4c8e-deb9-08d8f52516b8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2021 15:44:52.0488 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT115 Received-SPF: pass client-ip=40.92.72.15; envelope-from=arthur.miller@live.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267262 Archived-At: --=-=-= Content-Type: text/plain writes: > On Thu, Apr 01, 2021 at 09:18:30AM +0200, Arthur Miller wrote: >> Tom Gillespie writes: >> >> > This is a known issue with org babel blocks. It is due to the fact >> > that org babel translates the font locking for the language but not >> > the syntax propertization. Another frequent cause is the bash case >> > statement. The end result is that unmatched parens leak out from the >> > babel blocks and wreak havoc elsewhere in the org file unless you >> > balance out the parens e.g. in a comment. I have a hacked fix for >> > this, but it has horrible performance, especially with line numbers >> > enabled. I think that a proper solution would run arbitrary syntax >> > propertization on subsets of a buffer without having to continually >> > check where those subsets start or end. Best, >> > Tom >> >> Thanks for the explanation! >> >> I don't know how org-babel works, I guess it opens another buffer, >> font-locks syntax there and copy it over? What was the reason why they >> don't copy other properties? Performance or something else? > > Hm. I've just poked around a bit. If you are talking about babel > blocks, I think the entry point is `org-src-font-lock-fontify-block', > defined in `org-src.el'. > > And indeed, this function basically does this (with a lot of > corner-case chasing around, as is usual in our trade): > > (let ((lang-mode (org-src-get-lang-mode lang))) > ... > (with-current-buffer > (get-buffer-create > (format " *org-src-fontification:%s*" lang-mode)) > ...)) > > The rest is left to the reader's fantasy, as they say :) :-) Left as an exercise to reader's fantasy? I tried to copy 'syntax-table property, but it didn't solve anything. I think the problem is some bad regexp somewhere when it come to indentation, it misses what it looks at somewhere (obviously), but I have no idea where. I am not sure it is org fault. I see gnus is confused too, so it is probably deeper, maybe in elisp mode? I took a profiler snapshot to get a nice stack-trace while moving the cursor just from one place after parenthesis to the closing parenhesis on this line: (if (= (char-before (point)) ?\[) I have attached profiler-repport. I also noticed that the function got called ~1000 times, while there are only ~140 src blocks. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=profile-repport - command-execute 7,784,221 86% - call-interactively 7,784,221 86% - funcall-interactively 7,784,221 86% + helm-M-x 7,689,817 85% - next-line 90,356 1% - line-move 90,356 1% line-move-visual 64,756 0% - org-delete-backward-char 4,048 0% - backward-delete-char 2,832 0% - delete-char 2,832 0% - org-indent-notify-modified-headline 1,024 0% - org-at-heading-p 512 0% outline-on-heading-p 512 0% - jit-lock-after-change 1,024 0% - run-hook-with-args 1,024 0% - font-lock-extend-jit-lock-region-after-change 1,024 0% org-fontify-extend-region 1,024 0% - org-indent-refresh-maybe 784 0% - org-indent-add-properties 784 0% org-at-item-p 704 0% - org-fix-tags-on-the-fly 704 0% org-match-line 704 0% - timer-event-handler 633,847 7% - apply 632,095 7% + # 627,071 7% - show-paren-function 4,136 0% show-paren--default 4,136 0% - blink-cursor-start 888 0% - blink-cursor--start-timer 888 0% - run-with-timer 888 0% - apply 888 0% - run-at-time 888 0% - timer-set-time 504 0% timer--time-setter 504 0% - timer-activate 336 0% - timer--activate 336 0% timer--time-less-p 336 0% timer-relative-time 48 0% - timer-inc-time 816 0% timer-relative-time 600 0% timer--time-setter 216 0% - timer-activate 720 0% - timer--activate 720 0% timer--time-less-p 720 0% - beacon--post-command 347,992 3% - beacon--maybe-push-mark 347,992 3% beacon--movement-> 347,992 3% + redisplay_internal (C function) 141,823 1% - winner-save-old-configurations 33,088 0% winner-remember 33,088 0% - eldoc-pre-command-refresh-echo-area 4,724 0% - eldoc-message 4,724 0% - eldoc-minibuffer-message 4,724 0% apply 4,724 0% - ... 4,608 0% - helm-create-helm-buffer 4,608 0% - helm-major-mode 4,608 0% - run-mode-hooks 4,608 0% - run-hooks 4,608 0% - wrap-region-global-mode-enable-in-buffers 4,608 0% - turn-on-wrap-region-mode 4,608 0% - wrap-region-mode 4,608 0% - wrap-region-define-wrappers 4,608 0% - mapc 4,608 0% - # 4,608 0% - apply 4,608 0% - wrap-region-add-wrapper 4,608 0% + wrap-region-define-trigger 4,608 0% beacon--record-vars 4,136 0% - eldoc-schedule-timer 24 0% - run-with-idle-timer 24 0% - timer-set-idle-time 24 0% timer--time-setter 24 0% --=-=-= Content-Type: text/plain > Cheers Happy Eastern! --=-=-=--