[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orgalist c8fda13 4/4: Do not fill paragraph with next i
From: |
Nicolas Goaziou |
Subject: |
[elpa] externals/orgalist c8fda13 4/4: Do not fill paragraph with next item |
Date: |
Sat, 15 Sep 2018 10:59:43 -0400 (EDT) |
branch: externals/orgalist
commit c8fda13f5faf61205a4be16906e37463b709bae3
Author: Nicolas Goaziou <address@hidden>
Commit: Nicolas Goaziou <address@hidden>
Do not fill paragraph with next item
* orgalist.el (orgalist--fill-forward-wrapper): New function.
(orgalist-mode): When an item follows a paragraph without any blank
line in-between, filling the paragraph no longer fill the item.
---
orgalist.el | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/orgalist.el b/orgalist.el
index 597377f..3a3fc8a 100644
--- a/orgalist.el
+++ b/orgalist.el
@@ -580,6 +580,25 @@ This function is meant to be used as a piece of advice on
t))))
(t nil)))
+(defun orgalist--fill-forward-wrapper (fill-forward-function &rest args)
+ "Fill forward paragraph wrapper.
+
+FILL-FORWARD-FUNCTION is the regular function used to move over
+paragraphs by the filling code.
+
+This function is meant to be used as a piece of advice on
+`fill-forward-paragraph-function'."
+ (if (save-excursion
+ (and (re-search-forward orgalist--bullet-re nil t)
+ (pcase (orgalist--boundaries)
+ (`(,min . ,max)
+ (and (<= min (point))
+ (>= max (point)))))))
+ (let ((paragraph-start
+ (concat "[ \t]*" orgalist--bullet-re "\\|" paragraph-start)))
+ (apply fill-forward-function args))
+ (apply fill-forward-function args)))
+
(defun orgalist--cycle-indentation ()
"Cycle levels of indentation of an empty item.
@@ -794,6 +813,8 @@ C-c C-c `orgalist-check-item'"
(setq-local org-list-two-spaces-after-bullet-regexp nil)
(setq-local org-list-use-circular-motion nil)
(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)
#'orgalist--fill-item)
@@ -821,6 +842,8 @@ C-c C-c `orgalist-check-item'"
(funcall old))))
'((name . orgalist-fix-bug:31361)))))
(t
+ (remove-function (local 'fill-forward-paragraph-function)
+ #'orgalist--fill-forward-wrapper)
(remove-function (local 'fill-paragraph-function) #'orgalist--fill-item)
(remove-function (local 'indent-line-function) #'orgalist--indent-line)
(setq fill-nobreak-predicate