From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id +J/7B+kzCmf2KQAA62LTzQ:P1 (envelope-from ) for ; Sat, 12 Oct 2024 08:31:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id +J/7B+kzCmf2KQAA62LTzQ (envelope-from ) for ; Sat, 12 Oct 2024 10:31:37 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="L2jdeP/y"; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1728721897; 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=gMk76qO5xL+Ra5rQgfl/keCZ6K7j1pSqjD9zQqVTAW8=; b=gEOt2Px0xfYXVMoRnegxwYZiSZOfbvxfF1bVGnwMi4iBBX3TooF+3qtzpaujjYg3vFE0Fw +TXeSqqa2WRj/ZvUv8V7zu4BREnh/NfmGabEf42w+EhVylwDIXO+wnj83g9BXqQzCcg7wn PDZZw2ohR5mLIUz1VEnDlc/EpiO01XWeG0eWpOdPV9MdUv5dEhK6OsAgOayaoCmdvMvs4N NTAt5k2EbvRbrJhWHtsCQ1kyOCLZXtBAX6iNw0WP/Ae9MwNudf9zNhF/3kEIH0Nrk0gT+6 d/qPLnoXCLVw5d2KjMD96FK2nG1lDqlHmkMjvLi0JTBh87i5rTo8/AR1rer1xQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="L2jdeP/y"; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1728721897; a=rsa-sha256; cv=none; b=QhWqhVEjohFylmbcT24xRQ3m7iyVMiCN9S3IYPXUT2zfnc7Ag41YRBkuyio0iykuDF7d7D z2YNMy7Q5Tm9j5zAZdfldO1RHmMcmF4Vw7qzMvHAnfWE47INFgUmoDsvFQZmtvIew8beK+ 8xUPvE8QlFOKDsTuRATMAm0oZoMrYHpYDNmciP4YhRY9J/6AGOkf7MhZZsjua8/wFrBPOc PY6sXiLmaRNtZk944H7J9jUDT2PpdWWwZdLBH1LQJeRolIbWOGQMRFi3YZKE2PV1NsnhrE BMESmt7zlQTyYDLD3QhLmKI/gt/dlyAzEmG6cHU/IiO1UtPCo3CoN5nKdB6aTw== 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 A266B46D98 for ; Sat, 12 Oct 2024 10:31:35 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szXWR-000593-FY; Sat, 12 Oct 2024 04:30:47 -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 1szXWQ-00058t-AZ for emacs-orgmode@gnu.org; Sat, 12 Oct 2024 04:30:46 -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 1szXWN-0001Zz-4a for emacs-orgmode@gnu.org; Sat, 12 Oct 2024 04:30:46 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 3CB0B240101 for ; Sat, 12 Oct 2024 10:30:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1728721841; bh=O5sjDdyt0NfSoX77TBPufz+XkAP3EsuY6qo2vU8j2g8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=L2jdeP/yoK079nxiSFoW/08hH45kd7/ThHyLe3Bd1y6jGEcMaKFQEB4tgC/8mMh+X 4t9tqDuqKghbDIYTtsjwODvnCuJKSQ2SB4rU2xCmkFqVQa/EqaMf2g4XT+dlzrJJry Qq/iizszY+aYssJZcgfW4c+wiClzWJsZ9BuQNVYHXfmvpkUjSNwnLezwTRNYC0CtcB FXrq7IeF4epckmIXWtfSGQw0iEcWLf3Fcqq1fm+Q/GHBMHHD8b4433do7epuf0n8Oj XYUOUETojjUOw473knsYXxCwNpQ3baWDeagQt7GOT8pYwxcmGVJgG0Sn5EMIYAx8/N 32E/6T6q0ho2w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XQcBm61s1z6tvk; Sat, 12 Oct 2024 10:30:40 +0200 (CEST) From: Ihor Radchenko To: the_wurfkreuz Cc: "emacs-orgmode@gnu.org" Subject: Re: Elecrtic-pair-mode works incorrectly in code blocks In-Reply-To: References: Date: Sat, 12 Oct 2024 08:32:31 +0000 Message-ID: <871q0lu3fk.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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 X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -1.28 X-Spam-Score: -1.28 X-Migadu-Queue-Id: A266B46D98 X-TUID: hqQj8AWBdK6M the_wurfkreuz writes: > Reproduction: > > 1. emacs -Q > 2. In the scratch buffer enable to org-mode. > 3. Enable electric-pair-mode. > 4. Paste this code: > > #+begin_src emacs-lisp > > ;; (if (eq major-mode 'org-mode) > ;; (org-cycle) > ;; (yas-expand))) > ;; ;; (my-completion-preview-insert))) > > #+end_src > > 5. Then in the first line of the code block try to insert an opening > bracket - '('. It wont be closed. Writing a closing bracket will make > the cursor to jump to the next bracket. At the same time i don't have > such problem outside of org-mode. There is no bug here. Org mode does not provide support for src-block rules when completing the pairs. In other words, electric-pair-mode has no idea about Elisp syntax rules in this context. Instead, only Org mode markup rules are used, treating parenthesis more or less like in plain text. The behavior you are observing happens because > ;; (if (eq major-mode 'org-mode) > ;; (org-cycle) > ;; (yas-expand))) has trailing unbalanced ), which means that inserting ( before will make the following parenthesis balanced (again, electric-pair-mode has no idea that ;; means comment here). In contrast, when inserting ( after the comment, there no other ) present in the Org file afterward, so electric-pair-mode does close the input with (). Of course, it would be nice to make electric-pair-mode aware of src block syntax in addition to native Org syntax. For example, this can be done by applying src-block-specific syntax-table text property just for src-block. I did try implementing exactly this as a feature, but, unfortunately, local syntax tables break some parts of Org mode's own parser, opening a whole can of worms. So, adding the feature you expected to see is not trivial. Patches welcome though, if someone is dare enough to dive into fixing Org mode syntax reliance upon very specific syntax table. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at