From: Dan Hackney <dan@haxney.org>
To: emacs-orgmode@gnu.org
Cc: Dan Hackney <dan@haxney.org>
Subject: [PATCH 2/2] Fix adaptive filling.
Date: Mon, 1 Mar 2010 08:49:10 -0500 [thread overview]
Message-ID: <1267451350-5023-2-git-send-email-dan@haxney.org> (raw)
In-Reply-To: <1267451350-5023-1-git-send-email-dan@haxney.org>
For paragraph text, `org-adaptive-fill-function' did not handle the base case of
regular text which needed to be filled. This commit saves a buffer-local value
of `adaptive-fill-regexp' and uses it if none of the org-specific regexps match.
This allows email-style ">" comments to be filled correctly.
Signed-off-by: Dan Hackney <dan@haxney.org>
---
lisp/org.el | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 8ba782a..073061e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17289,6 +17289,12 @@ which make use of the date at the cursor."
t t))
(org-move-to-column column)))
+(defvar org-adaptive-fill-regexp-backup adaptive-fill-regexp
+ "Variable to store copy of `adaptive-fill-regexp'.
+Since `adaptive-fill-regexp' is set to never match, we need to
+store a backup of its value before entering `org-mode' so that
+the functionality can be provided as a fall-back.")
+
(defun org-set-autofill-regexps ()
(interactive)
;; In the paragraph separator we include headlines, because filling
@@ -17324,8 +17330,11 @@ which make use of the date at the cursor."
;; and fixed-width regions are not wrapped. That function will pass
;; through to `fill-paragraph' when appropriate.
(org-set-local 'fill-paragraph-function 'org-fill-paragraph)
- ; Adaptive filling: To get full control, first make sure that
+ ;; Adaptive filling: To get full control, first make sure that
;; `adaptive-fill-regexp' never matches. Then install our own matcher.
+ (unless (local-variable-p 'adaptive-fill-regexp)
+ (org-set-local 'org-adaptive-fill-regexp-backup
+ adaptive-fill-regexp))
(org-set-local 'adaptive-fill-regexp "\000")
(org-set-local 'adaptive-fill-function
'org-adaptive-fill-function)
@@ -17354,8 +17363,11 @@ which make use of the date at the cursor."
"Return a fill prefix for org-mode files.
In particular, this makes sure hanging paragraphs for hand-formatted lists
work correctly."
- (cond ((looking-at "#[ \t]+")
- (match-string 0))
+ (cond
+ ;; Comment line
+ ((looking-at "#[ \t]+")
+ (match-string-no-properties 0))
+ ;; Description list
((looking-at "[ \t]*\\([-*+] .*? :: \\)")
(save-excursion
(if (> (match-end 1) (+ (match-beginning 1)
@@ -17363,11 +17375,14 @@ work correctly."
(goto-char (+ (match-beginning 1) 5))
(goto-char (match-end 0)))
(make-string (current-column) ?\ )))
- ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] ?\\)?")
+ ;; Ordered or unordered list
+ ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] ?\\)")
(save-excursion
(goto-char (match-end 0))
(make-string (current-column) ?\ )))
- (t nil)))
+ ;; Other text
+ ((looking-at org-adaptive-fill-regexp-backup)
+ (match-string-no-properties 0))))
;;; Other stuff.
--
1.6.3.3
next prev parent reply other threads:[~2010-03-01 13:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-01 13:49 [PATCH 1/2] org-babel-oz: Fix line-endings Dan Hackney
2010-03-01 13:49 ` Dan Hackney [this message]
2010-03-03 12:48 ` [PATCH 2/2] Fix adaptive filling Carsten Dominik
2010-03-03 20:06 ` Austin Frank
2010-03-04 1:17 ` Samuel Wales
2010-03-04 1:25 ` Daniel Hackney
2010-03-11 17:13 ` Carsten Dominik
2010-03-12 2:55 ` Austin Frank
2010-03-12 4:57 ` Samuel Wales
2010-03-15 15:48 ` Carsten Dominik
2010-03-15 19:04 ` Daniel Hackney
2010-03-15 19:16 ` Carsten Dominik
2010-06-03 15:11 ` Daniel Hackney
2010-03-01 15:31 ` [PATCH 1/2] org-babel-oz: Fix line-endings Eric Schulte
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1267451350-5023-2-git-send-email-dan@haxney.org \
--to=dan@haxney.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.