News for hackers. Stuff that matters.
Re:Emacs org-mode examples and cookbook (2017) by ldx77 on Wednesday March 10, 2021 @03:17AM (#26409024)
I use org-mode all the time and do a lot of plotting with Python and matplotlib and for some reason the snippet

  #+BEGIN_SRC python :var fname="delseepy.png" :var delsee=delsee :results file
  import matplotlib.pyplot as plt
  
  x, y, z = zip(\*delsee)
  
  fig = plt.figure()
  axes = fig.add_subplot(1,1,1)
  axes.plot(y, z, marker='o')
  fig.savefig(fname)
  
  return fname
  #+END_SRC
has never worked for me. I have to remove the "return" keyword on the last line. Not sure if this is an org-mode issue or related to the Python version (the author seems to be using Python 2).
Re:Emacs org-mode examples and cookbook (2017) by superbcarrot on Wednesday March 10, 2021 @04:34AM (#26409489)
This has been my limited experience with everything related to Emacs - fragmented tutorials on how to do x that work with someone's specific setup. And when you start looking around for fixes you get solutions for "this is how I do this with Prelude", "this is built-in", "my customized Spacemacs setup..." and at that point I throw my hands in the air, admit to myself that I'm not a real man and go back to VSCode.
Re:Emacs org-mode examples and cookbook (2017) by rcdwealth on Wednesday March 10, 2021 @05:37AM (#26409880)
It is so. Emacs contains the full Emacs manual, non-fragmented, compact and complete, including the full Org mode manual, non-fragmented. It is self-documenting program. Users can learn what is built-in feature and what exists before starting to use extensions.

If you try to do too much at once, of course, you are prone to give up as you started on a too high gradient.

Re:Emacs org-mode examples and cookbook (2017) by Jeff_Brown on Wednesday March 10, 2021 @08:32AM (#26411004)
I think I'm a pretty adept emacs user, and I've relied at least ten times more on crappy informal documentation in blogs, StackOverflow etc. than on the real stuff.
Re:Emacs org-mode examples and cookbook (2017) by JHonaker on Wednesday March 10, 2021 @02:57PM (#26415402)
I do that too, but out of habit from other pursuits rather than a real necessity. Recently, I've found myself going to Emacs and packages' internal help first, and I usually find what I'm looking for. Despite me spending several years not believing it, it's really good documentation for the most part.
Re:Emacs org-mode examples and cookbook (2017) by nanna on Wednesday March 10, 2021 @07:01AM (#26410345)
> admit to myself that I'm not a real man

Note, many emacs users aren't men at all.

Re:Emacs org-mode examples and cookbook (2017) by Y_Y on Thursday March 11, 2021 @02:51PM (#26428240)
certainly not, they are gods
Re:Emacs org-mode examples and cookbook (2017) by superbcarrot on Wednesday March 10, 2021 @07:09AM (#26410383)
I know. It's a figure of speech, not a reference to the demographics of emacs users.
Re:Emacs org-mode examples and cookbook (2017) by nprescott on Wednesday March 10, 2021 @09:57AM (#26411841)
I have tried with both python 2.7.18 and python 3.8.6 using Emacs 27.1 and the excerpt works without issue for me; I have no configuration (emacs -Q) beyond pointing org to my virtual environment and allowing python evaluation in org-babel:

  (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  (setq org-babel-python-command "~/mpl-venv/bin/python")
Are you perhaps on an outdated version of Emacs?

There have been a few different fixes around the "last line" return value over the years[0][1] but I can't really remember something like your example not working for me personally.

[0]: https://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg...

[1]: https://orgmode.org/list/[email protected]/t/#u

Re:Emacs org-mode examples and cookbook (2017) by Thibi2000 on Wednesday March 10, 2021 @04:40AM (#26409527)
You might have to check the value of =org-babel-python-wrapper-method=, which defines the format of the created temporary file to which the source block is exported so it can be executed properly.

After installing matplotlib using pip3 and changing =org-babel-python-command= to python3 I was able to execute this example without a problem.

The value of =org-babel-python-wrapper-method= for me is:

  def main():
  %s

  open('%s', 'w').write( str(main()) )"
Re:Emacs org-mode examples and cookbook (2017) by danieldk on Wednesday March 10, 2021 @05:41AM (#26409903)
I have found that over time org documents tend to become coupled somewhat to your Emacs configuration and are not generally portable. I guess this is the reason why many org example snippets on the net do not really work exactly the same.
Re:Emacs org-mode examples and cookbook (2017) by neolog on Wednesday March 10, 2021 @03:19AM (#26409042)
Is each block converted into a function? Otherwise it's a syntax error.
Re:Emacs org-mode examples and cookbook (2017) by sahkopoyta on Wednesday March 10, 2021 @03:27AM (#26409099)
Yes they are, for me that exact snippet is fine
Re:Emacs org-mode examples and cookbook (2017) by tobbe2064 on Wednesday March 10, 2021 @06:47AM (#26410266)
There is a package which lets you interact with ipython kernels instead. You might want to check that out.

https://github.com/nnicandro/emacs-jupyter