From: Carlos Pita <carlosjosepita@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Feature request: simplify usage of special blocks (for beamer)
Date: Sun, 2 Dec 2018 18:05:14 -0300 [thread overview]
Message-ID: <CAELgYhey8mmqiJqtDdVg9UMJu0BNP8CK3huRwTyETQMBfPVDAg@mail.gmail.com> (raw)
In-Reply-To: <87zhtnk6cx.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]
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 #2: Screenshot_2018-12-02_18:00:22.png --]
[-- Type: image/png, Size: 51957 bytes --]
next prev parent reply other threads:[~2018-12-02 21:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 16:24 Feature request: simplify usage of special blocks (for beamer) Carlos Pita
2018-12-01 18:28 ` Eric S Fraga
2018-12-01 18:41 ` Carlos Pita
2018-12-01 19:23 ` Carlos Pita
2018-12-02 11:58 ` Eric S Fraga
2018-12-02 14:50 ` Carlos Pita
2018-12-02 15:30 ` Carlos Pita
2018-12-02 20:42 ` Nicolas Goaziou
2018-12-02 21:05 ` Carlos Pita [this message]
2018-12-02 11:55 ` Eric S Fraga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAELgYhey8mmqiJqtDdVg9UMJu0BNP8CK3huRwTyETQMBfPVDAg@mail.gmail.com \
--to=carlosjosepita@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).