Re: [O] Proposal and RFC for improving ob-python
Thank you for the feedback Kyle. > As I understand it (and if I'm remembering correctly), there are at > least three issues with ob-python sessions: 4. session and non-session code differs significantly as you have already mentioned > So for non-session code and value results, the main idea is to get rid > of the need for "return" at the end? > Yes, that's the greatest offense to the Python code. > > This seems useful to me. Requiring a trailing "return", which is a > syntax error when the code is taken by itself, is a quirk of the > implementation (the code ends up being wrapped in a function to get the > return value). Also, it would allow switching from ":results value" to > ":results output" without needing to remove "return" in order to avoid a > syntax error. > Yes, these would be the obvious benefits. > But what about when :results != value? Doesn't your proposal only > handle returning the last value? > You mean :results output ? In that case it could just omit the "open(...).write(...) " part and capture anything the console prints before the primary prompt appears again. Or it could capture stdout into a file, but I think that's needlessly complicated: python -i << HEREDOC_END import sys sys.stdout = open() # replace stdout with some file _ = block_eval(""" """) sys.stdout.close() sys.stdout = sys.__stdout__ # restore stdout HEREDOC_END After thinking about this, perhaps it is better to capture the block result into "_" instead of "ret", because a) it prevents name clashes b) it is more in line with what "_" is used for Kind regards, Ondřej Grover
Re: [O] Proposal and RFC for improving ob-python
Ondřej Grover writes: [...] > The ob-ipython project tries to solve this hackiness in a different way by > using the client-server infrastructure of IPython/Jupyter. That works quite > well too, but my hope is that improving ob-python.el would also make it > simpler to use IPython as the python REPL, relying only on the core of the > Python language. As I understand it (and if I'm remembering correctly), there are at least three issues with ob-python sessions: 1. Shell prompt markers leak into the output. 2. Whitespace at the beginning of the output is swallowed. 3. Valid code that has indentation and spaces cannot be sent. I think the first one is the race conditions that ob-ipython.el's README refers to. > It essentially boils down to implementing progn-like eval() function in > Python which would return the result of the last statement if it is an > expression. [...] > My proposal is to implement an equivalent of the following bash pseudo code > for non session mode > > python -i << HEREDOC_END > ret = block_eval(""" > > """) > open().write(str(ret)) > HEREDOC_END So for non-session code and value results, the main idea is to get rid of the need for "return" at the end? This seems useful to me. Requiring a trailing "return", which is a syntax error when the code is taken by itself, is a quirk of the implementation (the code ends up being wrapped in a function to get the return value). Also, it would allow switching from ":results value" to ":results output" without needing to remove "return" in order to avoid a syntax error. > For session mode it would be even simpler, lines containing HEREDOC above > would be dropped and the rest piped directly into the Python REPL. > > This also means that the 'org_babel_python_eoe' string indicator may not be > necessary anymore because end of evaluation would be simply shown by a new > line with the primary prompt appearing. But what about when :results != value? Doesn't your proposal only handle returning the last value? -- Kyle
Re: [O] org-element-at-point and special blocks
Hello, Rasmus writes: > Is there a reason why org-element-at-point reports the type to be a > paragraph for special blocks? E.g. in the examples at the bottom of this > mail, where | is the cursor, the types are: export-block, src-block and > paragraph with a nested special block. This is a corner-case. `org-element-at-point' returns the closest element at point, but prefers to see an empty paragraph than a special block, for consistency. I.e., when point is within block boundaries, you never return `special-block'. > Is there a neat way to detect if point is inside a block? I’m trying to > write a function for structures (e.g. #+begin_latex) that works like > org-babel-demarcate-block. (org-element-lineage (org-element-at-point) '(special-block) t) Regards, -- Nicolas Goaziou
Re: [O] Intermixed date in koma-letter export
Hi Rasmus, Thanks for your help. However, adding the :EXPORT_DATE: property doesn't work. Firstly, there's an error: "PDF file produced with errors.". Secondly, even though it still produced a PDF output, the date is always today's date which is wrong. Thanks. On Mon, Dec 7, 2015 at 4:21 AM, Rasmus wrote: > York Zhao writes: > > > Let's say I have two letters: > > > > * Letter1 > > ** Preamble :noexport: > > > > #+DATE: 2015-10-26 Monday > > ** To whom it may concern, > > > > > > * Letter2 > > ** Preamble :noexport: > > > > #+DATE: 2015-12-03 Thursday > > ** Hi, > > This should work: > > * letter 1 > :PROPERTIES: > :EXPORT_DATE: 2015-10-26 Monday > :END: > ** To whom it may concern, > > * letter 2 > :PROPERTIES: > :EXPORT_DATE: 2015-12-03 Thursday > :END: > ** hi, > > > -- > Dobbelt-A > > >
Re: [O] LaTeX-close-environment: org-close-template
On 9 Dec 2015 08:10, "Eric S Fraga" wrote: > > On Tuesday, 8 Dec 2015 at 17:04, Uwe Brauer wrote: > > I think the opposite, for example, another missing feature: if you mark > > a text and one to insert a template around it, say src, that does not > > work in org-mode, but for it works an environment in auctex. > > Yes, I do often find myself killing a bunch of lines, inserting the > template and then yanking the lines back. > It might be worth taking a look at something like yasnippet which provides both easy to insert templates and the wrap-around functionality you would like. It's very easy to write snippets which support both these use cases. Cheers, Will
Re: [O] org-ctrl-c-ctrl-c in comments
>>> "Eric" == Eric S Fraga writes: > On Wednesday, 9 Dec 2015 at 08:45, Uwe Brauer wrote: >> Really all these keys? : C-c ' C-c C-c C-c ' > Without the ":". > the sequence means edit the block in that block's language (C-c '), > update table (C-c C-c), and finish editing block and return to main text > (C-c '). Ah now I understand, thanks Eric, thank you Chuck. Not sure which solution is better the drawer or the src solution :-D
Re: [O] org-ctrl-c-ctrl-c in comments
> Uwe Brauer writes: > Not that I know of, but you can use > (info "(org) Easy templates") > to add a shortcut. Great works nicely. Thanks
[O] org-element-at-point and special blocks
Hi, Is there a reason why org-element-at-point reports the type to be a paragraph for special blocks? E.g. in the examples at the bottom of this mail, where | is the cursor, the types are: export-block, src-block and paragraph with a nested special block. Is there a neat way to detect if point is inside a block? I’m trying to write a function for structures (e.g. #+begin_latex) that works like org-babel-demarcate-block. Thanks, Rasmus #+BEGIN_LaTeX | #+END_LaTeX #+BEGIN_SRC emacs-lisp | #+END_SRC #+begin_abstract | #+end_abstract -- Dung makes an excellent fertilizer
Re: [O] LaTeX export with section number, name and page in internal links
John Kitchin writes: >> I do something like this with custom link types. > Aha! I am not the only one ;) > >> >> First of all, have a look at the variable >> >> org-latex-prefer-user-labels > > Is this a new 8.3 variable? It doesn't seem to be in my 8.2.10 MELPA > version. Yes, I believe it is new in 8.3, although it originated in a patch I wrote quite a while ago (February 2014?) when I needed this behavior. > I like your idea. I think you could simplify it to just: > > (org-add-link-type > "sec" > (lambda (path) >(org-open-link-from-string (format "[[#%s]]" path))) > ... Ah, nice, that is way simpler. Thanks! Best, Richard
Re: [O] org-ctrl-c-ctrl-c in comments
Uwe Brauer writes: > > Uwe Brauer writes: > > > OK - you can also select the drawers that you will (or will not) export. > > See the doc for the variable org-export-with-drawers (which is what is > > manipulated with the d: option above). > > Silly question: is there any keybinding for inserting automatically > #+OPTIONS: d:nil > > before the drawer? > I can't find anything in the documentation. Not that I know of, but you can use (info "(org) Easy templates") to add a shortcut. -- Nick
Re: [O] org-ctrl-c-ctrl-c in comments
> Uwe Brauer writes: > OK - you can also select the drawers that you will (or will not) export. > See the doc for the variable org-export-with-drawers (which is what is > manipulated with the d: option above). Silly question: is there any keybinding for inserting automatically #+OPTIONS: d:nil before the drawer? I can't find anything in the documentation.
Re: [O] pop-up flashing box using org-timer?
Sharon Kimble writes: > I'm using org-timer via "C-c C-x ;" and setting it for 30 minutes for a > repetitive job that I'm doing. When it ends it has a small popup which > shows its ended but that soon disappears. Is it possible for it to show > a flashing popup that will show even if I'm not an org-mode buffer? Like > in the code block showing at the end? > The timer code uses org-notify which in turn uses org-show-notification. The latter goes through a sequence of steps, until one succeeds: It first checks whether org-show-notification-handler is defined and either calls it (if a function) or executes it (if a string); so you can define it to be something that does what you want. If that is not defined, it checks whether notifications-notify is bound and is a function, and calls it if so (in my case at least, it's not defined). It then checks whether there is an executable called notify-send on the system and if so, it executes it (that's what happens in my case with Fedora 22 Linux). The appt popup code you quote also uses notify-send (assuming that X is running). BTW, I'm not sure what happens if you execute notify-send on the console. Finally, as a last resort and if everything else has failed, it calls message to put the notification in the echo area. HTH. -- Nick
[O] pop-up flashing box using org-timer?
I'm using org-timer via "C-c C-x ;" and setting it for 30 minutes for a repetitive job that I'm doing. When it ends it has a small popup which shows its ended but that soon disappears. Is it possible for it to show a flashing popup that will show even if I'm not an org-mode buffer? Like in the code block showing at the end? I am using the following code for showing appointments that are, and have just, occurred. Is it possible for this code be adapted to show a similar popup that flashes like this does please? Thanks Sharon. --8<---cut here---start->8--- #+BEGIN_SRC emacs-lisp (appt-activate t) ;; 5 minute warning (setq appt-message-warning-time '15) (setq appt-display-interval '5) #+END_SRC [2014-11-14 Fri 11:43] #+BEGIN_SRC emacs-lisp (defun djcb-popup (title msg &optional icon sound) ;; http://emacs-fu.blogspot.co.uk/2009/11/showing-pop-ups.html "Show a popup if we're on X, or echo it otherwise; TITLE is the title of the message, MSG is the context. Optionally, you can provide an ICON and a sound to be played" (interactive) (when sound (shell-command (concat "mplayer -really-quiet " sound " 2> /dev/null"))) (if (eq window-system 'x) (shell-command (concat "notify-send " (if icon (concat "-i " icon) "") " '" title "' '" msg "'")) ;; text only version (message (concat title ": " msg (djcb-popup "Warning" "The end is near" "/usr/share/icons/test.png" "/usr/share/sounds/beep.ogg") ;; the appointment notification facility (setq appt-message-warning-time 15 ;; warn 15 min in advance appt-display-mode-line t ;; show in the modeline appt-display-format 'window) ;; use our func (appt-activate 1) ;; active appt (appointment notification) (display-time) ;; time display is required for this... ;; update appt each time agenda opened (add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt) ;; our little façade-function for djcb-popup (defun djcb-appt-display (min-to-app new-time msg) (djcb-popup (format "Appointment in %s minute(s)" min-to-app) msg "/usr/share/icons/gnome/32x32/status/appointment-soon.png" )) ;; "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg" (setq appt-disp-window-function (function djcb-appt-display)) ;; you might also want to set: (setq org-agenda-skip-unavailable-files t) ;; so these warnings won't annoy the little remember-frame ;; also: I have noted infrequent problems when using ElScreen ;; (the wrong frame might be chosen for Remember in about 10% of the cases) #+END_SRC [2014-11-14 Fri 12:07] #+BEGIN_SRC emacs-lisp (defun my-appt-disp-window (min-to-app new-time msg) (save-window-excursion (async-shell-command (concat "/usr/bin/zenity --info --title='Appointment' --text='" msg "'") nil nil))) #+END_SRC [2014-11-14 Fri 11:44] --8<---cut here---end--->8--- -- A taste of linux = http://www.sharons.org.uk TGmeds = http://www.tgmeds.org.uk Debian 8.0, fluxbox 1.3.7, emacs 24.5.1 signature.asc Description: PGP signature
Re: [O] org-ctrl-c-ctrl-c in comments
Uwe Brauer writes: >> On Tue, 8 Dec 2015, Uwe Brauer wrote: > >> Sorry. You have to put the code into an edit buffer to be able to use >> native org mode edit commands. > > I still do not understand what you mean by edit buffer, (info "(org) Editing source code") -- Nick
Re: [O] org-ctrl-c-ctrl-c in comments
Uwe Brauer writes: "Nick" == Nick Dokos writes: > > > Uwe Brauer writes: > >> > Hello, > >> > Uwe Brauer writes: > >> > >> > >> > You can use drawers for that. > >> > >> No I cannot, I just found out about drawers, > >> however they *are* exported, when calling org-mime-htmlize, so they > >> don't serve my needs. > >> > > > Even if you set > > > #+OPTIONS: d:nil > > You mean > Hello > > #+OPTIONS: d:nil > :test: > > | this | that > :END: > > > That indeed works, thanks! > OK - you can also select the drawers that you will (or will not) export. See the doc for the variable org-export-with-drawers (which is what is manipulated with the d: option above). -- Nick
Re: [O] org-ellipsis problem
On Tue, Dec 8, 2015 at 10:53 AM, Eric S Fraga wrote: > On Monday, 30 Nov 2015 at 15:10, Dan Griswold wrote: > > Setting org-ellipsis (either via setq or customize) has no effect for me. > > Maybe show us how you actually do it? What version of org? What is > your intended result (just in case)? > > I have > > (setq org-ellipsis " ▸") > > in my customisation and it works just fine. > Thanks, Eric. It helped to know that it works for someone. Knowing that, I went into my .emacs file and did some testing. It turns out that there is some conflict with pp-c-l. These lines: (use-package pp-c-l) (pretty-control-l-mode 1) would mess up org-mode's use of org-ellipsis. I don't know why. But commenting out those two lines solves the problem for me. Regards, Dan
Re: [O] org-ctrl-c-ctrl-c in comments
On Wednesday, 9 Dec 2015 at 08:45, Uwe Brauer wrote: > Really all these keys? : C-c ' C-c C-c C-c ' Without the ":". the sequence means edit the block in that block's language (C-c '), update table (C-c C-c), and finish editing block and return to main text (C-c '). -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-379-g38fd09
Re: [O] Beamer export: metropolis-theme specific question
On Tuesday, 8 Dec 2015 at 21:07, zang_n...@posteo.de wrote: > Dear fellow Orgers, > > I like the metropolis beamer theme a lot [1], and I use it with Org > frequently. metropolis has a \plain macro that inserts a new, minimally > styled slide optimal for a short statement or an image. In plain latex, > I would do e.g. [...] > I just cannot get my head around how to tell Org to do this! If I do > > * a normal frame with title etc. > some content > > #+BEGIN_LATEX > \plain{another normal frame with title etc.} > #+END_LATEX > > * another normal frame with title etc. > some other content This is really tricky because a headline in org both ends the preceding frame and starts a new frame. The only way I can think of is for you to explicitly end and start the adjoining frames, as in: #+begin_src org ,* a normal frame with title etc. some content ,#+BEGIN_LATEX \end{frame} \plain{another normal frame with title etc.} \begin{frame}{another normal frame with title etc.} ,#+END_LATEX some other content #+end_src This will be somewhat fragile, e.g. if previous frame has columns they will also need to be terminated properly... HTH, eric -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-379-g38fd09
Re: [O] org-ctrl-c-ctrl-c in comments
> On Tue, 8 Dec 2015, Uwe Brauer wrote: > Sorry. You have to put the code into an edit buffer to be able to use > native org mode edit commands. I still do not understand what you mean by edit buffer, I copied the lines below in the *scratch* buffer (or it could be a message buffer) > So with the cursor where you have indicated above, > : C-c ' C-c C-c C-c ' Really all these keys? : C-c ' C-c C-c C-c ' Does not work for me, nothing happens. Thanks for your help,I am really sorry, but I reproduce your steps.
Re: [O] org-ctrl-c-ctrl-c in comments
>>> "Nick" == Nick Dokos writes: > Uwe Brauer writes: >> > Hello, >> > Uwe Brauer writes: >> >> >> > You can use drawers for that. >> >> No I cannot, I just found out about drawers, >> however they *are* exported, when calling org-mime-htmlize, so they >> don't serve my needs. >> > Even if you set > #+OPTIONS: d:nil You mean Hello #+OPTIONS: d:nil :test: | this | that :END: That indeed works, thanks!
Re: [O] Embedding and extracting license/author information in an image file
On Tuesday, 8 Dec 2015 at 11:15, Julien Cubizolles wrote: > Eric S Fraga writes: > >> On Monday, 7 Dec 2015 at 22:08, Julien Cubizolles wrote: >>> I often include images in my org documents and would like to properly >>> cite the license, and/or author. I was thinking that this could be >>> simplified by: >>> >>> * embedding the license/author information in some metadata of the jpg >>> or png file (it seems that some standard called xmp can be used to >>> embed data in png/jpg [fn:1]) preferably using some emacs tool >> >> I use jhead for adding a copyright statement to my photos (in >> JPEG). > > Thanks, is there a dedicated field for copyright statements ? Did some > good soul already code some lisp around it ? No idea to both of those. I use the -cl option for jhead: -cl string Replace comment with specified string from command line file -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-379-g38fd09
Re: [O] LaTeX-close-environment: org-close-template
On Tuesday, 8 Dec 2015 at 17:04, Uwe Brauer wrote: >> On Tuesday, 8 Dec 2015 at 10:34, Uwe Brauer wrote: > >> I don't. However, I find that using the easy templates (e.g. > insert a src block, > latex-insert-block, does the equivalent and better (in my opinion, of >> course ;-). There isn't an entry for comment blocks but you can >> define >> your own: > better why? Because it avoids typing the first line as well... but I didn't say that what you wanted wasn't useful. > I think the opposite, for example, another missing feature: if you mark > a text and one to insert a template around it, say src, that does not > work in org-mode, but for it works an environment in auctex. Yes, I do often find myself killing a bunch of lines, inserting the template and then yanking the lines back. > In any case, the point is: sometimes you incidentally may delete say > #+end_src, so having a function which I described spare you to copy and > paste text. Sure. -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-379-g38fd09