From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4EaPJtmQ616pMAAA0tVLHw (envelope-from ) for ; Thu, 18 Jun 2020 16:05:45 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GPKCItmQ615pOAAAB5/wlQ (envelope-from ) for ; Thu, 18 Jun 2020 16:05:45 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D59A39404CB for ; Thu, 18 Jun 2020 16:05:44 +0000 (UTC) Received: from localhost ([::1]:48334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlx2r-0001kq-V8 for larch@yhetil.org; Thu, 18 Jun 2020 12:05:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlx10-0000Sk-92 for emacs-orgmode@gnu.org; Thu, 18 Jun 2020 12:03:46 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:36804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlx0y-0005IN-6l for emacs-orgmode@gnu.org; Thu, 18 Jun 2020 12:03:45 -0400 Received: by mail-wr1-x42a.google.com with SMTP id q11so6648366wrp.3 for ; Thu, 18 Jun 2020 09:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=glkPLWjWe83PNGu69hZV80DbiHpHcNZXDQCGJCnrZG8=; b=jmtqU/af+mioES5+5bz/mY9M3Z4TEsa7XPQCp99zM5xTgOZQnSgG98wbKsyxZvfOsN NtCFb+RKJ3dWslwPf93w7pSIHcLDEQJrjDD9fzBaddXR5RQNetzWOx3K6NcnXuHqLljn fX74+amfJvBty7ZjXP2KyPFVqLy4i+nXFOnL7AJUhQt89t4m3S7Cd+ilw+giGs5rFiRA 3eYMnuMWurZLNPzOnccJ8ROFmuAzuya3KuV3ulrSIyo6WA4YOd/pX7IYf37V0hhdvR+P qsi2eTzqK9BYW21Vi98vzPLTBB3DesWJ+H8CjuEhWeNa3zI8IY6IhspH9WXzgSR0By/6 eA4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=glkPLWjWe83PNGu69hZV80DbiHpHcNZXDQCGJCnrZG8=; b=jjy+fNxrYvSfZUY89x+J7Q4PwUqPPfQzyw/G+RA8P1i0IP6APrOqnHlga+lWQoUy68 vIaYRUjgaE7zb9OyRJKImp8GZazYonV+nBXGD4dt1N7z2hJTORxWadCUVTS4N2sJT4MF a0hhlFdLTLRW1ky7+hNhpII0L+t5KinVfvx8Usvc+CvT1hE1asRztjCY+rHKcG2oDXgP Kq6XwejwvYdhvt+oMTFn3QDQK55ZrJXkZquZW4/h7c17iuK7qriX7xSSW87NiAR0iWXf tweJSgeO29w5nUh73ybkR7/h8xrR2b1J41xNtITBitgjbJTjwaDiLNDGlhFDjuw0NRwX +44A== X-Gm-Message-State: AOAM533UMIZdyyWET+Pt/27d6EWP8Fxdfx26Qv3M0tKOB90J1r1vl+IV zeCtEx8vzrdB6DA4WkzOb2yT+J5/eerd0yiabHK+wOnEeI8= X-Google-Smtp-Source: ABdhPJxvGjOx4rRUbi8htRJmgg269H7pNA2dS+9k8gYO4I7muFl8epbXNRWy1Qf37eLe5uSOp+KaxhTqla0nRsR+aZs= X-Received: by 2002:a5d:5092:: with SMTP id a18mr5320500wrt.42.1592496221508; Thu, 18 Jun 2020 09:03:41 -0700 (PDT) MIME-Version: 1.0 From: Douglas Perrin Date: Thu, 18 Jun 2020 12:03:30 -0400 Message-ID: Subject: Re: Import Reusable org-babel snippet using #+SETUPFILE To: emacs-orgmode@gnu.org Content-Type: multipart/alternative; boundary="00000000000096d8e205a85deb5b" Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=doug2024@gmail.com; helo=mail-wr1-x42a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jmtqU/af; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.29 X-TUID: i8VLSd2Ts3Ay --00000000000096d8e205a85deb5b Content-Type: text/plain; charset="UTF-8" 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)) (org-babel-remove-result)) )) )) ;;; interactive version that ignores PROPERTIES and clears all results (defun CHAI-ClearResultsNow () (interactive) (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) #+end_src 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: #+name:GeneralORGTools_Init #+BEGIN_SRC elisp ;; nice org-mode setting to remove newlines from the outline (setq org-cycle-separator-lines 0) #+end_src **correction from my previous post**: (org-sbe "GeneralORGTools.org") ' should have been a call to the init (org-sbe ":GeneralORGTools_Init") Regards Doug --00000000000096d8e205a85deb5b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Salomon,
Babel definitions, in this case, = lots of elsip blocks to add behaviors like this example to clear bloc resul= ts on save to avoid polluting=C2=A0commits that can be turned on and off pe= r section with properties.

#+name: Clear-Resu= lts-On-Save
#+begin_src emacs-lisp :results none
;;; co= de to clean up org-file results on save
(defun CHAI-ClearResultsO= nSave ()
=C2=A0 (when (eq major-mode 'org-mode)
=C2= =A0 =C2=A0 (org-babel-map-executables nil=C2=A0
=C2=A0 =C2=A0 =C2= =A0 (cond ((equal "true" (org-entry-get nil "ClearOnSave&quo= t; t t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-bab= el-remove-result))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ))
=C2=A0 =C2=A0 ))

;;; interactive version = that ignores PROPERTIES and clears all results
(defun CHAI-ClearR= esultsNow ()
=C2=A0 (interactive)
=C2=A0 (when (eq majo= r-mode 'org-mode)
=C2=A0 =C2=A0 (org-babel-map-executables ni= l (org-babel-remove-result))
=C2=A0 =C2=A0 ))

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

In this case, the=C2=A0init block in=C2=A0the 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 t= his case it is=C2=A0not very interesting:

#+n= ame:GeneralORGTools_Init
#+BEGIN_SRC elisp
=C2=A0 ;; ni= ce org-mode setting to remove newlines from the outline
=C2=A0 (s= etq org-cycle-separator-lines 0)
=C2=A0#+end_src
=
**correction from my previous post**:
=C2=A0(org-s= be "GeneralORGTools.org") '
should have been a = call to the init=C2=A0
(org-sbe ":GeneralORGTools_Init"= )

Regards
Doug
--00000000000096d8e205a85deb5b--