all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: sebastien.miquel@posteo.eu
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]
Date: Mon, 03 Jul 2023 13:05:41 +0000	[thread overview]
Message-ID: <87cz19gn6i.fsf@localhost> (raw)
In-Reply-To: <8d6dd95e-5bce-44c3-638a-52351b69cc66@posteo.eu>

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

>> May you please provide an example when it is necessary?
>> `org-indent-line' will run `org-babel-do-key-sequence-in-edit-buffer', so
>> it should still use `org-src--contents-for-write-back' and will not
>> modify the org buffer text directly.
>
> You're at the end of a line, you press =org-return-and-indent=.
>   1. It adds a newline character.
>   2. =org-indent-line= adds the org indentation, _before_ calling
>      =org-babel-do-key-sequence-in-edit-buffer=

I missed this:

             ;; At the beginning of a blank line, do some preindentation.  This
             ;; signals org-src--edit-element to preserve the indentation on exit

>   3. The native edit call removes the common indentation, before
>      calling tab in the native buffer.
>   4. Calling tab in the native buffer possibly does nothing.
>   5. =org-src--contents-for-write-back= sees the current line is empty,
>      but it should indent it (with org indentation) nonetheless.

Ok. I understand better now (I think).

We are talking about

\t#+begin_src bash
\tcd foo<point>
\t#+end_src

and user pressing <RET>
Then, the expected result is

\t#+begin_src bash
\tcd foo
\t<point>
\t#+end_src

with <point> being aligned with "cd foo" above.

Alternatively,

\t#+begin_src emacs-lisp
\t(when t<point>
\t#+end_src

<RET> should yield indentation in src block as well

\t#+begin_src emacs-lisp
\t(when t
\t  <point>
\t#+end_src

-------------

For the second scenario, no special treatment of current line is needed.
For the first scenario, why do we need to do it all the way in
`org-src--contents-for-write-back'? Why not directly in
`org-indent-line'?

>> Before your change, all the blank non-empty lines were unconditionally
>> removed. After your change, the first such line is removed and the
>> function returns nil without continuing.
>
> I don't understand. With this change, the function only stops if it
> finds a non blank line with less than n indentation (same as before).
> When a blank line with less than n indentation is found, it is emptied
> (same as before), and execution continues.

Never mind this. I misread the code. Thought that `throw' is called on
blank lines.

>> Since not removing blank lines is intentional after the change, why
>> doing it on a single line that is indented less than N?
>
> Are you advocating for computing N using blank lines as well ?

No. It was a misunderstanding.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-07-03 13:06 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-11 22:33 [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)] wolf
2023-06-14 12:16 ` Ihor Radchenko
2023-06-17 19:11   ` Sébastien Miquel
2023-06-18 11:16     ` Ihor Radchenko
2023-06-19  8:43       ` Sébastien Miquel
2023-06-19 11:05         ` Ihor Radchenko
2023-06-19 15:32           ` Sébastien Miquel
2023-06-20 10:02             ` Ihor Radchenko
2023-06-21  5:46               ` Sébastien Miquel
2023-06-25 10:46               ` Ihor Radchenko
2023-06-26 11:14               ` Sébastien Miquel
2023-06-26 11:45                 ` Sébastien Miquel
2023-06-26 11:52                 ` Ihor Radchenko
2023-06-26 12:15                   ` Sébastien Miquel
2023-06-26 12:44                     ` Ihor Radchenko
2023-06-27  8:54                       ` Sébastien Miquel
2023-06-28  9:21                         ` Ihor Radchenko
2023-06-29 15:54                           ` Sébastien Miquel
2023-06-30 11:43                             ` Ihor Radchenko
2023-06-30 20:27                               ` Sébastien Miquel
2023-07-01 11:07                                 ` Ihor Radchenko
2023-07-01 17:17                                   ` Sébastien Miquel
2023-07-03  9:58                                     ` Ihor Radchenko
2023-07-03 12:49                                       ` Sébastien Miquel
2023-07-03 13:05                                         ` Ihor Radchenko [this message]
2023-07-03 13:48                                           ` Sébastien Miquel
2023-07-04 10:41                                             ` Ihor Radchenko
2023-07-06 11:01                                               ` Sébastien Miquel
2023-07-07  9:26                                                 ` Ihor Radchenko
2023-07-07  9:54                                                   ` Ihor Radchenko
2023-07-07 13:21                                                     ` Sébastien Miquel
2023-07-08  8:44                                                       ` Ihor Radchenko
2023-07-09 11:10                                                         ` Sébastien Miquel
2023-07-10  8:22                                                           ` Ihor Radchenko
2023-07-07  9:31                                                 ` [BUG] org-list-struct-apply-struct overrides src block indentation (was: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]) Ihor Radchenko
2023-07-07 13:43                                                   ` Sébastien Miquel
2023-07-08  9:06                                                     ` 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

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

  git send-email \
    --in-reply-to=87cz19gn6i.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=sebastien.miquel@posteo.eu \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.