summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-07-14 15:40:12 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2010-09-01 19:05:46 +0200
commit47cd0c193de0f10c32230df726e8255c25f647b4 (patch)
tree4d8ef6ceadff66d3fc91b0dc058ba2838a9735f9
parent168a8b60072a0b5edc73fb49cc740d7f586ddeb7 (diff)
downloadorg-mode-47cd0c193de0f10c32230df726e8255c25f647b4.tar.gz
Make parsing of lists more powerful during export.
* org-list.el (org-search-backward-unenclosed): Do not stop in protected places. * org-list.el (org-search-forward-unenclosed): Do not stop in protected places. * org-latex.el (org-export-latex-lists): Use the fact that org-search-forward do not stop anymore at protected places.
-rw-r--r--lisp/org-latex.el25
-rw-r--r--lisp/org-list.el47
2 files changed, 39 insertions, 33 deletions
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 838cc68..b7b4f39 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2239,19 +2239,18 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(let (res)
(goto-char (point-min))
(while (org-search-forward-unenclosed (org-item-re) nil t)
- (org-if-unprotected
- (beginning-of-line)
- (setq res (org-list-to-latex (org-list-parse-list t)
- org-export-latex-list-parameters))
- (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
- res)
- (setq res (replace-match
- (concat (format "\\setcounter{enumi}{%d}"
- (1- (string-to-number
- (match-string 2 res))))
- "\n"
- (match-string 1 res))
- t t res))))
+ (beginning-of-line)
+ (setq res (org-list-to-latex (org-list-parse-list t)
+ org-export-latex-list-parameters))
+ (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
+ res)
+ (setq res (replace-match
+ (concat (format "\\setcounter{enumi}{%d}"
+ (1- (string-to-number
+ (match-string 2 res))))
+ "\n"
+ (match-string 1 res))
+ t t res)))
(insert res "\n"))))
(defconst org-latex-entities
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 7bc86da..158f4f1 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -266,26 +266,31 @@ the end of the nearest terminator from max."
(match-beginning 0)))))
(defun org-search-backward-unenclosed (regexp &optional bound noerror count)
- "Like `re-search-backward' but don't stop inside blocks or throw errors.
+ "Like `re-search-backward' but don't stop inside blocks or at protected places.
+This function does not throw errors.
-Optional fourth argument COUNT searches for that many occurrences,
-valid or not, then makes sure the last one is valid."
+Optional fourth argument COUNT searches for that many
+occurrences, valid or not, then makes sure the last one is
+valid."
(let ((origin (point)))
(cond
;; nothing found: return nil
((not (re-search-backward regexp bound (or noerror t) count)) nil)
- ;; match is not enclosed: return point.
- ((not (save-match-data
- (org-in-regexps-block-p "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)"
- '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2)))))
- (point))
- (t
- ;; else: we start again, searching one more occurrence away.
+ ;; match is enclosed or protected: start again, searching one
+ ;; more occurrence away.
+ ((or (save-match-data
+ (org-in-regexps-block-p "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)"
+ '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2))))
+ (get-text-property (match-beginning 0) 'org-protected))
(goto-char origin)
- (org-search-backward-unenclosed regexp bound noerror (1+ (or count 1)))))))
+ (org-search-backward-unenclosed regexp bound noerror (1+ (or count 1))))
+ ;; else return point.
+ (t
+ (point)))))
(defun org-search-forward-unenclosed (regexp &optional bound noerror count)
- "Like `re-search-forward' but don't stop inside blocks or throw errors.
+ "Like `re-search-forward' but don't stop inside blocks or at protected places.
+This function does not throw errors.
Optional fourth argument COUNT searches for that many occurrences,
valid or not, then makes sure the last one is valid."
@@ -293,15 +298,17 @@ valid or not, then makes sure the last one is valid."
(cond
;; nothing found: return nil
((not (re-search-forward regexp bound (or noerror t) count)) nil)
- ;; match is not enclosed: return point.
- ((not (save-match-data
- (org-in-regexps-block-p "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)"
- '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2)))))
- (point))
- ;; else: we start again, searching one more occurrence away.
- (t
+ ;; match is enclosed or protected: start again, searching one
+ ;; more occurrence away.
+ ((or (save-match-data
+ (org-in-regexps-block-p "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)"
+ '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2))))
+ (get-text-property (match-beginning 0) 'org-protected))
(goto-char origin)
- (org-search-forward-unenclosed regexp bound noerror (1+ (or count 1)))))))
+ (org-search-forward-unenclosed regexp bound noerror (1+ (or count 1))))
+ ;; else return point.
+ (t
+ (point)))))
(defun org-get-item-same-level-internal (search-fun pos limit pre-move)
"Return point at the beginning of next item at the same level.