From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: [PATCH 2/2] Fix adaptive filling. Date: Wed, 3 Mar 2010 18:17:22 -0700 Message-ID: <20524da71003031717r34fc6e35xcd8305d1428133da@mail.gmail.com> References: <1267451350-5023-1-git-send-email-dan@haxney.org> <1267451350-5023-2-git-send-email-dan@haxney.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nmzgt-0007v9-MQ for emacs-orgmode@gnu.org; Wed, 03 Mar 2010 20:17:27 -0500 Received: from [140.186.70.92] (port=38323 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nmzgs-0007uQ-Gu for emacs-orgmode@gnu.org; Wed, 03 Mar 2010 20:17:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nmzgq-0000ZL-M4 for emacs-orgmode@gnu.org; Wed, 03 Mar 2010 20:17:26 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:37377) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nmzgq-0000YY-Gr for emacs-orgmode@gnu.org; Wed, 03 Mar 2010 20:17:24 -0500 Received: by fxm22 with SMTP id 22so2285781fxm.26 for ; Wed, 03 Mar 2010 17:17:22 -0800 (PST) In-Reply-To: <1267451350-5023-2-git-send-email-dan@haxney.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Hackney Cc: emacs-orgmode@gnu.org How will the new value of a non-org variable affect filladapt.el? On 2010-03-01, Dan Hackney wrote: > 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 > --- > 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 > > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > -- Q: How many CDC "scientists" does it take to change a lightbulb? A: "You only think it's dark." [CDC has denied a deadly disease for 25 years] ========== Retrovirus: http://www.wpinstitute.org/xmrv/index.html