mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-23 07:18:53 +00:00
Revert "Fix c9a52787c14c3a7429bcd3c8975350525e0baa04"
This reverts commit 359572d37e
.
COMMENT headlines are expected to be ignored completely during export.
This commit is contained in:
parent
2e9a1d9c84
commit
fa0cc0ab70
@ -83,31 +83,28 @@ Return an alist containing all macro templates found."
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
"^[ \t]*#\\+\\(MACRO\\|SETUPFILE\\):" nil t)
|
||||
(if (org-in-commented-heading-p) (outline-next-heading)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (eq (org-element-type element) 'keyword)
|
||||
(let ((val (org-element-property :value element)))
|
||||
(if (equal (org-element-property :key element) "MACRO")
|
||||
;; Install macro in TEMPLATES.
|
||||
(when (string-match
|
||||
"^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$"
|
||||
val)
|
||||
(let* ((name (match-string 1 val))
|
||||
(template (or (match-string 2 val) ""))
|
||||
(old-cell (assoc name templates)))
|
||||
(if old-cell (setcdr old-cell template)
|
||||
(push (cons name template) templates))))
|
||||
;; Enter setup file.
|
||||
(let ((file (expand-file-name
|
||||
(org-remove-double-quotes val))))
|
||||
(unless (member file files)
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert (org-file-contents file 'noerror))
|
||||
(setq templates
|
||||
(funcall collect-macros
|
||||
(cons file files)
|
||||
templates))))))))))))
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (eq (org-element-type element) 'keyword)
|
||||
(let ((val (org-element-property :value element)))
|
||||
(if (equal (org-element-property :key element) "MACRO")
|
||||
;; Install macro in TEMPLATES.
|
||||
(when (string-match
|
||||
"^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$" val)
|
||||
(let* ((name (match-string 1 val))
|
||||
(template (or (match-string 2 val) ""))
|
||||
(old-cell (assoc name templates)))
|
||||
(if old-cell (setcdr old-cell template)
|
||||
(push (cons name template) templates))))
|
||||
;; Enter setup file.
|
||||
(let ((file (expand-file-name
|
||||
(org-remove-double-quotes val))))
|
||||
(unless (member file files)
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert (org-file-contents file 'noerror))
|
||||
(setq templates
|
||||
(funcall collect-macros (cons file files)
|
||||
templates)))))))))))
|
||||
templates))))
|
||||
(funcall collect-macros nil nil)))
|
||||
|
||||
|
130
lisp/ox.el
130
lisp/ox.el
@ -1479,7 +1479,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||
(and backend (org-export-get-all-options backend))
|
||||
org-export-options-alist))
|
||||
(regexp (format "^[ \t]*#\\+%s:"
|
||||
(regexp-opt (nconc (delq nil (mapcar #'cadr options))
|
||||
(regexp-opt (nconc (delq nil (mapcar 'cadr options))
|
||||
org-export-special-keywords))))
|
||||
(find-properties
|
||||
(lambda (keyword)
|
||||
@ -1496,67 +1496,62 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward regexp nil t)
|
||||
(if (org-in-commented-heading-p) (outline-next-heading)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (eq (org-element-type element) 'keyword)
|
||||
(let ((key (org-element-property :key element))
|
||||
(val (org-element-property :value element)))
|
||||
(cond
|
||||
;; Options in `org-export-special-keywords'.
|
||||
((equal key "SETUPFILE")
|
||||
(let ((file (expand-file-name
|
||||
(org-remove-double-quotes
|
||||
(org-trim val)))))
|
||||
;; Avoid circular dependencies.
|
||||
(unless (member file files)
|
||||
(with-temp-buffer
|
||||
(insert (org-file-contents file 'noerror))
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
(setq plist
|
||||
(funcall get-options
|
||||
(cons file files) plist))))))
|
||||
((equal key "OPTIONS")
|
||||
(setq plist
|
||||
(org-combine-plists
|
||||
plist
|
||||
(org-export--parse-option-keyword
|
||||
val backend))))
|
||||
((equal key "FILETAGS")
|
||||
(setq plist
|
||||
(org-combine-plists
|
||||
plist
|
||||
(list :filetags
|
||||
(org-uniquify
|
||||
(append (org-split-string val ":")
|
||||
(plist-get plist :filetags)))))))
|
||||
(t
|
||||
;; Options in `org-export-options-alist'.
|
||||
(dolist (property (funcall find-properties key))
|
||||
(let ((behaviour (nth 4 (assq property options))))
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist property
|
||||
;; Handle value depending on
|
||||
;; specified BEHAVIOUR.
|
||||
(case behaviour
|
||||
(space
|
||||
(if (not (plist-get plist property))
|
||||
(org-trim val)
|
||||
(concat (plist-get plist property)
|
||||
" "
|
||||
(org-trim val))))
|
||||
(newline
|
||||
(org-trim
|
||||
(concat (plist-get plist property)
|
||||
"\n"
|
||||
(org-trim val))))
|
||||
(split `(,@(plist-get plist property)
|
||||
,@(org-split-string val)))
|
||||
((t) val)
|
||||
(otherwise
|
||||
(if (plist-member plist property)
|
||||
(plist-get plist property)
|
||||
val))))))))))))))
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (eq (org-element-type element) 'keyword)
|
||||
(let ((key (org-element-property :key element))
|
||||
(val (org-element-property :value element)))
|
||||
(cond
|
||||
;; Options in `org-export-special-keywords'.
|
||||
((equal key "SETUPFILE")
|
||||
(let ((file (expand-file-name
|
||||
(org-remove-double-quotes (org-trim val)))))
|
||||
;; Avoid circular dependencies.
|
||||
(unless (member file files)
|
||||
(with-temp-buffer
|
||||
(insert (org-file-contents file 'noerror))
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
(setq plist (funcall get-options
|
||||
(cons file files) plist))))))
|
||||
((equal key "OPTIONS")
|
||||
(setq plist
|
||||
(org-combine-plists
|
||||
plist
|
||||
(org-export--parse-option-keyword val backend))))
|
||||
((equal key "FILETAGS")
|
||||
(setq plist
|
||||
(org-combine-plists
|
||||
plist
|
||||
(list :filetags
|
||||
(org-uniquify
|
||||
(append (org-split-string val ":")
|
||||
(plist-get plist :filetags)))))))
|
||||
(t
|
||||
;; Options in `org-export-options-alist'.
|
||||
(dolist (property (funcall find-properties key))
|
||||
(let ((behaviour (nth 4 (assq property options))))
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist property
|
||||
;; Handle value depending on specified
|
||||
;; BEHAVIOR.
|
||||
(case behaviour
|
||||
(space
|
||||
(if (not (plist-get plist property))
|
||||
(org-trim val)
|
||||
(concat (plist-get plist property)
|
||||
" "
|
||||
(org-trim val))))
|
||||
(newline
|
||||
(org-trim
|
||||
(concat (plist-get plist property)
|
||||
"\n"
|
||||
(org-trim val))))
|
||||
(split `(,@(plist-get plist property)
|
||||
,@(org-split-string val)))
|
||||
('t val)
|
||||
(otherwise
|
||||
(if (not (plist-member plist property)) val
|
||||
(plist-get plist property))))))))))))))
|
||||
;; Return final value.
|
||||
plist))))
|
||||
;; Read options in the current buffer.
|
||||
@ -2670,6 +2665,16 @@ The function assumes BUFFER's major mode is `org-mode'."
|
||||
(overlays-in (point-min) (point-max)))
|
||||
ov-set)))))
|
||||
|
||||
(defun org-export--delete-commented-subtrees ()
|
||||
"Delete commented subtrees or inlinetasks in the buffer."
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(let ((regexp (concat org-outline-regexp-bol org-comment-string)))
|
||||
(while (re-search-forward regexp nil t)
|
||||
(delete-region
|
||||
(line-beginning-position)
|
||||
(org-element-property :end (org-element-at-point)))))))
|
||||
|
||||
(defun org-export--prune-tree (data info)
|
||||
"Prune non exportable elements from DATA.
|
||||
DATA is the parse tree to traverse. INFO is the plist holding
|
||||
@ -2860,6 +2865,7 @@ Return code as a string."
|
||||
(run-hook-with-args 'org-export-before-processing-hook
|
||||
(org-export-backend-name backend))
|
||||
(org-export-expand-include-keyword)
|
||||
(org-export--delete-commented-subtrees)
|
||||
;; Update macro templates since #+INCLUDE keywords might have
|
||||
;; added some new ones.
|
||||
(org-macro-initialize-templates)
|
||||
|
@ -48,6 +48,7 @@ body to execute. Parse tree is available under the `tree'
|
||||
variable, and communication channel under `info'."
|
||||
(declare (debug (form body)) (indent 1))
|
||||
`(org-test-with-temp-text ,data
|
||||
(org-export--delete-commented-subtrees)
|
||||
(let* ((tree (org-element-parse-buffer))
|
||||
(info (org-export-get-environment)))
|
||||
(org-export--prune-tree tree info)
|
||||
|
Loading…
Reference in New Issue
Block a user