[Orgmode] org-babel: [PATCH] allow emacs-lisp results to be pretty-printed
Hey there, on irc (#org-mode) someone asked how one would go about to insert the result of a emacs-lisp function without it being transformed into a org-mode table. I didn't see any other way, so I wrote a small patch that allows the parameter :results to accept 'pp'. Is this the right way? And where should this special parameter be documented? diff --git a/contrib/babel/lisp/langs/org-babel-emacs-lisp.el b/contrib/babel/lisp/langs/org-babel-emacs-lisp.el index 39f5cc7..60671ac 100644 --- a/contrib/babel/lisp/langs/org-babel-emacs-lisp.el +++ b/contrib/babel/lisp/langs/org-babel-emacs-lisp.el @@ -39,10 +39,14 @@ "Execute a block of emacs-lisp code with org-babel. This function is called by `org-babel-execute-src-block' via multiple-value-bind." (message "executing emacs-lisp code block...") - (save-window-excursion -(let ((print-level nil) (print-length nil)) - (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars) - ,(read (concat "(progn " body ")"))) + (let ((results (cdr (assoc :results params +(save-window-excursion + (let ((print-level nil) (print-length nil)) +(eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars) + ,(read (concat "(progn " (if (string-match "pp$" results) + (concat "(pp " body ")") + body) +")" (provide 'org-babel-emacs-lisp) ;;; org-babel-emacs-lisp.el ends here br, benny ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: allow emacs-lisp results to be pretty-printed
Benjamin Andresen writes: > where should this special parameter be documented? I would add a page on Worg that is linked from org-babel.org that contains the following. I have done this for org-babel-screen.org here: http://orgmode.org/worg/org-contrib/babel/org-babel-screen.php (might not be visible yet, because Worg is only exported from git every hour or so) Is that a good way to do this? * Header Arguments :PROPERTIES: :CUSTOM_ID: header-arguments :END: - results :: supports everything documented [[file:org-babel.org::results%20arguments%20specify%20what%20should%20be%20done][here]] as well as - pp :: pretty prints results and replaces any previously inserted results from code block br, benny ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Re: LaTeX export of images
On Oct 2, 2009, at 5:23 PM, Nick Dokos wrote: Darlan Cavalcante Moreira wrote: At Fri, 2 Oct 2009 08:55:22 +0200, Carsten Dominik wrote: Do we need to implement a way so that text can be made to flow around a figure, just as it is possible in HTML export? What would be the right LaTeX package to use for this purpose? The Latex wikibook http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Wrapping_text_around_figures suggests the wrapfigure package, but it also warns that some manual adjustments is often required. Therefore, if this is implemented in the latex exporter it is probably a good idea to provide options to include latex commands that will be put before and after the \includegraphics command. See the example in the section "Tip for figures with too much white space" of the wikibook where some \vspace were used to adjust white space around the figure. ... and the TeX FAQ seems to agree that wrapfig is probably the best option: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=textflow It also mentions some additional limitations. Nick OK, I have now modified image placement in LaTeX. 1. Image in text [[./img/x.png]] 2. Floating image with caption and modified size and placement #+CAPTION: My caption #+ATTR_LATEX: placement=[H] width=0.6\textwidth [[./img/x.png]] 3. Wrapping text around the image #+ATTR_LaTeX: wrap #+ATTR_HTML: align="left" [[./img/x.png]] 4. Wrapping text around the image with modified size and wrapfigure placement #+ATTR_LaTeX: wrap width=0.38\textwidth placement={r}{0.4\textwidth #+ATTR_HTML: align="right" width="250" [[./img/x.png]] Even if there is a caption, wrap will work and force the image to be non-floating with text wrapped around. Comments? - Carsten P.S. if you have customized org-export-latex-classes, you might have to undo, then redo this customization, or add the float and wrapfigure environments by hand to all classes you want to use. ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Unrelated time of day shown in agenda for scheduled event
Hi Antti, On Sep 30, 2009, at 10:15 AM, Antti Kaihola wrote: I have the following TODO item: * TODO Confirm meeting with Alice on <2009-10-01 Thu 09:00-10:00>. SCHEDULED: <2009-09-30 Wed> It appears in the agenda view time grid for *both* 2009-09-30 and 2009-10-01 as: 9:00-10:00 Scheduled: TODO Confirm meeting with Alice on . I assumed it would appear untimed in the 2009-09-30 agenda and possibly 9:00-10:00 in the 2009-10-01 agenda. Reading the documentation I kind of guess why this happens: In the headline of the entry itself, a time(range) may also appear as plain text (like ‘12:45’ or a ‘8:30-1pm’). But it's surprising that the time of day of the timestamp in the headline is connected to the scheduled date. I also tried this: * TODO Confirm meeting with Alice tomorrow at 09:00-10:00 SCHEDULED: <2009-09-30 Wed> In this case I still get the entry in the time grid for 2009-09-30 but nothing on 2009-10-01. Please take a look at the variable `org-agenda-search-headline-for-time' - Carsten ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] newline at start of buffer
Hi Dan, this was a stupid hack to get the headline away from the first buffer line which can cause problems in Org under some circumstances which are hard to consistently remove. It looks a the empty buffer case because this is what will happen when people open a new buffer and immediately create a headline in this way. When there is already something in the buffer, even a space, I am assuming the user wants to be in control. If it is not bothering you a lot, I'd like to keep it this way. - Carsten On Oct 3, 2009, at 5:33 AM, Dan Davison wrote: In a completely empty buffer, org-insert-heading inserts a newline before the first heading. However, if there is (e.g.) a single space character in the buffer (after point), the heading goes on the first line. I admit it's trivial, but that doesn't seem right -- there presumably isn't a reason for the newline in the first case and not in the second, right? (My preference would be no automatic blank line.) Dan diff --git a/lisp/org.el b/lisp/org.el index 73ef6c5..4883a2f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5754,7 +5754,7 @@ current headline. If point is not at the beginning, do not split the line, but create the new headline after the current line." (interactive "P") (if (= (buffer-size) 0) - (insert "\n* ") + (insert "* ") (when (or force-heading (not (org-insert-item))) (let* ((empty-line-p nil) (head (save-excursion ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Problems using org-babel
I enabled org-babel according to the instructions on worg, but am running into a number of issues which I am guessing are a function of my configuration. For example, enabling org-babel completely breaks remember mode, giving me a "wrong ..." argument (sorry - don't have it in front of me) error. Adding a python source block still allows exporting, but adding a ruby block causes a "wrong..." error as well when I try to export. I guess the real question is how do I debug this? I am relatively new to emacs, and not familiar really with how to track some of these issues down. Keith Lancaster klancaster1...@mac.com ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: Problems using org-babel
Hey Keith, Keith Lancaster writes: > I enabled org-babel according to the instructions on worg, but am > running into a number of issues which I am guessing are a function of > my configuration. For example, enabling org-babel completely breaks > remember mode, giving me a "wrong ..." argument (sorry - don't have it > in front of me) error. Adding a python source block still allows > exporting, but adding a ruby block causes a "wrong..." error as well > when I try to export. I guess the real question is how do I debug > this? I am relatively new to emacs, and not familiar really with how > to track some of these issues down. Create a new file with nothing in it, then start adding org-mode parts. (The load path, require the org and org-babel). That way you can guarantee the problem is with org-mode/org-babel and not with some other part of your setup. emacs -Q -l newfile.el If you've done so, incrementally add parts of your old init.el to the new file and see if something breaks. That way you find the step that doesn't work. If you experience problems with the initial step of getting org-mode to run with an empty init.el file, tell us what versions you're using (M-x org-version RET) and what exactly you did to cause the error message. (Alternatively you could also do M-x toggle-debug-on-error RET and post that.) br, benny ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Problems using org-babel
Keith Lancaster writes: > I enabled org-babel according to the instructions on worg, but am > running into a number of issues which I am guessing are a function of > my configuration. For example, enabling org-babel completely breaks > remember mode, giving me a "wrong ..." argument (sorry - don't have it > in front of me) error. Adding a python source block still allows > exporting, but adding a ruby block causes a "wrong..." error as well > when I try to export. I guess the real question is how do I debug > this? I am relatively new to emacs, and not familiar really with how > to track some of these issues down. Hi Keith, In general, a good approach is to replace your personal configuration file with an absolutely bare-bones file -- which only contains the "official" recommended configuration for org-mode and org-babel: http://orgmode.org/manual/Installation.html#Installation http://orgmode.org/manual/Activation.html#Activation http://orgmode.org/worg/org-contrib/babel/org-babel.php#getting-started Presumably you have installed org-mode yourself, rather than using the version that comes with emacs (otherwise you would not have org-babel), so minimally that would be something like this: --8<---cut here---start->8--- (add-to-list 'load-path "/your/location/of/org-mode/lisp") (require 'org-install) (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cb" 'org-iswitchb) (add-to-list 'load-path "/your/location/of/org-mode/contrib/lisp") (require 'org-babel-init) (require 'org-babel-ruby) ;; requires ruby, irb, ruby-mode, and inf-ruby (require 'org-babel-python);; requires python, and python-mode --8<---cut here---end--->8--- With a configuration like this, org-babel should not interact badly with remember mode. So if you're still seeing this problem, please report back, telling us *exactly* what steps you did, in addition to operating system, org-mode version, emacs version. Error messages in emacs tend to get copied to a buffer called *Messages*, so that's a convenient place to retrieve the exact error message from -- perhaps you could send the last few lines from there. If you don't see the problem then you can add your personal config back in incrementally until something breaks. For the problem with ruby, could you send a minimal file containing a ruby block with which you have a problem? Have you definitely got the various ruby dependencies installed (ruby, irb, inf-ruby.el, ruby-mode.el). What operating system and version of org? Dan > > Keith Lancaster > klancaster1...@mac.com > > > > > > ___ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode