[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] org-babel-demarcate-block: split using org-element instead o
From: |
gerard . vermeulen |
Subject: |
Re: [PATCH] org-babel-demarcate-block: split using org-element instead of regexp |
Date: |
Thu, 04 Jan 2024 08:59:51 +0000 |
On 03.01.2024 16:11, Ihor Radchenko wrote:
gerard.vermeulen@posteo.net writes:
[...]
Attached you'll find a new patch that seems to solve the block
indentation
problem that you have pointed out, see PS or attached patch-demo.org.
test-ob/demarcate-block-split passes.
This was a bug in `org-element-copy'. Fixed, on main now.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dfeff03c5
I did not yet pull your change. Nevertheless, the Emergency exit errors
have disappeared.
[...]
I made some adjustments to the patch, making use of org-element API.
See the attached updated version of the patch.
This patch is heavily edited and I think I did not forget any of your
changes.
I have tried to clean up the code. I have also tried to get `body-beg'
and
`body-end' marking the text between the #+begin_src and #+end_src lines
from the element API, but I failed and had to fall back to
`org-babel-where-is-src-block-head'. But only for that.
I am not yet merging it as I found some weirdness with indentation.
Consider the following (indentation is important):
#+BEGIN_SRC emacs-lisp -n 20
;; This exports with line number 20.
<point> (message "This is line 21")
#+END_SRC
After M-x org-babel-demarcate-block, I am getting
#+BEGIN_SRC emacs-lisp -n 20
;; This exports with line number 20.
#+END_SRC
#+begin_src emacs-lisp -n 20
(message "This is line 21")
#+end_src
See PS or patch-demo.org: PS (hope you read it with a mono-spaced font):
#+begin_src emacs-lisp :results silent
(setopt org-adapt-indentation t
org-src-preserve-indentation nil
org-edit-src-content-indentation 2)
#+end_src
******** before C-u org-babel-demarcate-block splitting
I put point at the left of the last line in this block before
splitting
#+BEGIN_SRC emacs-lisp -n 20
;; this exports with line number 20
<point> (message "This exports with line number 21")
#+END_SRC
C-u C-c C-v d gets the stars right and the indentation
******** after C-u org-babel-demarcate-block splitting
I put point at the left of the last line in this block before
splitting
#+begin_src emacs-lisp -n 20
;; this exports with line number 20
#+end_src
********
#+begin_src emacs-lisp -n 20
(message "This exports with line number 21")
#+end_src
C-u C-c C-v d gets the stars right and the indentation
0001-org-babel-demarcate-block-split-using-org-element-in.patch
Description: Binary data
patch-demo.org
Description: Binary data
- Re: [PATCH] org-babel-demarcate-block: duplicate switches too, gerard . vermeulen, 2024/01/01
- Re: [PATCH] org-babel-demarcate-block: duplicate switches too, Ihor Radchenko, 2024/01/02
- Re: [PATCH] org-babel-demarcate-block: split using org-element instead of regexp, gerard . vermeulen, 2024/01/02
- Re: [PATCH] org-babel-demarcate-block: split using org-element instead of regexp, Ihor Radchenko, 2024/01/03
- Re: [PATCH] org-babel-demarcate-block: split using org-element instead of regexp,
gerard . vermeulen <=
- Re: [PATCH] org-babel-demarcate-block: split using org-element instead of regexp, Ihor Radchenko, 2024/01/04
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/07
- Re: [PATCH] org-babel-demarcate-block: split using element API, Ihor Radchenko, 2024/01/08
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/08
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/09
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/09
- Re: [PATCH] org-babel-demarcate-block: split using element API, Ihor Radchenko, 2024/01/09
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/13
- Re: [PATCH] org-babel-demarcate-block: split using element API, Ihor Radchenko, 2024/01/13
- Re: [PATCH] org-babel-demarcate-block: split using element API, gerard . vermeulen, 2024/01/13