From: Federico Beffa <beffa@ieee.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line
Date: Thu, 7 Aug 2014 15:56:13 +0200 [thread overview]
Message-ID: <CAKrPhPMB+wmQCfX11nP+dR5Wb19_=m4d7QXTqUdfuOOLNUw90Q@mail.gmail.com> (raw)
> 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
next reply other threads:[~2014-08-07 13:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 13:56 Federico Beffa [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-08-10 13:15 [PATCH] org.el: make org-paragraph-fill ignore \[...\] regions starting and ending a line Federico Beffa
2014-08-10 13:13 Federico Beffa
2014-08-11 13:06 ` Nicolas Goaziou
2014-08-11 18:27 ` Federico Beffa
2014-08-11 19:43 ` Rasmus
2014-08-11 20:44 ` Nicolas Goaziou
2014-08-16 7:50 ` Federico Beffa
2014-08-16 9:46 ` Nicolas Goaziou
2014-08-11 20:40 ` Nicolas Goaziou
2014-08-16 7:38 ` Federico Beffa
2014-08-28 10:10 ` Nicolas Goaziou
2014-08-05 21:45 Federico Beffa
2014-08-09 8:00 ` Nicolas Goaziou
2014-08-09 10:20 ` Federico Beffa
2014-08-09 23:20 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKrPhPMB+wmQCfX11nP+dR5Wb19_=m4d7QXTqUdfuOOLNUw90Q@mail.gmail.com' \
--to=beffa@ieee.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).