From 372daea6cbee60df03f1a68bd5fabca4212a12c3 Mon Sep 17 00:00:00 2001 From: Javier Olaechea Date: Wed, 20 Apr 2022 11:58:07 -0500 Subject: [PATCH] lisp/org.el: Allow org-c-l-b-f to handle an empty fill-prefix * org.el (org-comment-line-break-function): When fill-prefix is nil, don't call `insert-before-markers-and-inherit'. The default value for fill-prefix is nil, `insert-before-markers-and-inherit' expects a string. This results in an error when calling `org-comment-line-break-function', bound to M-j, on a vanilla installation of Emacs. We should add a guard checking that fill-prefix is not nill before calling i-b-m-a-i. The only exception is when adaptive-fill-mode is enabled. This is the approach that that rest of the code in Emacs takes. Some call-sites listed below: * simple.el (default-indent-new-line): uses (and fill-prefix (not adaptive-fill-mode) ...) * newcomment.el (comment-indent-new-line): uses (and fill-prefix (not adaptive-fill-mode) ...) * fill.el (fill-new-line): uses (and fill-prefix (not (equal fill-prefix "")) ...) TINYCHANGE --- lisp/org.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 2353c6594..4176c683f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19943,7 +19943,8 @@ (defun org-comment-line-break-function (&optional soft) (save-excursion (forward-char -1) (delete-horizontal-space)) (delete-horizontal-space) (indent-to-left-margin) - (insert-before-markers-and-inherit fill-prefix)) + (and fill-prefix (not adaptive-fill-mode) + (insert-before-markers-and-inherit fill-prefix))) ;;; Fixed Width Areas -- 2.29.2.154.g7f7ebe054a