From b2ec5b804223acf36c42f096bfd8d654be8eaa6f Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 11 Dec 2012 07:17:13 -0700 Subject: [PATCH 2/2] consolidate Babel defcustoms in ob.el --- lisp/ob-core.el | 25 --------- lisp/ob-exp.el | 45 ---------------- lisp/ob-lob.el | 7 --- lisp/ob-tangle.el | 71 ------------------------- lisp/ob.el | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+), 148 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 7b4ee92..04264a2 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -119,31 +119,6 @@ remove code block execution from the C-c C-c keybinding." ;; don't allow this variable to be changed through file settings (put 'org-confirm-babel-evaluate 'safe-local-variable (lambda (x) (eq x t))) -(defcustom org-babel-no-eval-on-ctrl-c-ctrl-c nil - "Remove code block evaluation from the C-c C-c key binding." - :group 'org-babel - :version "24.1" - :type 'boolean) - -(defcustom org-babel-results-keyword "RESULTS" - "Keyword used to name results generated by code blocks. -Should be either RESULTS or NAME however any capitalization may -be used." - :group 'org-babel - :type 'string) - -(defcustom org-babel-noweb-wrap-start "<<" - "String used to begin a noweb reference in a code block. -See also `org-babel-noweb-wrap-end'." - :group 'org-babel - :type 'string) - -(defcustom org-babel-noweb-wrap-end ">>" - "String used to end a noweb reference in a code block. -See also `org-babel-noweb-wrap-start'." - :group 'org-babel - :type 'string) - (defun org-babel-noweb-wrap (&optional regexp) (concat org-babel-noweb-wrap-start (or regexp "\\([^ \t\n].+?[^ \t]\\|[^ \t\n]\\)") diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index e2be94d..d61b1e6 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -50,15 +50,6 @@ (declare-function org-element-type "org-element" (element)) (declare-function org-escape-code-in-string "org-src" (s)) -(defcustom org-export-babel-evaluate t - "Switch controlling code evaluation during export. -When set to nil no code will be evaluated as part of the export -process." - :group 'org-babel - :version "24.1" - :type 'boolean) -(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil))) - (defun org-babel-exp-get-export-buffer () "Return the current export buffer if possible." (cond @@ -128,23 +119,6 @@ Assume point is at the beginning of block's starting line." (setf hash (org-babel-sha1-hash info))) (org-babel-exp-do-export info 'block hash))))) -(defcustom org-babel-exp-call-line-template - "" - "Template used to export call lines. -This template may be customized to include the call line name -with any export markup. The template is filled out using -`org-fill-template', and the following %keys may be used. - - line --- call line - -An example value would be \"\\n: call: %line\" to export the call line -wrapped in a verbatim environment. - -Note: the results are inserted separately after the contents of -this template." - :group 'org-babel - :type 'string) - (defvar org-babel-default-lob-header-args) (defun org-babel-exp-non-block-elements (start end) "Process inline source and call lines between START and END for export." @@ -333,25 +307,6 @@ The function respects the value of the :exports header argument." ('both (org-babel-exp-results info type nil hash) (org-babel-exp-code info))))) -(defcustom org-babel-exp-code-template - "#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC" - "Template used to export the body of code blocks. -This template may be customized to include additional information -such as the code block name, or the values of particular header -arguments. The template is filled out using `org-fill-template', -and the following %keys may be used. - - lang ------ the language of the code block - name ------ the name of the code block - body ------ the body of the code block - flags ----- the flags passed to the code block - -In addition to the keys mentioned above, every header argument -defined for the code block may be used as a key and will be -replaced with its value." - :group 'org-babel - :type 'string) - (defun org-babel-exp-code (info) "Return the original code block formatted for export." (setf (nth 1 info) diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el index 5c21db7..8dd9f58 100644 --- a/lisp/ob-lob.el +++ b/lisp/ob-lob.el @@ -35,13 +35,6 @@ This is an association list. Populate the library by adding files to `org-babel-lob-files'.") -(defcustom org-babel-lob-files '() - "Files used to populate the `org-babel-library-of-babel'. -To add files to this list use the `org-babel-lob-ingest' command." - :group 'org-babel - :version "24.1" - :type 'list) - (defvar org-babel-default-lob-header-args '((:exports . "results")) "Default header arguments to use when exporting #+lob/call lines.") diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 697a269..25beabe 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -37,77 +37,6 @@ (declare-function org-babel-update-block-body "org" (new-body)) (declare-function make-directory "files" (dir &optional parents)) -(defcustom org-babel-tangle-lang-exts - '(("emacs-lisp" . "el")) - "Alist mapping languages to their file extensions. -The key is the language name, the value is the string that should -be inserted as the extension commonly used to identify files -written in this language. If no entry is found in this list, -then the name of the language is used." - :group 'org-babel-tangle - :version "24.1" - :type '(repeat - (cons - (string "Language name") - (string "File Extension")))) - -(defcustom org-babel-post-tangle-hook nil - "Hook run in code files tangled by `org-babel-tangle'." - :group 'org-babel - :version "24.1" - :type 'hook) - -(defcustom org-babel-pre-tangle-hook '(save-buffer) - "Hook run at the beginning of `org-babel-tangle'." - :group 'org-babel - :version "24.1" - :type 'hook) - -(defcustom org-babel-tangle-body-hook nil - "Hook run over the contents of each code block body." - :group 'org-babel - :version "24.1" - :type 'hook) - -(defcustom org-babel-tangle-comment-format-beg "[[%link][%source-name]]" - "Format of inserted comments in tangled code files. -The following format strings can be used to insert special -information into the output using `org-fill-template'. -%start-line --- the line number at the start of the code block -%file --------- the file from which the code block was tangled -%link --------- Org-mode style link to the code block -%source-name -- name of the code block - -Whether or not comments are inserted during tangling is -controlled by the :comments header argument." - :group 'org-babel - :version "24.1" - :type 'string) - -(defcustom org-babel-tangle-comment-format-end "%source-name ends here" - "Format of inserted comments in tangled code files. -The following format strings can be used to insert special -information into the output using `org-fill-template'. -%start-line --- the line number at the start of the code block -%file --------- the file from which the code block was tangled -%link --------- Org-mode style link to the code block -%source-name -- name of the code block - -Whether or not comments are inserted during tangling is -controlled by the :comments header argument." - :group 'org-babel - :version "24.1" - :type 'string) - -(defcustom org-babel-process-comment-text #'org-babel-trim - "Function called to process raw Org-mode text collected to be -inserted as comments in tangled source-code files. The function -should take a single string argument and return a string -result. The default value is `org-babel-trim'." - :group 'org-babel - :version "24.1" - :type 'function) - (defun org-babel-find-file-noselect-refresh (file) "Find file ensuring that the latest changes on disk are represented in the file." diff --git a/lisp/ob.el b/lisp/ob.el index 3010503..0f189b3 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -32,6 +32,162 @@ (require 'ob-ref) (require 'ob-tangle) + +;;; Core defcustoms +(defcustom org-babel-no-eval-on-ctrl-c-ctrl-c nil + "Remove code block evaluation from the C-c C-c key binding." + :group 'org-babel + :version "24.1" + :type 'boolean) + +(defcustom org-babel-results-keyword "RESULTS" + "Keyword used to name results generated by code blocks. +Should be either RESULTS or NAME however any capitalization may +be used." + :group 'org-babel + :type 'string) + +(defcustom org-babel-noweb-wrap-start "<<" + "String used to begin a noweb reference in a code block. +See also `org-babel-noweb-wrap-end'." + :group 'org-babel + :type 'string) + +(defcustom org-babel-noweb-wrap-end ">>" + "String used to end a noweb reference in a code block. +See also `org-babel-noweb-wrap-start'." + :group 'org-babel + :type 'string) + + +;;; Export defcustoms +(defcustom org-export-babel-evaluate t + "Switch controlling code evaluation during export. +When set to nil no code will be evaluated as part of the export +process." + :group 'org-babel + :version "24.1" + :type 'boolean) +(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil))) + +(defcustom org-babel-exp-call-line-template + "" + "Template used to export call lines. +This template may be customized to include the call line name +with any export markup. The template is filled out using +`org-fill-template', and the following %keys may be used. + + line --- call line + +An example value would be \"\\n: call: %line\" to export the call line +wrapped in a verbatim environment. + +Note: the results are inserted separately after the contents of +this template." + :group 'org-babel + :type 'string) + +(defcustom org-babel-exp-code-template + "#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC" + "Template used to export the body of code blocks. +This template may be customized to include additional information +such as the code block name, or the values of particular header +arguments. The template is filled out using `org-fill-template', +and the following %keys may be used. + + lang ------ the language of the code block + name ------ the name of the code block + body ------ the body of the code block + flags ----- the flags passed to the code block + +In addition to the keys mentioned above, every header argument +defined for the code block may be used as a key and will be +replaced with its value." + :group 'org-babel + :type 'string) + + +;;; Tangle defcustoms +(defcustom org-babel-tangle-lang-exts + '(("emacs-lisp" . "el")) + "Alist mapping languages to their file extensions. +The key is the language name, the value is the string that should +be inserted as the extension commonly used to identify files +written in this language. If no entry is found in this list, +then the name of the language is used." + :group 'org-babel-tangle + :version "24.1" + :type '(repeat + (cons + (string "Language name") + (string "File Extension")))) + +(defcustom org-babel-post-tangle-hook nil + "Hook run in code files tangled by `org-babel-tangle'." + :group 'org-babel + :version "24.1" + :type 'hook) + +(defcustom org-babel-pre-tangle-hook '(save-buffer) + "Hook run at the beginning of `org-babel-tangle'." + :group 'org-babel + :version "24.1" + :type 'hook) + +(defcustom org-babel-tangle-body-hook nil + "Hook run over the contents of each code block body." + :group 'org-babel + :version "24.1" + :type 'hook) + +(defcustom org-babel-tangle-comment-format-beg "[[%link][%source-name]]" + "Format of inserted comments in tangled code files. +The following format strings can be used to insert special +information into the output using `org-fill-template'. +%start-line --- the line number at the start of the code block +%file --------- the file from which the code block was tangled +%link --------- Org-mode style link to the code block +%source-name -- name of the code block + +Whether or not comments are inserted during tangling is +controlled by the :comments header argument." + :group 'org-babel + :version "24.1" + :type 'string) + +(defcustom org-babel-tangle-comment-format-end "%source-name ends here" + "Format of inserted comments in tangled code files. +The following format strings can be used to insert special +information into the output using `org-fill-template'. +%start-line --- the line number at the start of the code block +%file --------- the file from which the code block was tangled +%link --------- Org-mode style link to the code block +%source-name -- name of the code block + +Whether or not comments are inserted during tangling is +controlled by the :comments header argument." + :group 'org-babel + :version "24.1" + :type 'string) + +(defcustom org-babel-process-comment-text #'org-babel-trim + "Function called to process raw Org-mode text collected to be +inserted as comments in tangled source-code files. The function +should take a single string argument and return a string +result. The default value is `org-babel-trim'." + :group 'org-babel + :version "24.1" + :type 'function) + + +;;; Export defcustoms +(defcustom org-babel-lob-files '() + "Files used to populate the `org-babel-library-of-babel'. +To add files to this list use the `org-babel-lob-ingest' command." + :group 'org-babel + :version "24.1" + :type 'list) + (provide 'ob) ;; Local variables: -- 1.8.0.1