0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-07-16 06:46:26 +00:00

org-list: ignore lines with org-example property when creating structure

* lisp/org-list.el (org-list-struct): when a line has org-example
  property, skip the entire block. This is needed during export, for
  example when src blocks in org markup contain lists, and are
  returned verbatim because org isn't in the list of interpreted
  languages.
This commit is contained in:
Nicolas Goaziou 2011-01-23 00:32:03 +01:00
parent d309256aff
commit dcf23c416f

View file

@ -621,8 +621,8 @@ Assume point is at an item."
(text-min-ind 10000) (text-min-ind 10000)
(item-re (org-item-re)) (item-re (org-item-re))
(drawers-re (concat "^[ \t]*:\\(" (drawers-re (concat "^[ \t]*:\\("
(mapconcat 'regexp-quote org-drawers "\\|") (mapconcat 'regexp-quote org-drawers "\\|")
"\\):[ \t]*$")) "\\):[ \t]*$"))
(inlinetask-re (and (featurep 'org-inlinetask) (inlinetask-re (and (featurep 'org-inlinetask)
(org-inlinetask-outline-regexp))) (org-inlinetask-outline-regexp)))
(beg-cell (cons (point) (org-get-indentation))) (beg-cell (cons (point) (org-get-indentation)))
@ -661,14 +661,22 @@ Assume point is at an item."
;; Jump to part 2. ;; Jump to part 2.
(throw 'exit (throw 'exit
(setq itm-lst (setq itm-lst
(if (not (looking-at item-re)) (if (or (not (looking-at item-re))
(get-text-property (point) 'org-example))
(memq (assq (car beg-cell) itm-lst) itm-lst) (memq (assq (car beg-cell) itm-lst) itm-lst)
(setq beg-cell (cons (point) ind)) (setq beg-cell (cons (point) ind))
(cons (funcall assoc-at-point ind) itm-lst))))) (cons (funcall assoc-at-point ind) itm-lst)))))
;; At a verbatim block, go before its beginning. Move
;; from eol to ensure `previous-single-property-change'
;; will return a value.
((get-text-property (point) 'org-example)
(goto-char (previous-single-property-change
(point-at-eol) 'org-example nil lim-up))
(forward-line -1))
;; Looking at a list ending regexp. Dismiss useless
;; data recorded above BEG-CELL. Jump to part 2.
((and (not (eq org-list-ending-method 'indent)) ((and (not (eq org-list-ending-method 'indent))
(looking-at org-list-end-re)) (looking-at org-list-end-re))
;; Looking at a list ending regexp. Dismiss useless
;; data recorded above BEG-CELL. Jump to part 2.
(throw 'exit (throw 'exit
(setq itm-lst (setq itm-lst
(memq (assq (car beg-cell) itm-lst) itm-lst)))) (memq (assq (car beg-cell) itm-lst) itm-lst))))
@ -732,10 +740,16 @@ Assume point is at an item."
;; part 3. ;; part 3.
(throw 'exit (throw 'exit
(push (cons 0 (funcall end-before-blank)) end-lst-2))) (push (cons 0 (funcall end-before-blank)) end-lst-2)))
;; At a verbatim block, move to its end. Point is at bol
;; and 'org-example property is set by whole lines:
;; `next-single-property-change' always return a value.
((get-text-property (point) 'org-example)
(goto-char
(next-single-property-change (point) 'org-example nil lim-down)))
;; Looking at a list ending regexp. Save point as an
;; ending position and jump to part 3.
((and (not (eq org-list-ending-method 'indent)) ((and (not (eq org-list-ending-method 'indent))
(looking-at org-list-end-re)) (looking-at org-list-end-re))
;; Looking at a list ending regexp. Save point as an
;; ending position and jump to part 3.
(throw 'exit (push (cons 0 (point-at-bol)) end-lst-2))) (throw 'exit (push (cons 0 (point-at-bol)) end-lst-2)))
;; Skip blocks, drawers, inline tasks and blank lines ;; Skip blocks, drawers, inline tasks and blank lines
;; along the way ;; along the way
@ -765,14 +779,14 @@ Assume point is at an item."
;; ;;
;; - ind is lesser or equal than previous item's. This ;; - ind is lesser or equal than previous item's. This
;; is an ending position. Store it and proceed. ;; is an ending position. Store it and proceed.
(cond (cond
((eq org-list-ending-method 'regexp)) ((eq org-list-ending-method 'regexp))
((<= ind (cdr beg-cell)) ((<= ind (cdr beg-cell))
(push (cons ind (funcall end-before-blank)) end-lst-2) (push (cons ind (funcall end-before-blank)) end-lst-2)
(throw 'exit nil)) (throw 'exit nil))
((<= ind (nth 1 (car itm-lst-2))) ((<= ind (nth 1 (car itm-lst-2)))
(push (cons ind (point-at-bol)) end-lst-2))) (push (cons ind (point-at-bol)) end-lst-2)))
(forward-line 1)))))) (forward-line 1))))))
(setq struct (append itm-lst (cdr (nreverse itm-lst-2)))) (setq struct (append itm-lst (cdr (nreverse itm-lst-2))))
(setq end-lst (append end-lst (cdr (nreverse end-lst-2)))) (setq end-lst (append end-lst (cdr (nreverse end-lst-2))))
;; 3. Correct ill-formed lists by making sure top item has the ;; 3. Correct ill-formed lists by making sure top item has the