emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Fabio Natali <me@fabionatali.com>, emacs-orgmode@gnu.org
Subject: Re: `org-fill-paragraph' (`M-q') in Org Mode source blocks
Date: Mon, 10 Jan 2022 19:50:59 +0000	[thread overview]
Message-ID: <cf166d70-a1db-4e66-960b-59ce7c0ce359@posteo.eu> (raw)
In-Reply-To: <YdsVc5ReHWxo3Zx+@localhost>

Hi,

Fabio Natali writes:
> Is there anything obvious that you think I'm missing here? Is anyone
> able to replicate the above behaviour and, if so, do you also find it
> slightly problematic? Any thoughts and feedback on the above will be
> greatly appreciated.:)

It's not just you. I think org-fill-paragraph should try to act
natively if called from inside a src block.

As it happens, I've recently added the following advice to my init
file.

(defun my-org-fill-paragraph-natively-maybe ()
   (let* ((element (save-excursion (beginning-of-line) 
(org-element-at-point-no-context)))
          (type (org-element-type element)))
     (if (and (eq type 'src-block)
              (> (line-beginning-position)
                 (org-element-property :post-affiliated element))
              (< (line-beginning-position)
                 (org-with-point-at (org-element-property :end element)
                   (skip-chars-backward " \t\n")
                   (line-beginning-position))))
         (progn
           (org-babel-do-in-edit-buffer (fill-paragraph))
           nil) t)))
(advice-add 'org-fill-paragraph :before-while 
#'my-org-fill-paragraph-natively-maybe)

Regards,

-- 
Sébastien Miquel



  reply	other threads:[~2022-01-10 19:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 17:03 `org-fill-paragraph' (`M-q') in Org Mode source blocks Fabio Natali
2022-01-10 19:50 ` Sébastien Miquel [this message]
2022-01-11 13:30   ` Fabio Natali
2022-01-11 19:32     ` Rudolf Adamkovič
2022-01-11 20:09     ` Sébastien Miquel
2022-10-03  6:51       ` Ihor Radchenko
2022-10-03  7:18         ` Sébastien Miquel
2022-10-03  9:23           ` Ihor Radchenko
2022-10-04 16:36             ` Sébastien Miquel
2022-10-05  5:22               ` 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=cf166d70-a1db-4e66-960b-59ce7c0ce359@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=me@fabionatali.com \
    /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).