Do not rely on M-q binding for filling src-block

* lisp/org.el (org-fill-element): Use `fill-paragraph' instead of
simulating "M-q" binding.
(org-fill-paragraph): Return t as described in `fill-paragraph'
docstring.

Fixes https://orgmode.org/list/CAH7LOt0PO3js6_+Cbinm6EYNx0KFvpfiSS7Dwc1EXsfHfHkHVA@mail.gmail.com/
This commit is contained in:
Ihor Radchenko 2021-09-01 20:42:05 +08:00 committed by Bastien
parent 0b4e357d62
commit 05ee1e6ee0
1 changed files with 6 additions and 2 deletions

View File

@ -19362,7 +19362,9 @@ a footnote definition, try to fill the first paragraph within."
;; the buffer. In that case, ignore filling.
(cl-case (org-element-type element)
;; Use major mode filling function is source blocks.
(src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
(src-block (org-babel-do-in-edit-buffer
(mark-whole-buffer)
(funcall-interactively #'fill-paragraph justify 'region)))
;; Align Org tables, leave table.el tables as-is.
(table-row (org-table-align) t)
(table
@ -19497,7 +19499,9 @@ filling the current element."
;; previously unmodified), then flip the modification status back
;; to "unchanged".
(when (and hash (equal hash (org-buffer-hash)))
(set-buffer-modified-p nil))))
(set-buffer-modified-p nil))
;; Return non-nil.
t))
(defun org-auto-fill-function ()
"Auto-fill function."