emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Parens matching errors in org-babel code blocks
Date: Wed, 22 Dec 2021 05:20:54 +1100	[thread overview]
Message-ID: <8735ml7qmx.fsf@gmail.com> (raw)
In-Reply-To: <CABa5=g5z0C9Vd0JPOczUHukHXXCGb2oMGShuXPDLK4uYayRTrQ@mail.gmail.com>


I think this is a known problem (Org probably needs a PROBLEMS or
KNOWN_PROBLEMS file in addition to a NEWS file).

Problem is that org treats things like <> as special paren syntax
because they are used by org. Unfortunately, this causes problems with
things like paren matching in org files if you also have code which uses
these characters 'unmatched' e.g. (< 1 2) or (> 2 1). This is partly due
to things like check-parens, which doens't really know about babel code
blocks and so just uses the syntax table to find all characters marked
as parenthesis type syntax characters and generates an error when they
are not matched/closed.

Issue is, there is no universal and clean way to fix this which
doesn't have unwanted side effects in some use cases or has an impact on
speed/performance.

There was one solution proposed a couple of months ago which looked
promising, but it didn't seem to gain any traction. Not sure why. You
can probably find it in the archives. 

One solution which can work is to modify the syntax table for org
buffers to not mark things like < and > as syntax parens. However, this
can have other side effects, depending on how you use org.

What I do is not have paren matching or run check-parens in org buffers.
I also use org-edit-special (C-c ') to edit babel blocks as this gives
me the 'normal' language setup and things like check-parens or parens
matching work correctly.

Eddie Drury <eddie.drury@gmail.com> writes:

> Inside org-babel code blocks, emacs matches parens incorrectly whenever different bracket types (eg <> {} []) are used. 
>
> For example the following in an .org file will cause check-parens to throw an error:
>
> #+BEGIN_SRC emacs-lisp 
>
>   (> 1 0)
>
> #+END_SRC 
>
> Where in an .el it will interpret the parens correctly. This error also occurs with show-paren-mode and evil-jump-item. 
>
> Thanks very much. 
>
> Emacs  : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4)
>  of 2021-03-27
> Package: Org mode version 9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)



  reply	other threads:[~2021-12-21 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 12:51 Eddie Drury
2021-12-21 18:20 ` Tim Cross [this message]
2021-12-21 20:58   ` Tom Gillespie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735ml7qmx.fsf@gmail.com \
    --to=theophilusx@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Parens matching errors in org-babel code blocks' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).