Browse Source

org.el: Autoload `org-element-at-point' instead of requiring org-element it in some commands

* org.el (org-element-at-point): Autoload.
(org-element-up): Remove useless declaration.
(org-fill-context-prefix, org-fill-paragraph)
(org-mark-element, org-narrow-to-element)
(org-transpose-element, org-unindent-buffer): Do not require
org-element.
Bastien Guerry 13 years ago
parent
commit
d6db2566d9
1 changed files with 2 additions and 9 deletions
  1. 2 9
      lisp/org.el

+ 2 - 9
lisp/org.el

@@ -18719,13 +18719,14 @@ this function returns t, nil otherwise."
 		(throw 'exit t))))
 		(throw 'exit t))))
 	nil))))
 	nil))))
 
 
+(autoload 'org-element-at-point "org-element")
+
 (declare-function org-element-at-point "org-element" (&optional keep-trail))
 (declare-function org-element-at-point "org-element" (&optional keep-trail))
 (declare-function org-element-type "org-element" (element))
 (declare-function org-element-type "org-element" (element))
 (declare-function org-element-contents "org-element" (element))
 (declare-function org-element-contents "org-element" (element))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-paragraph-parser "org-element" (limit))
 (declare-function org-element-paragraph-parser "org-element" (limit))
 (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion))
 (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion))
-(declare-function org-element-up "org-element" ())
 (declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
 (declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
 (declare-function org-element--parse-objects "org-element" (beg end acc restriction))
 (declare-function org-element--parse-objects "org-element" (beg end acc restriction))
@@ -20961,9 +20962,6 @@ Return fill prefix, as a string, or nil if current line isn't
 meant to be filled."
 meant to be filled."
   (org-with-wide-buffer
   (org-with-wide-buffer
    (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p)))
    (unless (and (derived-mode-p 'message-mode) (not (message-in-body-p)))
-     ;; FIXME: Prevent an error for users who forgot to make autoloads?
-     ;; See also `org-fill-paragraph', which has the same.
-     (require 'org-element)
      ;; FIXME: This is really the job of orgstruct++-mode
      ;; FIXME: This is really the job of orgstruct++-mode
      (goto-char p)
      (goto-char p)
      (beginning-of-line)
      (beginning-of-line)
@@ -21038,7 +21036,6 @@ a footnote definition, try to fill the first paragraph within."
     (save-excursion
     (save-excursion
       ;; Move to end of line in order to get the first paragraph within
       ;; Move to end of line in order to get the first paragraph within
       ;; a plain list or a footnote definition.
       ;; a plain list or a footnote definition.
-      (require 'org-element)
       (end-of-line)
       (end-of-line)
       (let ((element (org-element-at-point)))
       (let ((element (org-element-at-point)))
 	;; First check if point is in a blank line at the beginning of the
 	;; First check if point is in a blank line at the beginning of the
@@ -21980,7 +21977,6 @@ Interactively, if this command is repeated or (in Transient Mark
 mode) if the mark is active, it marks the next element after the
 mode) if the mark is active, it marks the next element after the
 ones already marked."
 ones already marked."
   (interactive)
   (interactive)
-  (require 'org-element)
   (let (deactivate-mark)
   (let (deactivate-mark)
     (if (and (org-called-interactively-p 'any)
     (if (and (org-called-interactively-p 'any)
 	     (or (and (eq last-command this-command) (mark t))
 	     (or (and (eq last-command this-command) (mark t))
@@ -21998,7 +21994,6 @@ ones already marked."
 (defun org-narrow-to-element ()
 (defun org-narrow-to-element ()
   "Narrow buffer to current element."
   "Narrow buffer to current element."
   (interactive)
   (interactive)
-  (require 'org-element)
   (let ((elem (org-element-at-point)))
   (let ((elem (org-element-at-point)))
     (cond
     (cond
      ((eq (car elem) 'headline)
      ((eq (car elem) 'headline)
@@ -22019,7 +22014,6 @@ ones already marked."
   "Transpose current and previous elements, keeping blank lines between.
   "Transpose current and previous elements, keeping blank lines between.
 Point is moved after both elements."
 Point is moved after both elements."
   (interactive)
   (interactive)
-  (require 'org-element)
   (org-skip-whitespace)
   (org-skip-whitespace)
   (let ((end (org-element-property :end (org-element-at-point))))
   (let ((end (org-element-property :end (org-element-at-point))))
     (org-drag-element-backward)
     (org-drag-element-backward)
@@ -22033,7 +22027,6 @@ modified."
   (interactive)
   (interactive)
   (unless (eq major-mode 'org-mode)
   (unless (eq major-mode 'org-mode)
     (error "Cannot un-indent a buffer not in Org mode"))
     (error "Cannot un-indent a buffer not in Org mode"))
-  (require 'org-element)
   (let* ((parse-tree (org-element-parse-buffer 'greater-element))
   (let* ((parse-tree (org-element-parse-buffer 'greater-element))
 	 unindent-tree			; For byte-compiler.
 	 unindent-tree			; For byte-compiler.
 	 (unindent-tree
 	 (unindent-tree