summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-12-18 19:32:40 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-12-18 19:32:50 +0100
commit7739e8b5f7d81319b647043c2a9f6d9ef7eb813b (patch)
tree406d4b3035fe7dd4e0bd5886aea3fa8d97f0ce54
parent374efdd63e22215984bf2c8a8c54862788797130 (diff)
downloadorg-mode-7739e8b5f7d81319b647043c2a9f6d9ef7eb813b.tar.gz
Small refactoring
* lisp/org.el (org-fill-paragraph): Small refactoring.
-rw-r--r--lisp/org.el32
1 files changed, 15 insertions, 17 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 93ec8d6..362cb3b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20993,22 +20993,18 @@ width for filling.
For convenience, when point is at a plain list, an item or
a footnote definition, try to fill the first paragraph within."
(interactive)
- (cond ;; First ensure filling in correct in message-mode
- ((and (derived-mode-p 'message-mode)
- (or (not (message-in-body-p))
- (save-excursion (move-beginning-of-line 1)
- (looking-at message-cite-prefix-regexp))))
- (let ((fill-paragraph-function
- (cadadr (assoc 'fill-paragraph-function org-fb-vars)))
- (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars)))
- (paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars)))
- (paragraph-separate
- (cadadr (assoc 'paragraph-separate org-fb-vars))))
- (fill-paragraph nil)))
- ;; Correct filling in source block
- ((org-in-src-block-p)
- (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
- (t
+ (if (and (derived-mode-p 'message-mode)
+ (or (not (message-in-body-p))
+ (save-excursion (move-beginning-of-line 1)
+ (looking-at message-cite-prefix-regexp))))
+ ;; First ensure filling is correct in message-mode.
+ (let ((fill-paragraph-function
+ (cadadr (assoc 'fill-paragraph-function org-fb-vars)))
+ (fill-prefix (cadadr (assoc 'fill-prefix org-fb-vars)))
+ (paragraph-start (cadadr (assoc 'paragraph-start org-fb-vars)))
+ (paragraph-separate
+ (cadadr (assoc 'paragraph-separate org-fb-vars))))
+ (fill-paragraph nil))
(save-excursion
;; Move to end of line in order to get the first paragraph
;; within a plain list or a footnote definition.
@@ -21018,6 +21014,8 @@ a footnote definition, try to fill the first paragraph within."
;; the buffer. In that case, ignore filling.
(if (< (point) (org-element-property :begin element)) t
(case (org-element-type element)
+ ;; Use major mode filling function is src blocks.
+ (src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
;; Align Org tables, leave table.el tables as-is.
(table-row (org-table-align) t)
(table
@@ -21094,7 +21092,7 @@ a footnote definition, try to fill the first paragraph within."
;; Fill comments.
(comment (fill-comment-paragraph justify))
;; Ignore every other element.
- (otherwise t))))))))
+ (otherwise t)))))))
(defun org-auto-fill-function ()
"Auto-fill function."