* Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
@ 2015-03-25 2:28 Robert Snapp
2015-03-29 20:48 ` Thierry Banel
0 siblings, 1 reply; 8+ messages in thread
From: Robert Snapp @ 2015-03-25 2:28 UTC (permalink / raw)
To: emacs-orgmode
I must admit I am not a fan of the proposed changes to ob-C.el which seem to insert
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
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 "\\<Robert Snapp\\>"
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-after-visibility-change)
org-tags-exclude-from-inheritance '("crypt" "project")
org-crypt-key "snapp@cs.uvm.edu"
org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)")
(sequence "ERROR(e)" "|" "FIXED(f)") (sequence "|" "CANCELLED(c)"))
org-babel-tangle-lang-exts '(("latex" . "tex") ("D" . "d") ("C++" . "cpp")
("clojure" . "clj") ("emacs-lisp" . "el") ("elisp" . "el"))
org-confirm-elisp-link-function 'yes-or-no-p
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-latex-listings 'minted
org-html-format-headline-function 'org-html-format-headline-default-function
org-structure-template-alist '(("J"
"#+name: ?\n#+begin_src clojure :results silent\n\n#+end_src" "<src id=\"?\" lang=clojure\"\">\n?\n</src>")
("j" "#+begin_src clojure :results silent\n?\n#+end_src"
"<src lang=\"clojure\">\n?\n</src>")
("S" "#+name: ?\n#+begin_src \n\n#+end_src"
"<src id=\"?\" lang=\"\">\n\n</src>")
("s" "#+begin_src ?\n\n#+end_src"
"<src lang=\"?\">\n\n</src>")
("e" "#+begin_example\n?\n#+end_example"
"<example>\n?\n</example>")
("q" "#+begin_quote\n?\n#+end_quote"
"<quote>\n?\n</quote>")
("v" "#+BEGIN_VERSE\n?\n#+END_VERSE"
"<verse>\n?\n</verse>")
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER"
"<center>\n?\n</center>")
("l" "#+BEGIN_LaTeX\n?\n#+END_LaTeX"
"<literal style=\"latex\">\n?\n</literal>")
("L" "#+latex: " "<literal style=\"latex\">?</literal>")
("h" "#+begin_html\n?\n#+end_html"
"<literal style=\"html\">\n?\n</literal>")
("H" "#+html: " "<literal style=\"html\">?</literal>")
("a" "#+begin_ascii\n?\n#+end_ascii") ("A" "#+ascii: ")
("i" "#+index: ?" "#+index: ?")
("I" "#+include %file ?"
"<include file=%file markup=\"?\">")
)
org-mobile-directory "~/Dropbox/MobileOrg"
org-babel-load-languages '((C . t) (clojure . t) (emacs-lisp . t) (latex . t) (org . t))
org-src-preserve-indentation t
org-reveal-start-hook '(org-decrypt-entry)
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
org-agenda-files '("~/org/dates.org" "~/org/todo.org" "~/org/projects/")
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-mobile-inbox-for-pull "~/org//inbox.org"
org-tag-alist '((:startgroup) ("@COMPUTER" . 67) ("@ERRAND" . 69) ("@HOME" . 72)
("@PHONE" . 80) ("@READING" . 82) ("@UVM" . 85) (:endgroup)
("crypt" . 99) ("MEETING" . 109) ("PROGRAMMING" . 112)
("READING" . 114) ("SYS_ADMIN" . 115) ("TEACHING" . 116))
)
==========================================================================
Robert R. Snapp | Office: 802-656-0735
Associate Professor | CS Dept: 802-656-3330
Department of Computer Science | iPhone: 802-598-1274
University of Vermont |
33 Colchester Ave. |
Burlington, VT 05405 USA |
--------------------------------------------------------------------------
Office: 353 Votey Hall; Hours: Mon. 2:00–3:30 pm; Thu. 10:00-11:30 am;
and by appointment. Home Page: http://www.cems.uvm.edu/~rsnapp/
==========================================================================
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-25 2:28 Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)] Robert Snapp
@ 2015-03-29 20:48 ` Thierry Banel
2015-03-30 14:39 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Thierry Banel @ 2015-03-29 20:48 UTC (permalink / raw)
To: emacs-orgmode
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 <string.h> <stdio.h><stdlib.h>
// 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 <string.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> 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
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-29 20:48 ` Thierry Banel
@ 2015-03-30 14:39 ` Nick Dokos
2015-03-30 19:53 ` Thierry Banel
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2015-03-30 14:39 UTC (permalink / raw)
To: emacs-orgmode
Thierry Banel <tbanelwebmin@free.fr> 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 <string.h> <stdio.h><stdlib.h>
> // 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-30 14:39 ` Nick Dokos
@ 2015-03-30 19:53 ` Thierry Banel
2015-03-31 10:07 ` Nicolas Goaziou
0 siblings, 1 reply; 8+ messages in thread
From: Thierry Banel @ 2015-03-30 19:53 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
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
>
>
[-- Attachment #2: 0001-Remove-default-includes-in-Babel-C-C.patch --]
[-- Type: text/x-diff, Size: 1360 bytes --]
From 89eab423a0084a715456db558a987d6d806c49ba Mon Sep 17 00:00:00 2001
From: Thierry Banel <tbanelwebmin@free.fr>
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 <string.h>, <stdio.h>, <stdlib.h>
* 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 '("<string.h>" "<stdio.h>" "<stdlib.h>")))
(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 <string.h> <stdio.h>
int main()
{
int i, j;
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-30 19:53 ` Thierry Banel
@ 2015-03-31 10:07 ` Nicolas Goaziou
2015-03-31 19:52 ` Thierry Banel
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2015-03-31 10:07 UTC (permalink / raw)
To: Thierry Banel; +Cc: emacs-orgmode
Hello,
Thierry Banel <tbanelwebmin@free.fr> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-31 10:07 ` Nicolas Goaziou
@ 2015-03-31 19:52 ` Thierry Banel
2015-03-31 22:14 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Thierry Banel @ 2015-03-31 19:52 UTC (permalink / raw)
To: emacs-orgmode
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: <stdio.h> <myheader.h>
:END:
Any C++ babel block below this tree will inherit the <stdio.h> and
<myheader.h>#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 "<stdio.h>"
"<myheader.h>"))
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-31 19:52 ` Thierry Banel
@ 2015-03-31 22:14 ` Nick Dokos
2015-04-02 21:30 ` Thierry Banel
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2015-03-31 22:14 UTC (permalink / raw)
To: emacs-orgmode
Thierry Banel <tbanelwebmin@free.fr> 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: <stdio.h> <myheader.h>
> :END:
> Any C++ babel block below this tree will inherit the <stdio.h> and
> <myheader.h>#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 "<stdio.h>"
> "<myheader.h>"))
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)]
2015-03-31 22:14 ` Nick Dokos
@ 2015-04-02 21:30 ` Thierry Banel
0 siblings, 0 replies; 8+ messages in thread
From: Thierry Banel @ 2015-04-02 21:30 UTC (permalink / raw)
To: emacs-orgmode
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 <one.h>
2) org-babel-default-header-args:C++ '(:includes "<two.h>")
3) org-babel-default-header-args '(:includes "<three.h>")
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-04-02 21:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-25 2:28 Bug: Proposed new version of ob-C.el [8.3beta (release_8.3beta-944-g830cf3 @ /Users/snapp/.emacs.d/vendor/org/)] Robert Snapp
2015-03-29 20:48 ` Thierry Banel
2015-03-30 14:39 ` Nick Dokos
2015-03-30 19:53 ` Thierry Banel
2015-03-31 10:07 ` Nicolas Goaziou
2015-03-31 19:52 ` Thierry Banel
2015-03-31 22:14 ` Nick Dokos
2015-04-02 21:30 ` Thierry Banel
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).