[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions start
From: |
Federico Beffa |
Subject: |
[O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line |
Date: |
Thu, 7 Aug 2014 15:56:13 +0200 |
> Attached you find a patch with the proposed modification. I would
> greatly appreciate if you could consider it for inclusion in org-mode
> and provide feedback.
Here a more lispy version of the function
`org-fill-paragraph-construct-regions' used in the patch.I guess it
could be more appealing to people on this list :-)
(defun org-fill-paragraph-construct-regions (lbl dmrl)
"Construct paragraph regions to be filled.
This function takes an ordered list LBL with the positions of org
`line-break' objects and an ordered list DMRL with the start and
end positions of \\=\\[...\\=\\] LaTeX macros beginning and
ending a line. It returns a list of the form ((r1-beg r1-end)
... (rN-beg rN-end)) with the start end end positions of the
paragraph regions to be filled."
(let ((lbl-len (length lbl))) ; compute only once length of lbl
(or
;; elementary case 1: no display math regions and 2 entries in lbl
(and (not dmrl)
(eq lbl-len 2)
(list lbl))
;; elementary case 2: 1 remaining line break (end of paragraph) and
;; 1 remaining display math region.
(and (eq (length dmrl) 1)
(eq lbl-len 1)
(list (list (nth 1 dmrl) (car lbl))))
;; remove line-breaks within display math regions
(and dmrl (>= (nth 1 lbl) (caar dmrl))
(<= (nth 1 lbl) (nth 1 (car dmrl)))
(if (> lbl-len 2)
(org-fill-paragraph-construct-regions2
(cons (car lbl) (cddr lbl))
dmrl)
;; a displayed math region finished the paragraph
(org-fill-paragraph-construct-regions2
(cons (car lbl) (list (caar dmrl)))
nil)))
;; non elementary cases:
(if (and dmrl (> (nth 1 lbl) (caar dmrl)))
(cons (list (car lbl) (caar dmrl))
(org-fill-paragraph-construct-regions2
(cons (nth 1 (car dmrl)) (cdr lbl))
(cdr dmrl)))
(cons (list (car lbl) (nth 1 lbl))
(org-fill-paragraph-construct-regions2
(cdr lbl)
dmrl))))))
Regards,
Federico
- [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Federico Beffa, 2014/08/05
- [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line,
Federico Beffa <=
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Federico Beffa, 2014/08/10
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Nicolas Goaziou, 2014/08/11
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Federico Beffa, 2014/08/11
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Rasmus, 2014/08/11
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Nicolas Goaziou, 2014/08/11
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Federico Beffa, 2014/08/16
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Nicolas Goaziou, 2014/08/16
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Nicolas Goaziou, 2014/08/11
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Federico Beffa, 2014/08/16
- Re: [O] [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line, Nicolas Goaziou, 2014/08/28