From 78b3ba579f56f8a984c9cdaa56f3e730230840e9 Mon Sep 17 00:00:00 2001 From: Tim Showalter Date: Wed, 4 Apr 2018 14:17:42 -0700 Subject: [PATCH] fill while in a comment should behave as in text modes This fixes a bug in fill-paragraph that made adaptive fill not work while in a comment (probably the only time it matters in yaml-mode). This change does what lisp-mode does: first, try fill-comment-paragraph. If fill-comment-paragraph does the fill, great; we're in a comment, and the right thing happens. If it returns nil, it can't do the fill, and we can fall back to the previous method. Without this change, a paragraph break inside a comment, or other things that adaptive fill would generally detect, are not respected. --- yaml-mode.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yaml-mode.el b/yaml-mode.el index c3416dd..9f76c38 100644 --- a/yaml-mode.el +++ b/yaml-mode.el @@ -438,13 +438,15 @@ otherwise do nothing." (defun yaml-fill-paragraph (&optional justify region) "Fill paragraph. -This behaves as `fill-paragraph' except that filling does not -cross boundaries of block literals." +Outside of comments, this behaves as `fill-paragraph' except that +filling does not cross boundaries of block literals. Inside comments, +this will do usual adaptive fill behaviors." (interactive "*P") (save-restriction (yaml-narrow-to-block-literal) (let ((fill-paragraph-function nil)) - (fill-paragraph justify region)))) + (or (fill-comment-paragraph justify) + (fill-paragraph justify region))))) (defun yaml-set-imenu-generic-expression () (make-local-variable 'imenu-generic-expression)