branch: externals/orgalist commit d9ffd2c6105809ae5d9149b9a65bb932996cdc72 Author: Nicolas Goaziou <m...@nicolasgoaziou.fr> Commit: Nicolas Goaziou <m...@nicolasgoaziou.fr>
Fix "Symbol's function definition is void: nil" in Text mode * orgalist.el (orgalist--fill-item): Catch case when `fill-paragraph-function' was initially nil. (orgalist-mode): Advise `fill-paragraph-function' around it, not before. --- orgalist.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/orgalist.el b/orgalist.el index e1f25bd..029209f 100644 --- a/orgalist.el +++ b/orgalist.el @@ -527,17 +527,26 @@ is meant to be used as a piece of advice on both (if item? (orgalist--call-in-item fill-function item?) (funcall fill-function))))))) -(defun orgalist--fill-item (justify) +(defun orgalist--fill-item (fill-function justify) "Fill item as a paragraph. -If JUSTIFY is non-nil, justify as well. +FILL-FUNCTION is the regular function used for filling +paragraphs, or nil. If JUSTIFY is non-nil, justify as well. Return nil outside of a list. This function is meant to be used as a piece of advice on `fill-paragraph-function'." - (let ((item? (orgalist--in-item-p))) - (when item? - (orgalist--call-in-item #'fill-paragraph item? justify) - t))) + (pcase (orgalist--in-item-p) + (`nil + ;; When `fill-paragraph-function' is nil in the current major + ;; mode (e.g.,in Text mode), the advice makes it look like + ;; a function anyway. As a consequence, calling it results in an + ;; error. Catch that error and call plain `fill-paragraph' + ;; instead. + (condition-case nil + (funcall fill-function justify) + (void-function (fill-paragraph justify)))) + (item + (orgalist--call-in-item #'fill-paragraph item justify)))) (defun orgalist--indent-line () "Indent current line in an item. @@ -815,8 +824,7 @@ C-c C-c `orgalist-check-item'" (setq-local org-plain-list-ordered-item-terminator ?.) (add-function :around (local 'fill-forward-paragraph-function) #'orgalist--fill-forward-wrapper) - (add-function :before-until - (local 'fill-paragraph-function) + (add-function :around (local 'fill-paragraph-function) #'orgalist--fill-item) ;; Unless `indent-line-function' is buffer-local before it is ;; advised with `add-function', the workaround for bug#31361 below