From 578a7f5aa5e01ec847b9da4cbd31a4376fb946e2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 5 May 2012 08:13:43 +0200 Subject: [PATCH] New option `org-src-prevent-auto-filling' defaulting to nil. * org.el (org-src-prevent-auto-filling): New option to prevent auto-filling in src blocks. This defaults to nil to avoid people being surprised that no auto-fill occurs in Org buffers where they use `auto-fill-mode'. (org-auto-fill-function): Use the new option. Thanks to Ken Williams for this feature request and to Charles C. Berry for a preliminary patch for this. --- lisp/org.el | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 8cdb79958..5f707d7b0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5411,6 +5411,13 @@ will be prompted for." :group 'org-appearance :group 'org-babel) +(defcustom org-src-prevent-auto-filling nil + "When non-nil, prevent auto-filling in src blocks." + :type 'boolean + :version "24.1" + :group 'org-appearance + :group 'org-babel) + (defun org-fontify-meta-lines-and-blocks (limit) (condition-case nil (org-fontify-meta-lines-and-blocks-1 limit) @@ -20754,18 +20761,19 @@ the functionality can be provided as a fall-back.") (defun org-auto-fill-function () "Auto-fill function." - (let (itemp prefix) - ;; When in a list, compute an appropriate fill-prefix and make - ;; sure it will be used by `do-auto-fill'. - (cond ((setq itemp (org-in-item-p)) - (progn - (setq prefix (make-string (org-list-item-body-column itemp) ?\ )) - (flet ((fill-context-prefix (from to &optional flr) prefix)) - (do-auto-fill)))) - (orgstruct-is-++ - (orgstruct++-ignore-org-filling - (do-auto-fill))) - (t (do-auto-fill))))) + (unless (and org-src-prevent-auto-filling (org-in-src-block-p)) + (let (itemp prefix) + ;; When in a list, compute an appropriate fill-prefix and make + ;; sure it will be used by `do-auto-fill'. + (cond ((setq itemp (org-in-item-p)) + (progn + (setq prefix (make-string (org-list-item-body-column itemp) ?\ )) + (flet ((fill-context-prefix (from to &optional flr) prefix)) + (do-auto-fill)))) + (orgstruct-is-++ + (orgstruct++-ignore-org-filling + (do-auto-fill))) + (t (do-auto-fill)))))) ;;; Other stuff.