Rasmus <ras...@gmx.us> writes:

> Here's a new version of the second patch with tests.

Thanks. Some comments follow.

> The recognition regexp is still not great, but the idea of the regexp
> is to only act on includes where there's no :minlevel already and no
> plain words (most obviously src and example, but any block really)
> when disregarding ":key value" pairs.

This is not necessary. Even if :minlevel is used on these include
keywords, its value is ignored when inserting contents of the file.

> * ox.el (org-export-expand-include-keyword): Guess :minlevel if
> missing and relevant.
> * test-ox.el: Tests for automatic :minlevel.

Pleas name test modified.

> +    ;; Add :minlevel to all include words that no explicitly have one.
> +    (save-excursion

No need for that.

> +      (while (re-search-forward
> +           (concat include-re "[ \t]*" "\\(?:\".+?\"\\|[^ \t]+\\)[ \t]*" 
> "\\(.*\\)$")
> +           nil t)

  (re-search-forward include-re nil t)

is enough.

> +     (let ((matched (match-string 1)))
> +       (unless (or (string-match-p ":minlevel" matched)
> +                   ;; matched a normal word
> +                   (string-match "\\(?:^\\|[ \t]+\\)\\(\\w\\)"
> +                                 (replace-regexp-in-string "\\(^\\|[ 
> t]+\\):\\w+[ \t]+\\w+" ""
> +                                                           matched)))

  (unless (search-forward ":minlevel" (line-end-position) t) ...)

> +         (goto-char (line-end-position))

aka (end-of-line)

> +         (insert (format " :minlevel %d"
> +                         (1+ (org-with-wide-buffer
> +                              (if (search-backward-regexp org-heading-regexp 
> nil t)
> +                                  (length (match-string 1))
> +                                0)))))))))

  (insert (format " :minlevel %d" (1+ (org-outline-level))))


Regards,

Reply via email to