emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Parens matching errors in org-babel code blocks
@ 2021-12-21 12:51 Eddie Drury
  2021-12-21 18:20 ` Tim Cross
  0 siblings, 1 reply; 3+ messages in thread
From: Eddie Drury @ 2021-12-21 12:51 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

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/)

[-- Attachment #2: Type: text/html, Size: 779 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Parens matching errors in org-babel code blocks
  2021-12-21 12:51 Parens matching errors in org-babel code blocks Eddie Drury
@ 2021-12-21 18:20 ` Tim Cross
  2021-12-21 20:58   ` Tom Gillespie
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Cross @ 2021-12-21 18:20 UTC (permalink / raw)
  To: emacs-orgmode


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/)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Parens matching errors in org-babel code blocks
  2021-12-21 18:20 ` Tim Cross
@ 2021-12-21 20:58   ` Tom Gillespie
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Gillespie @ 2021-12-21 20:58 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

Definitely a known issue. No easy way to fix it without someone doing
a deep pass on syntax propertization I think. I have a version of
rainbow delimiters mode that tries to work around this at least for
font locking, but it is severely broken and has some nasty quadratic
performance issues in large files. I'll have to look into the proposed
solution that Tim mentions, I may have missed it (unless it was the
solution for <> that John mentions in the linked thread, in which case
that one is not sufficient). Here is a discussion from back in April.
https://lists.gnu.org/archive/html/emacs-orgmode/2021-04/msg00031.html

Best,
Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-21 20:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 12:51 Parens matching errors in org-babel code blocks Eddie Drury
2021-12-21 18:20 ` Tim Cross
2021-12-21 20:58   ` Tom Gillespie

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).