emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastian Wålinder" <s.walinder@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Babel results don't respect narrowing
Date: Sat, 29 Apr 2023 08:46:29 +1000	[thread overview]
Message-ID: <87mt2r39ru.fsf@nixos.mail-host-address-is-not-set> (raw)

Hello!

When org-babel inserts results after evaluating a org-babel block, the current narrowing isn't respected.

Org searches outside of the current narrowing to find a result block, then updates that.

Here's a example to illustrate it:
```
#+CAPTION: 1. Evaluate this to narrow to the elisp block (I put :results raw here so that it's impossible for it to narrow to the first block)
#+BEGIN_SRC emacs-lisp :results raw
(narrow-to-region
 (progn
   (re-search-forward "#\\+BEGIN_SRC emacs-lisp$")
   (beginning-of-line)
   (point))
 (progn
   (re-search-forward "#\\+END_SRC")
   (next-line)
   (point)))
#+END_SRC

#+CAPTION: 2. Evaluate this
#+BEGIN_SRC emacs-lisp
(+ 1 2)
#+END_SRC

#+RESULTS:
2
```

So, if you narrow so that only the elisp (+ 1 2) src block is in view, and then evaluate it, the result that's outside of view will be updated to '3'.

This is an issue primarily with libraries that insert IDs where the results are.

Then, when the library searches for that ID it inserted in the narrowed buffer that doesn't contain the RESULTS tag, it won't be able to find it, as it's outside the view.

I believe the proper behavior to be for org-mode to create a new RESULTS tag, and insert 3 in there.

Thoughts?

Best,
Sebastian


             reply	other threads:[~2023-05-03 12:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 22:46 Sebastian Wålinder [this message]
2023-05-04  9:45 ` Babel results don't respect narrowing Ihor Radchenko
     [not found]   ` <87r0qib3ri.fsf@nixos.mail-host-address-is-not-set>
2023-06-11 13:01     ` Ihor Radchenko

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=87mt2r39ru.fsf@nixos.mail-host-address-is-not-set \
    --to=s.walinder@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).