From 2ff317ece235890da5e1f8246dba08d585b0fbaa Mon Sep 17 00:00:00 2001 Message-Id: <2ff317ece235890da5e1f8246dba08d585b0fbaa.1630500712.git.yantar92@gmail.com> From: Ihor Radchenko Date: Wed, 1 Sep 2021 20:42:05 +0800 Subject: [PATCH] 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/ --- lisp/org.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ce68f4692..601526e84 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19486,7 +19486,9 @@ (defun org-fill-element (&optional justify) ;; 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 @@ -19621,7 +19623,9 @@ (defun org-fill-paragraph (&optional justify region) ;; 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." -- 2.31.1