emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Douglas Perrin <doug2024@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Import Reusable org-babel snippet using #+SETUPFILE
Date: Thu, 18 Jun 2020 12:03:30 -0400	[thread overview]
Message-ID: <CAFw+bXFgCSFYhHVu0sxiSv1WjKpkbLNwdYTgDgjeaNGXhMPKrA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]

Hi Salomon,
Babel definitions, in this case, lots of elsip blocks to add behaviors like
this example to clear bloc results on save to avoid polluting commits that
can be turned on and off per section with properties.

#+name: Clear-Results-On-Save
#+begin_src emacs-lisp :results none
;;; code to clean up org-file results on save
(defun CHAI-ClearResultsOnSave ()
  (when (eq major-mode 'org-mode)
    (org-babel-map-executables nil
      (cond ((equal "true" (org-entry-get nil "ClearOnSave" t t))

;;; interactive version that ignores PROPERTIES and clears all results
(defun CHAI-ClearResultsNow ()
  (when (eq major-mode 'org-mode)
    (org-babel-map-executables nil (org-babel-remove-result))

;;; add the hook before saving a file
(add-hook 'before-save-hook 'CHAI-ClearResultsOnSave nil t)

In this case, the init block in the template.org file would have an org-sbe
call to "Clear-Results-On-Save" after ingesting GeneralORGTools.org if I
wanted that behavior. By convention, I always have an init bloc but in this
case it is not very interesting:

#+BEGIN_SRC elisp
  ;; nice org-mode setting to remove newlines from the outline
  (setq org-cycle-separator-lines 0)

**correction from my previous post**:
 (org-sbe "GeneralORGTools.org") '
should have been a call to the init
(org-sbe ":GeneralORGTools_Init")


[-- Attachment #2: Type: text/html, Size: 2266 bytes --]

             reply	other threads:[~2020-06-18 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 16:03 Douglas Perrin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-06-15 19:52 Import Reusable org-babel snippet using #+SETUPFILE Douglas Perrin
2020-06-16 15:21 ` Salomon Turgman
2020-06-17 14:23   ` Salomon Turgman
2020-06-09 17:28 Salomon Turgman
2020-06-09 23:09 ` Nicolas Goaziou

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:

  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=CAFw+bXFgCSFYhHVu0sxiSv1WjKpkbLNwdYTgDgjeaNGXhMPKrA@mail.gmail.com \
    --to=doug2024@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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


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).