From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: fill paragraph: break after sentence. Date: Tue, 06 Sep 2016 11:38:56 +0100 Message-ID: <87d1khz51b.fsf@gmail.com> References: <874m5t308p.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhDmS-0000y7-5j for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 06:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhDmN-0005bi-6M for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 06:39:03 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:38440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhDmN-0005ba-03 for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 06:38:59 -0400 Received: by mail-wm0-x233.google.com with SMTP id 1so181453541wmz.1 for ; Tue, 06 Sep 2016 03:38:58 -0700 (PDT) In-Reply-To: <874m5t308p.fsf@mat.ucm.es> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Uwe Brauer , emacs-orgmode Hi Uwe, The following code is what I use. It uses filladapt mode, but doesn=E2=80= =99t work with auto-fill (I manually refill paragraphs with M-q as I=E2=80=99m writing). I wrote the code a long time ago, it works for me, YMMV, etc. Hope it is helpful. #+BEGIN_SRC emacs-lisp (defun awe-org-fill-paragraph-function (&rest ignore) (let ((bounds (cons (save-excursion (backward-paragraph) (point)) (save-excursion (forward-paragraph) (point)))) beg end end-marker) (save-excursion (goto-char (cdr bounds)) (skip-chars-backward "\n") (setq end-marker (point-marker)) (setq end (make-marker)) (goto-char (car bounds)) (skip-chars-forward "\n") (catch 'exit (while t (setq beg (point)) (forward-sentence) (move-marker end (point)) (save-excursion (goto-char beg) (when (and fill-prefix (not (looking-at-p (regexp-quote fill-prefix)))) (insert fill-prefix)) (while (re-search-forward "\n *" end t) (replace-match " "))) (setq beg (point)) (skip-chars-forward " \n") (move-marker end (point)) (when (>=3D (point) end-marker) (throw 'exit t)) (when (/=3D beg end) (delete-region beg end)) (insert "\n")))) (set-marker end-marker nil) (set-marker end nil))) (defun awe-org-setup-fill-hook () (setq-local sentence-end-base (rx (any ".?!") (? "[fn:" (+ (any "0-9" "a-f")) "]") (* (any "]\"'=E2=80=9D)}")))) (when (featurep 'filladapt) (setq-local fill-paragraph-function #'awe-org-fill-paragraph-function) (make-local-variable 'filladapt-token-table) (make-local-variable 'filladapt-token-match-table) (make-local-variable 'filladapt-token-conversion-table) (cl-pushnew `(,(rx "#+" (or "caption" "CAPTION") ": ") org-caption) filladapt-token-table :test #'equal) (cl-pushnew '(org-caption org-caption) filladapt-token-match-table :test #'equal) (cl-pushnew '(org-caption . exact) filladapt-token-conversion-table :test #'equal)) (visual-line-mode 1) (auto-fill-mode 0)) (add-hook 'org-mode-hook #'awe-org-setup-fill-hook) #+END_SRC --=20 Aaron Ecay