emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Feature request: simplify usage of special blocks (for beamer)


From: Carlos Pita
Subject: Re: [O] Feature request: simplify usage of special blocks (for beamer)
Date: Sun, 2 Dec 2018 18:05:14 -0300

Hi Nicolas,

fair enough if you feel it's not worth the hassle.

I'm pasting here a simple filter implementing the rule I described
above (use the special arg if present and if it doesn't conflict with
any ATTR directive for the current backend) for anyone interested, if
any at all:

(defun my-org-special-block-filter (tree backend _symbol)
  (pcase-let ((`(,prop ,fmt)
               (cond ((org-export-derived-backend-p backend 'latex)
                      '(:attr_latex ":options [%s]")))))
    (when prop
      (org-element-map tree 'special-block
        (lambda (element)
          (unless (org-element-property prop element)
            (save-excursion
              (goto-char (org-element-property :begin element))
              (when (re-search-forward "#\\+BEGIN_\\S-+[ \t]+\\(.+\\)" nil t)
                (let ((attr (format fmt (match-string-no-properties 1))))
                  (org-element-put-property element prop (list attr))))))
          nil)))))

It can easily be extended to other backends by just adding a new
clause to the cond at the beginning.

This plus a little extra font locking allows me to edit my
presentations like the attached screenshot shows. I think it's quite
an improvement over subsectioning and ignoreheading cruft but it must
be said that, although it looks nicer, it's only a marginal
improvement over special blocks plus affiliated ATTRs.

Best regards
--
Carlos

Attachment: Screenshot_2018-12-02_18:00:22.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]