Re: [O] Mixing Python2 and Python3 blocks in one file
Hi Ken, On Wed, May 18, 2016 at 8:45 AM, Ken Mankoffwrote: On 2016-05-17 at 21:19, William Henney wrote: > > Why is the :python parameter insufficient for your needs? You can also > > use it for different virtual environments > > Can you clarify how to do this? Does it work with conda environments too? > Yes, you just have to specify ~/anaconda/envs/NAME_OF_ENV/bin/python as the name of the interpreter I gave a conda example in my first message to this thread, but here is another one. In the shell, I just made a new environment: $ condo create --name myenv And now, I can test it in an org file: #+BEGIN_SRC python :python ~/anaconda/envs/myenv/bin/python :results verbatim import sys return sys.path #+END_SRC #+RESULTS: : ['', '/Users/will/anaconda/envs/myenv/lib/python35.zip', '/Users/will/anaconda/envs/myenv/lib/python3.5', '/Users/will/anaconda/envs/myenv/lib/python3.5/plat-darwin', '/Users/will/anaconda/envs/myenv/lib/python3.5/lib-dynload', '/Users/will/anaconda/envs/myenv/lib/python3.5/site-packages', '/Users/will/anaconda/envs/myenv/lib/python3.5/site-packages/setuptools-20.7.0-py3.5.egg'] Note that this is not /exactly/ equivalent to doing “source activate myenv” in a terminal shell since it does not run any activation/deactivation scripts that you might have put in the virtual environment. But personally I never use that feature Will -- Dr William Henney, Instituto de Radioastronomía y Astrofísica, Universidad Nacional Autónoma de México, Campus Morelia
Re: [O] speed keys for plain lists?
On Tue, May 17, 2016 at 10:54 AM, Bill Whitewrote: > Could you post an example? Sure. I wanted to refer to my heading by UID rather than name since I wasn't sure of the final format: https://raw.githubusercontent.com/grettke/help/master/help.org Karl provided a format for your example using properties. I would approach it the same way. The folks that use Org-Mode to maintain bibliographies and BBDB databases might have some feedback for you here, too.
Re: [O] template for writing Emacs manuals in Org
I'm coming a little late to this thread so apologies! Most of the previous thread has focused on analysing the various pros and cons of the various documentation methods, INFOText/html/org, to produce the final documentation. I would like to suggest that whatever method is used that it also supports the development workflow cycle of emacs. Core features that are documented should also have corresponding testplans. John Wiegley makes this point in his in his YouTube talk with Sacha Chua https://www.youtube.com/watch?v=nUjgKoOYxos. He concisely summed up the workflow issue as 'bugs/tests/documentation'. It was one of the areas that needed more effort. The challenge is to elegantly manage the documentation process so that it caters for the complete workflow development cycle. I favour the use of org as it has the capability of embedding tests within the documentation, among other things. Ciaran
[O] org-mode html export background/foreground inconsistency
I attempted to follow this blog to enable a background html export on org file save: http://stephanus-volke.de/posts/2015/Dez/22/org-mode-live-preview-en/ I tried adding the following to the top of the org file: # -*- after-save-hook: org-html-export-to-html; org-export-in-background: t; -*- by the way I also tried: -*- after-save-hook: org-html-export-to-html; org-export-in-background: t; -*- I even tried the following which I thought would work since I'm setting the optional ASYNC variable to true: #-*- after-save-hook: (org-html-export-to-html t); org-export-in-background: t; -*- For each test I tried I quit emacs and reopened to org file fresh. I was prompted to accept some security settings and chose "y" so the variable org-export-in-background is set correctly. The funny thing is when I go through (C-c C-e h o) the export goes to the background, otherwise when I save the file it happens in the foreground (which freezes emacs for some time). :( Running: Org-mode version 8.3.4 (8.3.4-50-g83e373-elpa) GNU Emacs 25.1.50.1 I'm not sure if this is correct behavior? Thank you in advance for any insight or suggestions you may have. - lad
Re: [O] [patch] get modification-time from vc
Hi, Thanks for the comments! Nicolas Goaziouwrites: > Why enforcing "vc" and not any non-nil/non-empty second argument instead ? No point, really. >> Is cl-lib OK now?! > > cl-lib is OK in master. Minimal requirement for master is Emacs 24.3. Cool. >> + (when (cl-some 'identity time) >> + (setq date (apply #'encode-time time > > Why #'encode-time and not #'identity ? To test if you review the all the way to the end! Or... > In any case, this looks good. Please push when you're happy with the > result. Pushed. Rasmus -- And when I’m finished thinking, I have to die a lot
Re: [O] Bug: orgtbl-self-insert-command does not overwrite whitespace [8.3.4 (8.3.4-50-g83e373-elpa @ /home/alex/.emacs.d/elpa/org-20160509/)]
The following message is a courtesy copy of an article that has been posted to gmane.emacs.orgmode as well. > Backspace works as expected, however. I'm afraid that as of org-20160516 on ELPA, backspace also does not overwrite whitespace.
Re: [O] template for writing Emacs manuals in Org
Nicolas Goaziouwrites: > Hello, > > Jonathan Leech-Pepin writes: > >> I’m trying to remember why I didn’t implement indexes as properties >> (it may well have been because I simply didn’t consider it). Assuming >> there’s nothing in the exporter to prevent converting properties to >> text after headlines it could work. Treat comma separated values as >> separate entries. > > Index entries are not section wide. It doesn't sound right to attach > them to properties drawers. In many cases an index entry is referring explicitly to a specific heading. Example: ** Installation :PROPERTIES: :DESCRIPTION: How to install a downloaded version of Org-mode :END: #+cindex: installation In such cases I’d prefer to able to attach the index specifically to the heading. Much the same way that I prefer to give a heading a custom_id property rather than putting a <> after a headline. > Besides, the {{{cindex()}}} macro is not used anymore. There is the > CINDEX keyword, which is slightly better. My bad, I must have accidentally looked at the version before your recent changes. The keyword is already better. > I guess we could use #+INDEX instead, but it would require to add an > information specific to Texinfo (index type), which would probably > defeat the simplicity of the solution. Either is fine. Though I don’t think it’s less simple to have a key. #+index: key :type cindex. Rasmus -- This is the kind of tedious nonsense up with which I will not put
Re: [O] "global" variables in a babel document...
Hello, "Allen S. Rout"writes: > #+PROPERTY:header-args:var tsmuser="query" It should be #+PROPERTY: header-args :var tsmuser="query" Regards, -- Nicolas Goaziou
Re: [O] [patch] get modification-time from vc
Hello, Rasmuswrites: > Here’s a new version. Thank you. > New idea, an optional 2nd argument to modification-time. E.g. > > {{{modification-time(%Y, vc)}}} Even better! >> If you think that is useful, then I vote for a different macro. > > I prefer an argument as it gives a clear ranking: get the modified time > from vc, if possible (if the second argument is vc), otherwise get it from > the file system (also default behavior). Why enforcing "vc" and not any non-nil/non-empty second argument instead ? > Is cl-lib OK now?! cl-lib is OK in master. Minimal requirement for master is Emacs 24.3. > +the modification date and time, respectively. @var{FORMAT} should be a > +format string understood by @code{format-time-string}. If the second > +argument to the @code{modification-time} macro is @samp{vc}, Org will try to > +find the modification time via version control (using @code{vc.el}). Suggestion: Org retrieves the information from the version control system (using @file{vc.el}) instead of the file attributes. > + (format "(eval (format-time-string \"$1\" (or (when > (equal (org-trim (downcase \"$2\")) \"vc\") (org-macro--vc-modified-time %s)) > '%s)))" when => and > +(when (cl-some 'identity time) > + (setq date (apply #'encode-time time Why #'encode-time and not #'identity ? In any case, this looks good. Please push when you're happy with the result. Regards, -- Nicolas Goaziou
Re: [O] template for writing Emacs manuals in Org
Hello, Jonathan Leech-Pepinwrites: > I’m trying to remember why I didn’t implement indexes as properties > (it may well have been because I simply didn’t consider it). Assuming > there’s nothing in the exporter to prevent converting properties to > text after headlines it could work. Treat comma separated values as > separate entries. Index entries are not section wide. It doesn't sound right to attach them to properties drawers. Besides, the {{{cindex()}}} macro is not used anymore. There is the CINDEX keyword, which is slightly better. I guess we could use #+INDEX instead, but it would require to add an information specific to Texinfo (index type), which would probably defeat the simplicity of the solution. Regards, -- Nicolas Goaziou
Re: [O] template for writing Emacs manuals in Org
Hi, On May 18, 2016 5:21:06 AM EDT, Rasmuswrote: >Hi, > >Nick Dokos writes: > >> I believe the main obstacle is that the emacs policy requires a >texinfo >> manual for all its component parts. > >What is the "component parts"? I couldn't find the definition. > >> If that can be generated automatically from the org document, then >any >> objections probably disappear. Of course, Bastien might object to the >> extra effort required to do the conversion, but if the conversion is >> indeed completely automatic (or, perhaps more likely, a volunteer can >be >> found to take care of the conversion and any problems that might >arise), >> then he might be amenable to it. But it would be an extra step >required >> at release time and would require some coordination. > >My issue is all the damn macros. While it displays the flexibility of >Org, it also makes Org-for-texinfo-manuals less appealing. I don’t >want >to learn new mini documentation language for each manual I might send >patches to. > >Maybe a "Library-of-Macros" would go some of the way of at least making >it >feel less ad-hoc? > >Another annoyance. When I see something like the an index right after >a >headline, I really would like to put the index into the properties >drawer: > > ** Installation >:PROPERTIES: >:DESCRIPTION: How to install a downloaded version of Org-mode >:END: > > {{{cindex(installation)}}} > I’m trying to remember why I didn’t implement indexes as properties (it may well have been because I simply didn’t consider it). Assuming there’s nothing in the exporter to prevent converting properties to text after headlines it could work. Treat comma separated values as separate entries. Then using the macro would only be needed if indexing at content rather than at a headline (use lower level headlines that do not become nodes and it could still work). >Aside: I’ve been wanting a drawer property for inserting text just >before >headings (and maybe just after headings) for a while, e.g. > > EXPORT_BACKEND_{BEFORE, AFTER}, or > INSERT_{BEFORE, AFTER} > >It would also be useful for latex, e.g. > >* Proofs > :PROPERTIES: > :EXPORT_LATEX_BEFORE: \appendix > :INSERT_BEFORE: @@latex:\appendix@@ > :END: > >Rasmus -- Jon
Re: [O] Mixing Python2 and Python3 blocks in one file
Hi Will, On 2016-05-17 at 21:19, William Henneywrote: > Why is the :python parameter insufficient for your needs? You can also > use it for different virtual environments Can you clarify how to do this? Does it work with conda environments too? Thanks, -k.
Re: [O] Division of Org documentation: Org manual and Worg
On Wed, May 18 2016, Daniele Pizzolli wrote: > On Wed, May 18 2016, Rasmus wrote: > >> Daniele Pizzolli writes: >> >>> It would be nice to add them to the documentation, but I have not yet >>> figured out what is the appropriate way to send the patch! >> >> /That/ information happens to be on Worg :) >> >>http://orgmode.org/worg/org-contribute.html > > Thanks Rasmus, > > So... here is the patch for worg about python and utf-8! I skipped > the part related to the tables, since I do not have a clean > workaround. Oops, I correct a couple of typos with this one. Sorry for the noise. Daniele >From e885c2d7654dcf78cf37e5fd5b1e104545ecbd2f Mon Sep 17 00:00:00 2001 From: Daniele PizzolliDate: Wed, 18 May 2016 11:55:00 +0200 Subject: [PATCH 1/1] Add caveats about uft-8 strings --- org-contrib/babel/languages/ob-doc-python.org | 52 ++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/org-contrib/babel/languages/ob-doc-python.org b/org-contrib/babel/languages/ob-doc-python.org index 968a8bc..8acfbff 100644 --- a/org-contrib/babel/languages/ob-doc-python.org +++ b/org-contrib/babel/languages/ob-doc-python.org @@ -25,7 +25,7 @@ #+end_html -* Template Checklist [10/12] :noexport: +* Template Checklist [11/14] :noexport: - [X] Revise #+TITLE: - [X] Indicate #+AUTHOR: - [X] Add #+EMAIL: @@ -42,6 +42,8 @@ - [ ] Describe [[Result%20Types][Result Types]] - [ ] Describe [[Other]] differences from supported languages - [X] Provide brief [[Examples%20of%20Use][Examples of Use]] + - [X] Add caveats about utf-8 in strings + - [ ] Add caveats about utf-8 in tables * Introduction Python is a high-level, readable, interpreted language which can be used for many common computing tasks. It runs on most modern @@ -242,3 +244,51 @@ return 'images/python-matplot-fig.png' # return filename to org-mode #+end_example [[file:images/python-matplot-fig.png]] + +* Caveats + +You need some care in order to pass utf-8 strings to python. + +** passing utf-8 strings to python + +#+begin_example +#+NAME: unicode_str +,#+BEGIN_EXAMPLE +“this string is not ascii!” +,#+END_EXAMPLE +#+end_example + +#+begin_example +#+NAME: error-in-passing-var +#+BEGIN_SRC python :var data=unicode_str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: error-in-passing-var +#+end_example + +Will produce no output and prints the following message in the buffer +=*Org-Babel Error Output*=: + +#+BEGIN_EXAMPLE + File "", line 3 +SyntaxError: Non-ASCII character '\xe2' in file on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details +#+END_EXAMPLE + +** passing utf-8 strings to python with workaround + +A workaround is to use =:preamble= with the value =# -*- coding:utf-8 -*-= + +#+begin_example +#+NAME: ok-in-passing-var +#+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: ok-in-passing-var +: “this string is not ascii!” +#+end_example -- 2.1.4
Re: [O] Division of Org documentation: Org manual and Worg
Hi Daniele, > So... here is the patch for worg about python and utf-8! I skipped > the part related to the tables, since I do not have a clean > workaround. Thanks for contributing to Worg! For Worg you just need to have your ssh key added. Then you can push changes yourself. http://orgmode.org/worg/worg-about.html You can email your public ssh key to e.g. Bastien (bzg at gnu dot org). Rasmus -- You people at the NSA are becoming my new best friends!
Re: [O] [patch] get modification-time from vc
Hi, An overdue "Thanks" for the feedback. Here’s a new version. Nicolas Goaziouwrites: > Well, if you ask, I do not like much when some software tries to > outsmart me (note that I like it even less when it actually succeeds). > So, I think {{{modification-time}}} should expand to modification time. New idea, an optional 2nd argument to modification-time. E.g. {{{modification-time(%Y, vc)}}} > If you think that is useful, then I vote for a different macro. I prefer an argument as it gives a clear ranking: get the modified time from vc, if possible (if the second argument is vc), otherwise get it from the file system (also default behavior). >> + (when (org-some 'identity >> time) > > (cl-some #'identity time) Is cl-lib OK now?! Thanks, Rasmus -- ... The proofs are technical in nature and provide no real understanding >From 20f2268c7555c08e26654c77c0191012e176e059 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 18 May 2016 11:23:46 +0200 Subject: [PATCH 1/3] org-macro.el: Allow modification-time from vc.el * org-macro.el (org-macro--vc-modified-time): New function. * org-macro.el (org-macro-initialize-templates): Add support for new function. * doc/org.texi (Macro replacement): Document new behavior. * etc/ORG-NEWS: Mention new behavior. --- doc/org.texi | 9 + etc/ORG-NEWS | 3 +++ lisp/org-macro.el | 32 +++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 0bfee39..f0fd8bb 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10247,13 +10247,14 @@ argument to the @code{@{@{@{date@}@}@}} macro that will be used only if understood by @code{format-time-string}. @item @{@{@{time(@var{FORMAT})@}@}@} -@itemx @{@{@{modification-time(@var{FORMAT})@}@}@} +@itemx @{@{@{modification-time(@var{FORMAT}, @var{VC})@}@}@} @cindex time, macro @cindex modification time, macro These macros refer to the date and time when the document is exported and to -the modification date and time of the file being exported, respectively. -@var{FORMAT} should be a format string understood by -@code{format-time-string}. +the modification date and time, respectively. @var{FORMAT} should be a +format string understood by @code{format-time-string}. If the second +argument to the @code{modification-time} macro is @samp{vc}, Org will try to +find the modification time via version control (using @code{vc.el}). @item @{@{@{input-file@}@}@} @cindex input file, macro diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 7a0a890..370963e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -105,6 +105,9 @@ becomes : ("pdf" . (lambda (file link) (foo))) +*** The ~{{{modification-time}}}~ macro can obtain time via =vc= +The modification time will be determined via =vc.el= if the second +argument is =vc=. See the manual for details. ** New features *** New org-protocol key=value syntax diff --git a/lisp/org-macro.el b/lisp/org-macro.el index e135374..d86aaee 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -58,6 +58,10 @@ (declare-function org-file-contents "org" (file noerror)) (declare-function org-mode "org" ()) (declare-function org-remove-double-quotes "org" (s)) +(declare-function org-with-wide-buffer "org-macs" ( body)) +(declare-function vc-backend "vc-hooks" (f)) +(declare-function vc-call "vc-hooks" ( args)) +(declare-function vc-exec-after "vc-dispatcher" (code)) ;;; Variables @@ -145,11 +149,13 @@ function installs the following ones: \"property\", (mapc update-templates (list (cons "input-file" (file-name-nondirectory visited-file)) (cons "modification-time" - (format "(eval (format-time-string \"$1\" '%s))" + (format "(eval (format-time-string \"$1\" (or (when (equal (org-trim (downcase \"$2\")) \"vc\") (org-macro--vc-modified-time %s)) '%s)))" + (prin1-to-string visited-file) (prin1-to-string (nth 5 (file-attributes visited-file) (setq org-macro-templates templates))) + (defun org-macro-expand (macro templates) "Return expanded MACRO, as a string. MACRO is an object, obtained, for example, with @@ -276,6 +282,30 @@ Return a list of arguments, as strings. This is the opposite of s nil t) "\000")) +(defun org-macro--vc-modified-time (file) + (save-window-excursion +(when (vc-backend file) + (let ((buf (get-buffer-create " *org-vc*")) + (case-fold-search t) + date) + (unwind-protect + (progn + (vc-call print-log file buf nil nil 1) + (with-current-buffer buf + (vc-exec-after + (lambda () + (goto-char (point-min)) + (when (re-search-forward "Date:?[ \t]*" nil t) + (let ((time (parse-time-string + (buffer-substring + (point) (line-end-position) + (when (cl-some 'identity time) + (setq date (apply #'encode-time time + (let ((proc
Re: [O] Division of Org documentation: Org manual and Worg
On Wed, May 18 2016, Rasmus wrote: > Daniele Pizzolli writes: > >> It would be nice to add them to the documentation, but I have not yet >> figured out what is the appropriate way to send the patch! > > /That/ information happens to be on Worg :) > >http://orgmode.org/worg/org-contribute.html Thanks Rasmus, So... here is the patch for worg about python and utf-8! I skipped the part related to the tables, since I do not have a clean workaround. Best, Daniele >From 91941d90d26e1715447fecc255d7976c0895e75d Mon Sep 17 00:00:00 2001 From: Daniele PizzolliDate: Wed, 18 May 2016 11:55:00 +0200 Subject: [PATCH 1/1] Add caveats about uft-8 strings --- org-contrib/babel/languages/ob-doc-python.org | 52 ++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/org-contrib/babel/languages/ob-doc-python.org b/org-contrib/babel/languages/ob-doc-python.org index 968a8bc..e4619ed 100644 --- a/org-contrib/babel/languages/ob-doc-python.org +++ b/org-contrib/babel/languages/ob-doc-python.org @@ -25,7 +25,7 @@ #+end_html -* Template Checklist [10/12] :noexport: +* Template Checklist [11/14] :noexport: - [X] Revise #+TITLE: - [X] Indicate #+AUTHOR: - [X] Add #+EMAIL: @@ -42,6 +42,8 @@ - [ ] Describe [[Result%20Types][Result Types]] - [ ] Describe [[Other]] differences from supported languages - [X] Provide brief [[Examples%20of%20Use][Examples of Use]] + - [X] Add caveats about utf-8 in strings + - [ ] Add caveats about utf-8 in tables * Introduction Python is a high-level, readable, interpreted language which can be used for many common computing tasks. It runs on most modern @@ -242,3 +244,51 @@ return 'images/python-matplot-fig.png' # return filename to org-mode #+end_example [[file:images/python-matplot-fig.png]] + +* Caveats + +** passing utf-8 strings to python + +You need some care in order to pass utf-8 strings to python. + +#+begin_example +#+NAME: unicode_str +,#+BEGIN_EXAMPLE +“this string is not ascii!” +,#+END_EXAMPLE +#+end_example + +#+begin_example +#+NAME: error-in-passing-var +#+BEGIN_SRC python :var data=unicode_str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: error-in-passing-var +#+end_example + +Will produce no output and prints the following message in the buffer +=*Org-Babel Error Output*=: + +#+BEGIN_EXAMPLE + File "", line 3 +SyntaxError: Non-ASCII character '\xe2' in file on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details +#+END_EXAMPLE + +** passing utf-8 strings to python with workaround + +A workaround is to use =:preamble= with wthe value =# -*- coding:utf-8 -*-= + +#+begin_example +#+NAME: ok-in-passing-var +#+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: ok-in-passing-var +: “this string is not ascii!” +#+end_example -- 2.1.4
Re: [O] template for writing Emacs manuals in Org
Hi, Nick Dokoswrites: > I believe the main obstacle is that the emacs policy requires a texinfo > manual for all its component parts. What is the "component parts"? I couldn't find the definition. > If that can be generated automatically from the org document, then any > objections probably disappear. Of course, Bastien might object to the > extra effort required to do the conversion, but if the conversion is > indeed completely automatic (or, perhaps more likely, a volunteer can be > found to take care of the conversion and any problems that might arise), > then he might be amenable to it. But it would be an extra step required > at release time and would require some coordination. My issue is all the damn macros. While it displays the flexibility of Org, it also makes Org-for-texinfo-manuals less appealing. I don’t want to learn new mini documentation language for each manual I might send patches to. Maybe a "Library-of-Macros" would go some of the way of at least making it feel less ad-hoc? Another annoyance. When I see something like the an index right after a headline, I really would like to put the index into the properties drawer: ** Installation :PROPERTIES: :DESCRIPTION: How to install a downloaded version of Org-mode :END: {{{cindex(installation)}}} Aside: I’ve been wanting a drawer property for inserting text just before headings (and maybe just after headings) for a while, e.g. EXPORT_BACKEND_{BEFORE, AFTER}, or INSERT_{BEFORE, AFTER} It would also be useful for latex, e.g. * Proofs :PROPERTIES: :EXPORT_LATEX_BEFORE: \appendix :INSERT_BEFORE: @@latex:\appendix@@ :END: Rasmus -- ツ
Re: [O] Division of Org documentation: Org manual and Worg
Daniele Pizzolliwrites: > It would be nice to add them to the documentation, but I have not yet > figured out what is the appropriate way to send the patch! /That/ information happens to be on Worg :) http://orgmode.org/worg/org-contribute.html -- It was you, Jezebel, it was you
[O] org-mode, python and unicode
Hello, I found some problems and workarounds in the use of python (version 2) and org-mode. This applies to: #+BEGIN_EXAMPLE Org-mode version 8.3.4 (8.3.4-60-g19cf68-elpa @ /home/vagrant/.emacs.d/elpa/org-20160516/) #+END_EXAMPLE Some workaround are not complete, and suggestions are welcome! Best, Daniele * python ** load python support for babel #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) #+END_SRC #+RESULTS: : ((python . t)) ** passing utf-8 strings to python #+NAME: unicode_str #+BEGIN_EXAMPLE “this string is not ascii!” #+END_EXAMPLE #+NAME: error-in-passing-var #+BEGIN_SRC python :var data=unicode_str return data #+END_SRC #+RESULTS: error-in-passing-var Will result in the following message in the buffer =*Org-Babel Error Output*=: #+BEGIN_EXAMPLE File "", line 3 SyntaxError: Non-ASCII character '\xe2' in file on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details #+END_EXAMPLE ** passing utf-8 strings to python with workaround A workaround is to use =:preamble= with wthe value =# -*- coding:utf-8 -*-= #+NAME: ok-in-passing-var #+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_str return data #+END_SRC #+RESULTS: ok-in-passing-var : “this string is not ascii!” ** passing utf-8 tables to python #+NAME: unicode_table | key | value | |-+-| | 1 | “this string is not ascii!” | #+NAME: error-in-passing-table #+BEGIN_SRC python :var data=unicode_table return data #+END_SRC Will result in the following message in the buffer =*Org-Babel Error Output*=: #+BEGIN_EXAMPLE File "", line 3 SyntaxError: Non-ASCII character '\xe2' in file on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details #+END_EXAMPLE ** returning utf-8 tables from python #+NAME: error-in-returnig-table #+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_table :colnames yes return data #+END_SRC Will output the ascii text with escape sequence for unicode characters. I still do not know the best workaround #+RESULTS: error-in-returnig-table | key | value | |-+---| | 1 | \xe2\x80\x9cthis string is not ascii!\xe2\x80\x9d | Please note that the single cell is correctly returned: #+NAME: returnig-table-cell #+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_table return data[0][1] #+END_SRC #+RESULTS: returnig-table-cell : “this string is not ascii!” ** Undocumented parts I did not found out: - how to get the table headers in python - in general, the magic that org-mode does to pass and retrieve data structures to various languages is lacking documentation
Re: [O] Division of Org documentation: Org manual and Worg
On Wed, May 18 2016, Karl Voit wrote: > Good morning William, > > * William Henneywrote: >> >> On Tue, May 17, 2016 at 9:54 AM, Karl Voit wrote: >> >>> * William Henney wrote: >>> > >>> > #+BEGIN_SRC python :python /Users/will/anaconda/envs/py27/bin/python >>> >>> Is this undocumented? http://orgmode.org/org.html does not contain >>> the string ":python:" and >>> http://orgmode.org/org.html#Language_002dspecific-header-arguments >>> also does not mention this parameter. >>> >> It is documented at >> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html >> >> You are right that it would be better if the language-specific babel >> documentation were better integrated in the general org info file. But I >> suppose nobody has been sufficiently motivated to do it yet > > That brings me to an additional question I was asking myself a > couple of times: things like this, IMHO basic features, are > sometimes mentioned in Worg but not in the Org manual. Is there a > «rule» that I can follow so that I know where to look? > > So far, I had to do full text search on both domains to find certain > keywords... Hello, Me too, and this is really a problem when you try do unusual stuff. I will share some problems and workaround for python in a new thread. It would be nice to add them to the documentation, but I have not yet figured out what is the appropriate way to send the patch! Best, Daniele
Re: [O] speed keys for plain lists?
* Bill Whitewrote: > > Here's a sample of my second iteration. A poor man's database - still > pure orgmode and still plain text, but easily parsable: > > - main word|subordinate word, subdivided into grammatical relations A, B, C, > >- identification > - main form :: Abbacy > - obsolete † :: no > - non-naturalized ‖ :: no > - pronunciation :: æ•băsi > - part of speech :: substantive > - specification :: none > - status :: default > - spellings :: 5-6 abbasy, 6-7 abbacie > - inflections :: none >- [morphology] > - derivation (etymology) :: A modification of the earlier > ABBATIE, assimilated to forms like prelacy, mediaeval Latin > -acia, -atia. > - subsequent form-history :: > - miscellaneous facts :: >- TODO: significations & illustrative quotations I am certainly not thinking of all of your use-cases. However, here is a possible alternative «solution» with headings. Just being curious: What disadvantages do you see here compared to lists? *** main word|subordinate word, subdivided into grammatical relations A, B, C, :PROPERTIES: ## or: :identification:-drawer :mainform: Abbacy :obsolete: no :nonnaturalized: no :pronunciation: æ•basi :partofspeech: substantive :specification: none :status: default :spellings: 5-6 abbasy, 6-7 abbacie :...OR...: :spelling: 5-6 abbasy :spelling: 6-7 abbacie :inflections: none :END: #+COMMENT: Previous list as properties does have multiple advantages #+COMMENT: such as column view (+ corresponding edit functionality) #+COMMENT: Following lines seem to contain potential multi-line #+COMMENT: text which does not qualify to be handled well in properties: - [morphology] - derivation (etymology) :: A modification of the earlier ABBATIE, assimilated to forms like prelacy, mediaeval Latin -acia, -atia. - subsequent form-history :: - miscellaneous facts :: TODO: significations & illustrative quotations #+COMMENT: I personally prefer todos that can possible get SCHEDULED #+COMMENT: and/or DEADLINE dates to be headings. -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github
Re: [O] Mixing Python2 and Python3 blocks in one file
* Thomas S. Dyewrote: > > William Henney writes: >> >> It is documented at >> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html > > As of a few hours ago, when I added it. It probably wasn't there when > Karl looked. Thank you very much Thomas! I can not appreciate documentation improvements too much ;-) -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github
[O] Division of Org documentation: Org manual and Worg (was: Mixing Python2 and Python3 blocks in one file)
Good morning William, * William Henneywrote: > > On Tue, May 17, 2016 at 9:54 AM, Karl Voit wrote: > >> * William Henney wrote: >> > >> > #+BEGIN_SRC python :python /Users/will/anaconda/envs/py27/bin/python >> >> Is this undocumented? http://orgmode.org/org.html does not contain >> the string ":python:" and >> http://orgmode.org/org.html#Language_002dspecific-header-arguments >> also does not mention this parameter. >> > It is documented at > http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html > > You are right that it would be better if the language-specific babel > documentation were better integrated in the general org info file. But I > suppose nobody has been sufficiently motivated to do it yet That brings me to an additional question I was asking myself a couple of times: things like this, IMHO basic features, are sometimes mentioned in Worg but not in the Org manual. Is there a «rule» that I can follow so that I know where to look? So far, I had to do full text search on both domains to find certain keywords... Thanks -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github
Re: [O] (V8) [PATCH] New feature: Use dvisvgm to preview latex formular
> As discussed in another message, I don't think we should mess with > `org-latex-compile'. Instead, we could factor out the needed part in > `org-latex-compile' and make it a generic function. Then we can > introduce a new function to specifically handle previewing related > compilation. > > Note that I'm not asking you to implement the factoring out part in your > patch, but to tell me if the following would fulfill your needs for > `org-create-formula-image'. I'm sending its docstring again. > I have rebase my patch to new function org-compile-file, the v8 patch is very different with the earlier version, it is more simpler i think, please comment again, thanks for your help! >From 61885684f4826b06de4bb72b6ef1f369960f268a Mon Sep 17 00:00:00 2001 From: Feng ShuDate: Tue, 17 May 2016 21:24:35 +0800 Subject: [PATCH] New feature: Use dvisvgm to preview latex formular * ox-html.el (org-html-with-latex): Add dvisvgm support. (org-html-with-latex): Add dvisvgm support. (org-html-format-latex): "ltxpng" -> "ltximg". (org-html-latex-environment): Add dvisvgm support. (org-html-latex-fragment): Add dvisvgm support. * org.el (org-latex-create-formula-image-program): Add dvisvgm. (org-latex-preview-ltximg-directory): Rename from `org-preview-latex-image-directory'. (org--format-latex-make-overlay): Add optional image-type, which used to deal with svg. (org-toggle-latex-fragment): "org-ltxpng" -> "org-ltximg". (org-format-latex): Add dvisvgm support. (org-create-formula-image): Big refactor, merge dvipng and imagemagick backend's feature. Add dvisvgm feature. (org-preview-latex-process-alist): Add new variable, which used to set latex preview processes. (org-create-formula-image-with-dvipng): Useless, removed. (org-create-formula-image-with-imagemagick): Useless, removed. * org.texi (@LaTeX{} fragments): Add dvisvgm information. (Previewing @LaTeX{} fragments): Add dvisvgm information. (Math formatting in HTML export): Add dvisvgm information. (Working with @LaTeX{} math snippets): Add dvisvgm information. --- doc/org.texi| 41 +++-- lisp/org.el | 462 +--- lisp/ox-html.el | 27 ++-- 3 files changed, 346 insertions(+), 184 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 17b01c2..ad75b5d 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10393,10 +10393,10 @@ snippets will be identified as @LaTeX{} source code: @item Environments of any kind@footnote{When MathJax is used, only the environments recognized by MathJax will be processed. When -@file{dvipng} program or @file{imagemagick} suite is used to create images, -any @LaTeX{} environment will be handled.}. The only requirement is that the -@code{\begin} statement appears on a new line, at the beginning of the line -or after whitespaces only. +@file{dvipng} program, @file{dvisvgm} program or @file{imagemagick} suite is +used to create images, any @LaTeX{} environment will be handled.}. The only +requirement is that the @code{\begin} statement appears on a new line, at the +beginning of the line or after whitespaces only. @item Text within the usual @LaTeX{} math delimiters. To avoid conflicts with currency specifications, single @samp{$} characters are only recognized as @@ -10444,11 +10444,11 @@ lines: @cindex @LaTeX{} fragments, preview @vindex org-latex-create-formula-image-program -If you have a working @LaTeX{} installation and either @file{dvipng} or -@file{convert} installed@footnote{These are respectively available at -@url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick} -suite. Choose the converter by setting the variable -@code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{} +If you have a working @LaTeX{} installation and @file{dvipng}, @file{dvisvgm} +or @file{convert} installed@footnote{These are respectively available at +@url{http://sourceforge.net/projects/dvipng/}, @url{http://dvisvgm.bplaced.net/} +and from the @file{imagemagick} suite. Choose the converter by setting the +variable @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{} fragments can be processed to produce images of the typeset expressions to be used for inclusion while exporting to HTML (see @pxref{@LaTeX{} fragments}), or for inline previewing within Org mode. @@ -11713,6 +11713,7 @@ You could use @code{http} addresses just as well. @subsection Math formatting in HTML export @cindex MathJax @cindex dvipng +@cindex dvisvgm @cindex imagemagick @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two @@ -11737,13 +11738,18 @@ template can be configure via @code{org-html-mathjax-template}. If you prefer, you can also request that @LaTeX{} fragments are processed into small images that will be inserted into the browser page. Before the availability of MathJax, this was the default method for Org files. This -method