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 via email to