Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Le 01/04/2015 00:14, Nick Dokos a écrit : > > I was thinking of an ob-C.el customizable variable that is set by > default to some useful list of includes, not file-settable things. > But I'm probably the last person you should ask about what is useful > here. Real users should speak up. > > I think augmentation might be nice, but if people are willing to live > with replacement, I'm not going to argue. And if augmentation carries > the day, there always is the vexing question of what to do when you > really *want* replacement, not augmentation. > The situation is as follow. Values for :includes are searched in several locations, in this order: 1) #+BEGIN_SRC C++ :includes 2) org-babel-default-header-args:C++ '(:includes "") 3) org-babel-default-header-args '(:includes "") The search stops as soon as a value is found. Thus we have a "replacement" logic rather than an "augmentation" one. This works for :includes, but also for :defines, and every possible parameter. It also works for C, D, elisp, and any language. It is a generic feature of Babel. To play with it, type C-c C-v I in the source block. The variables are declared in this way: (defvar org-babel-default-header-args:fortran) Maybe they could be changed to: (defcustom org-babel-default-header-args:fortran) to enable customization through Emacs customization facility... Changing from a "replacement" behavior to an "augmentation" one involves changing it for all languages at the same time, because it is implemented in the core of Babel. Moreover, it would require to know which parameters hold single values, and which ones hold lists. Definitely more than a quick and small change.
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Thierry Banel writes: > Le 31/03/2015 12:07, Nicolas Goaziou a écrit : >> >>> IMO, it would be better than the current situation, but I wonder if >>> it makes sense to have a global default setting containing the >>> three files, but one which the user can customize; any :includes >>> parameters would augment the default. >>> >>> That would satisfy the OP's requirements, but would also allow for >>> a shorter #+BEGIN_SRC line. >> I think this suggestion makes sense. While you're at it, would you mind >> implementing it? >> >> > > Well, actually the global default setting feature may already be available > 1) through properties in drawers > 2) through the org-babel-default-header-args global variable > > * Property in drawer > :PROPERTIES: > :includes: > :END: > Any C++ babel block below this tree will inherit the and > #includes > > * The org-babel-default-header-argsvariable > This variable holds global defaults. For C++ do something like that: > (add-to-list 'org-babel-default-header-args '(:includes "" > "")) > Any babel C++ block anywhere will inherit from the global variable. > > Nick, are those the kinds of settings you were thinking about? I was thinking of an ob-C.el customizable variable that is set by default to some useful list of includes, not file-settable things. But I'm probably the last person you should ask about what is useful here. Real users should speak up. > The "augment" feature may be missing though: > local :includes overwrite global ones. I think augmentation might be nice, but if people are willing to live with replacement, I'm not going to argue. And if augmentation carries the day, there always is the vexing question of what to do when you really *want* replacement, not augmentation. Nick
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Le 31/03/2015 12:07, Nicolas Goaziou a écrit : > >> IMO, it would be better than the current situation, but I wonder if >> it makes sense to have a global default setting containing the >> three files, but one which the user can customize; any :includes >> parameters would augment the default. >> >> That would satisfy the OP's requirements, but would also allow for >> a shorter #+BEGIN_SRC line. > I think this suggestion makes sense. While you're at it, would you mind > implementing it? > > Well, actually the global default setting feature may already be available 1) through properties in drawers 2) through the org-babel-default-header-args global variable * Property in drawer :PROPERTIES: :includes: :END: Any C++ babel block below this tree will inherit the and #includes * The org-babel-default-header-argsvariable This variable holds global defaults. For C++ do something like that: (add-to-list 'org-babel-default-header-args '(:includes "" "")) Any babel C++ block anywhere will inherit from the global variable. Nick, are those the kinds of settings you were thinking about? The "augment" feature may be missing though: local :includes overwrite global ones. Thierry
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Hello, Thierry Banel writes: > Ok, 100% of votes are for the removal of wired #includes. > Here is the patch. Tests are changed accordingly. Applied. Thank you. >> IMO, it would be better than the current situation, but I wonder if >> it makes sense to have a global default setting containing the >> three files, but one which the user can customize; any :includes >> parameters would augment the default. >> >> That would satisfy the OP's requirements, but would also allow for >> a shorter #+BEGIN_SRC line. I think this suggestion makes sense. While you're at it, would you mind implementing it? Regards, -- Nicolas Goaziou
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Ok, 100% of votes are for the removal of wired #includes. Here is the patch. Tests are changed accordingly. Thierry Le 30/03/2015 16:39, Nick Dokos a écrit : > > IMO, it would be better than the current situation, but I wonder if > it makes sense to have a global default setting containing the > three files, but one which the user can customize; any :includes > parameters would augment the default. > > That would satisfy the OP's requirements, but would also allow for > a shorter #+BEGIN_SRC line. > > Nick > > >From 89eab423a0084a715456db558a987d6d806c49ba Mon Sep 17 00:00:00 2001 From: Thierry Banel Date: Mon, 30 Mar 2015 21:36:00 +0200 Subject: [PATCH] Remove default #includes in Babel C, C++ * ob-C.el (org-babel-C-expand-C): remove automatic inclusion of , , * ob-C-test.org: adjust C++ tests to manually include required header files. --- lisp/ob-C.el | 1 - testing/examples/ob-C-test.org | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index 0857795..8d5ff2f 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -194,7 +194,6 @@ it's header arguments." nil))) (when (stringp includes) (setq includes (split-string includes))) -(setq includes (append includes '("" "" ""))) (when (stringp defines) (let ((y nil) (result (list t))) diff --git a/testing/examples/ob-C-test.org b/testing/examples/ob-C-test.org index ab744f1..dcd1c48 100644 --- a/testing/examples/ob-C-test.org +++ b/testing/examples/ob-C-test.org @@ -129,7 +129,7 @@ | sunday|4 | #+source: inhomogeneous_table -#+begin_src cpp :var tinomogen=tinomogen :results silent +#+begin_src cpp :var tinomogen=tinomogen :results silent :includes int main() { int i, j; -- 2.1.4
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Thierry Banel writes: > Hi Robert > > Those #includes were a proposal I did long ago. > The purpose was to make short scripts even shorter with default > #includes that everybody uses. > > Your use-case is worth considering. > If this cause trouble, it is easy to remove the includes. > > To keep existing scripts working, an :includes parameter would be > required, like this: > > #+BEGIN_SRC C++ :includes > // C++ script > #+END_SRC > > Does everyone agree with this change? > IMO, it would be better than the current situation, but I wonder if it makes sense to have a global default setting containing the three files, but one which the user can customize; any :includes parameters would augment the default. That would satisfy the OP's requirements, but would also allow for a shorter #+BEGIN_SRC line. Nick
Re: [O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
Hi Robert Those #includes were a proposal I did long ago. The purpose was to make short scripts even shorter with default #includes that everybody uses. Your use-case is worth considering. If this cause trouble, it is easy to remove the includes. To keep existing scripts working, an :includes parameter would be required, like this: #+BEGIN_SRC C++ :includes // C++ script #+END_SRC Does everyone agree with this change? Regards Thierry Le 25/03/2015 03:28, Robert Snapp a écrit : > I must admit I am not a fan of the proposed changes to ob-C.el which seem to > insert > > #include > #include > #include > > during a tangle operation, without option. Currently, I am using C mode to > tangle source written in GLSL (OpenGL shading language), which is > syntactically similar to C. However the inclusion of the three includes > triggers an error when the tangled GLSL files are compiled by OpenGL. I would > appreciate if you either required users to specify each included header file > in the #+src_begin line, or provide an option to suppress the three include > statements described above. Alternatively, one could tangle GLSL files with > the extensions (.glsl, .vert, and .frag) like C files without inserting any > unrequested "#include" statements. > > Thank you for your consideration. > Robert Snapp > >
[O] Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
I must admit I am not a fan of the proposed changes to ob-C.el which seem to insert #include #include #include during a tangle operation, without option. Currently, I am using C mode to tangle source written in GLSL (OpenGL shading language), which is syntactically similar to C. However the inclusion of the three includes triggers an error when the tangled GLSL files are compiled by OpenGL. I would appreciate if you either required users to specify each included header file in the #+src_begin line, or provide an option to suppress the three include statements described above. Alternatively, one could tangle GLSL files with the extensions (.glsl, .vert, and .frag) like C files without inserting any unrequested "#include" statements. Thank you for your consideration. Robert Snapp == Emacs : GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0) of 2014-11-19 on tenten-slave.macports.org Package: Org-mode version 8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/) current state: == (setq org-hide-leading-stars t org-tab-first-hook '(org-hide-block-toggle-maybe org-babel-hide-result-toggle-maybe org-babel-header-arg-expand) org-mobile-files '("~/org/journal.org" "~/org/dates.org" "~/org/todo.org" "~/org/projects/") org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook) org-occur-hook '(org-first-headline-recenter) org-metaup-hook '(org-babel-load-in-session-maybe) org-html-format-drawer-function '(lambda (name contents) contents) org-log-done 'time org-latex-minted-options '(("frame" "lines") ("fontsize" "\\scriptsize") ("bgcolor" "WhiteSmoke")) org-src-window-setup 'current-window org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function org-confirm-shell-link-function 'yes-or-no-p org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "bibtex %b" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o\ %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f") org-latex-format-headline-function 'org-latex-format-headline-default-function org-default-notes-file "~/org//notes.org" org-todo-keyword-faces '(("TODO" :foreground "red" :weight bold) ("WAITING" :foreground "orange" :weight bold) ("CANCELLED" :foreground "purple" :weight bold) ("DONE" :foreground "forest green" :weight bold) ("FIXME" :foreground "red" :weight bold) ("FIXED" :foreground "forest green" :weight bold)) org-capture-templates '(("t" "Todo" entry (file+headline "~/org/todo.org" "Tasks") "* TODO %?\n %i\n %a") ("j" "Journal" entry (file+datetree "~/org/journal.org") "* %U %? %^g\n %i\n %a") ("n" "Notes" entry (file+headline "~/org/notes.org" "Unfiled") "* %?\n %i\n %a") ("p" "Password" entry (file "~/org/sites.gpg") "* %^{Account Name}\n %i\n %[~/org/templates/password.txt]") ) org-after-todo-state-change-hook '(org-clock-out-if-current) org-latex-format-drawer-function '(lambda (name contents) contents) org-from-is-user-regexp "\\" org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer) org-agenda-before-write-hook '(org-agenda-add-entry-text) org-babel-pre-tangle-hook '(save-buffer) org-mode-hook '(#[nil "\300\301\302\303\304$\207" [org-add-hook before-save-hook org-encrypt-entries nil t] 5] turn-on-visual-line-mode er/add-org-mode-expansions #[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook org-show-block-all append local] 5] #[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes #[nil "\300\301!\207" [run-hooks prelude-org-mode-hook] 2] org-journal-update-auto-mode-alist) org-refile-targets '((nil :maxlevel . 1) (org-agenda-files :maxlevel . 1)) org-archive-hook '(org-attach-archive-delete-maybe) org-ascii-format-drawer-function '(lambda (name contents width) contents) org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe) org-directory "~/org/" org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-hide-inline-tasks org-cycle-show-empty-lines org-optimize-window-a