10 ms·
Emacs org-mode examples and cookbook (2017)
- submeta 6y agoThis is excellent. Been using Emacs/org for all my writing projects for a year now, and this site gives a wonderful overview of many things I have learned the hard way. - Thank you for sharing this.
- ldx77 6y agoI 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).
- neolog 6y agoIs each block converted into a function? Otherwise it's a syntax error.
- sahkopoyta 6y agoYes they are, for me that exact snippet is fine
- deleted 6y ago[deleted]
- superbcarrot 6y agoThis 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.
- rcdwealth 6y agoIt 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.
- Jeff_Brown 6y agoI 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.
- JHonaker 6y agoI 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.
- nanna 6y ago> admit to myself that I'm not a real man Note, many emacs users aren't men at all.
- deleted 6y ago[deleted]
- superbcarrot 6y agoI know. It's a figure of speech, not a reference to the demographics of emacs users.
- Y_Y 6y agocertainly not, they are gods
- Thibi2000 6y agoYou 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()) )"
- danieldk 6y agoI 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.
- tobbe2064 6y agoThere is a package which lets you interact with ipython kernels instead. You might want to check that out. https://github.com/nnicandro/emacs-jupyter https://github.com/nnicandro/emacs-jupyter
- nprescott 6y agoI 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/msg00274.html https://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg... [1]: https://orgmode.org/list/87pnfdo88v.fsf@gmail.com/t/#u https://orgmode.org/list/87pnfdo88v.fsf@gmail.com/t/#u
- dang 6y agoDiscussed at the time: Emacs org-mode examples and cookbook - https://news.ycombinator.com/item?id=13828732 https://news.ycombinator.com/item?id=13828732 - March 2017 (161 comments)
- mkl95 6y agoI have been using Emacs (Python and C/C++) and Org for a few years now. Org's HTML export is a godsend feature.
- singingfish 6y agoOrg is great. I recently hooked up my working notes directory to our gitlab instance at work. With git auto-commit-mode I can show my colleagues nicely formatted notes. When I need to export to word I can do that with pandoc. I wish I used babel more. Last I used was to give live examples for some external API interactions we needed to document.
- deleted 6y ago[deleted]
- xenodium 6y agoI love org. I wish it was used by more apps as portable storage/format across platforms. I recently scratched my own itch and wrote an iOS habit tracker app, backed by org mode https://news.ycombinator.com/item?id=26306018 https://news.ycombinator.com/item?id=26306018
- ta988 6y agoI've came to love asciidoc too, much simpler and clearer syntax. But the support is still too limited (and require a ton of libraries)
- Rochus 6y agoWell, org-mode obviously has very powerful features; but I am rather avoiding Emacs and prefer my https://github.com/rochus-keller/CrossLine https://github.com/rochus-keller/CrossLine for note taking and information management; I can already generate navigable HTML pages for hand-out and I intend to implement an Asciidoc and LuaTeX export too.
- rcdwealth 6y agoThat looks as great application, thank you. I am not now hot to download all dependencies, and especially Qt as dependency is overkill. Did you see Leo editor? It works similar. Emacs works well on console and in GUI, so it is not just GUI application, that is big advantage. If you develop SQL application like that, I suggest you develop API in the same time and have the editor rather use the API, so that any other language can access the Outline structure you are creating. I wish I could run it, try it out, but dependencies are too much.
- Rochus 6y agoThe two available binary downloads for Windows (see http://software.rochus-keller.info/CrossLine_win32.zip http://software.rochus-keller.info/CrossLine_win32.zip) and Linux i386 are static builds with Qt statically linked, so no other dependencies; the Windows binary also works well with Wine on Linux and Mac; both only a few megabytes uncompressed. Didn't know Leo; will have a look at it. My preferred IDE is Qt Creator 3.x.
- agumonkey 6y agogotta admit using external code as org-table formula was a nice trick http://ehneilsen.net/notebook/orgExamples/org-examples.html#sec-8-2 http://ehneilsen.net/notebook/orgExamples/org-examples.html#... also, even though calc rpn stack is cute, having it in SRC blocks is quite dandy
- nanna 6y agoAnyone know if it's possible to tag a paragraph, or non-heading element, in org?
- olivierestsage 6y agoI do this in a sort of roundabout way, by actually using a new heading for each paragraph (helps with outlining). You can make this work by adding the :ignore: tag to the headings, which means that the heading titles won't be exported when you export the document, but the text under them will. Basically, you get an invisible outline of your document that you can tag however you like. It requires some light setup to get working, since it's not part of the base functionality of Org. First, add these lines to your config (more details on StackExchange[1]): (require 'ox-extra) (ox-extras-activate '(ignore-headlines)) Now you can add the :ignore: tag, and any other tags you want, to the heading for any paragraph. When you export, you'll just get the paragraphs, not the headings or tags. [1] https://emacs.stackexchange.com/questions/38184/org-mode-ignore-heading-when-exporting-to-latex https://emacs.stackexchange.com/questions/38184/org-mode-ign...
- nanna 6y agoThat's pretty neat, thank you! I'll give that a go. I suppose radio target links function a bit like inline tags, in a way, in that wrapping a string in <<<angle brackets>>> and C-c'ing it turns every use of that string in the file into a C-o'able link to the original radio target. Definitely not as featureful as proper :tags: but also has it's uses...
- dangom 6y agoAs a sibling parent mentioned, you can tag an element by inserting it into it's own heading and adding the :ignore: tag. I feel this functionality is overlooked, and it is in my opinion one of the most powerful features implemented in org, as it allows you to add "meta" groupings to your org document without any effect on the content. Without the :ignore: tag, there is a strict semantic relation between org-mode document headings, as physically indicated by the * at the beginning of a line, and the corresponding hierarchical level of the heading's content. With the :ignore: tag, however, you separate content from form. Headings with :ignore: work just as headings for your file.org document: you can search for headings, link to them, add IDs and properties and whatever else you can do with headings. But when you export your document, the heading no longer exists and thus has no impact on the hierarchical level of its content. Why is this interesting? Well, because if content is separated from form, we can build things where the same content assume multiple forms depending on whatever context we define. I used this in combination with other org-mode tags, "#+exclude_tags" and "#+include" directives to build my Ph.D. thesis with org mode and have my thesis chapters be exportable both as thesis chapters as well as standalone publications. Shameless plug: https://github.com/dangom/org-thesis https://github.com/dangom/org-thesis It should be straightforward to extend the idea to presentations and other formats as well.
- j7ake 6y agoI like orgmode and emacs and wish to convert more activities into orgmode. One thing I found tricky was switching computers or getting a new computer can be very disruptive to the emacs/orgmode workflow because of the amount of customizations that build over years of using a specific orgmode workflow. Apps, on the other hand, are very portable between devices (phone, table, laptop). Are there easy solutions to make emacs and orgmode set ups more portable between machines?
- easytiger 6y agoDepends. checkin to a vc repo?
- clircle 6y agoEmacs config in github, org notes in dropbox. I did this for a little while, but now I just use org notes on my work computer, and the ios notes app for personal things. Org need not consume everything.
- nanna 6y agoI've found that using use-package in my init.el to manage, install and customize my packages helps me run a reasonably similar emacs setup across my Linux and Windows computers. I use git to synchronise it across systems. (use-package wordnut :ensure t ;; install package if it doesn't exist :config (global-set-key (kbd "C-c w") 'wordnut-search)) If I want a package to only load on Linux or windows, I can do it so: (use-package xclip :if (eq system-type 'gnu/linux) :ensure t :config (xclip-mode 1)) (use-package w32-browser :if (eq system-type 'windows-nt) :ensure t)
- jeremyjh 6y agoI wish there were a way to pin/lock the version of dependencies. Each time I update all packages something new breaks, and I have to spend time tracking it down and fixing or reverting it. So I've just been syncing my entire .emacs.d folder.
- 6y ago
- sigmonsays 6y agoThis is a nicely timed article, i'm thirsty for emacs. I dived into emacs in janurary 2021 fully using doom emacs. I started doing scrum and meeting notes in org, then find myself slowly switching existing notes over to it. i keep all my emacs configs from ~/.doom.d in git and can easily bounce from machine to machine. Setup is pretty easy and i've found to have the same emacs experience where I go.
- amichail 6y agoDon't you think an org-mode for TeXmacs would be even better?
- dan-robertson 6y agoWhy would it be better? Org-mode can generate latex output but the whole point is to be a more human-readable markup format than latex. Org-mode can also convert your equations to images and display them inline.
- BostonEnginerd 6y agoTeXmacs is a great looking piece of software, but I've never understood the name. I don't think it uses TeX underneath the hood, nor does it use Emacs.
- cwlb 6y agoI switched to Spacemacs around the same time you picked up Doom and dropped Spacemacs for Doom around a month ago. I'm not really a note taker, and I haven't picked up org yet. I actually uninstalled it before I realized that all the Doom docs are written in it and without org-mode you can't follow links XD
- jacobmoe 6y agoI've been using spacemacs for a while, haven't looked into doom. Mind telling me why you decided to switch?
- agentultra 6y agoOrg mode is my documentation secret weapon. I write books, presentations, technical documentation, and even literate data migration scripts. Some added tips: ditaa is cool but you can also integrate mermaid [0] well and display inline images. There's a well-done revealjs [1] exporter. And you can also use results blocks as input to other code blocks! PDF export is excellent and integrates well with some scripts I wrote to publish them to my remarkable. Great for writing and then reviewing specs on the go. The drawback is that sharing the document sources with a team is hard since so few people on a team are likely going to be emacs users. Only work around I have for that is to run emacs in batch mode to generate/export docs... or just export to markdown and maintain in markdown if the team uses a different tool or dislikes the org syntax. [0] https://mermaid-js.github.io/mermaid/#/ https://mermaid-js.github.io/mermaid/#/ [1] https://github.com/yjwen/org-reveal https://github.com/yjwen/org-reveal
- DiggyJohnson 6y agoI am breaking the guidelines [0] in good faith to link to a mirror. Host limit exceeded on the author's blog (Thu 11 Mar 2021 01:07:37 AM UTC). https://web.archive.org/web/20210122070120/http://ehneilsen.net/notebook/orgExamples/org-examples.html https://web.archive.org/web/20210122070120/http://ehneilsen.... [0] https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- ashton314 6y agoI used to use Markdown for all my personal notes. Now I use org-mode. Part of what made this possible was finding Working Copy on iOS so I could view and edit my org-mode documents. It makes me very happy that GitHub supports formatting your README in org-mode.
- sudhirkhanger 6y agoIs there a way to view live preview of org file? Say in the next window.
- mcncm 6y agoDespite being a plain-text format, it can be made very human-readable with minimal configuration. If you want to auto-export to your preferred format on save, say, and view it live in a parallel window, you can accomplish that with a single line of Emacs Lisp. This is what Emacs is all about: if you can do anything with a tiny little elisp function, there isn't exactly a clear bulleted list of what the "features" of an application are. Some people really like that.
- felixr 6y agohttps://web.archive.org/web/20210122070120/http://ehneilsen.net/notebook/orgExamples/org-examples.html https://web.archive.org/web/20210122070120/http://ehneilsen....
- ipnon 6y agoI've been dreaming of a full Lisp port of Emacs to get rid of all the baremetal C routines and GNU libraries. Just write the whole thing in Racket or something similar.
- msla 6y agoIt's been done: https://en.wikipedia.org/wiki/Multics_Emacs https://en.wikipedia.org/wiki/Multics_Emacs > Multics Emacs is an early implementation of the Emacs text editor.[1] It was written in Maclisp by Bernard Greenberg at Honeywell's Cambridge Information Systems Lab in 1978, as a successor to the original 1976 TECO implementation of Emacs and a precursor of later GNU Emacs. https://en.wikipedia.org/wiki/EINE_and_ZWEI https://en.wikipedia.org/wiki/EINE_and_ZWEI > EINE and ZWEI are two discontinued Emacs-like text editors developed by Daniel Weinreb and Mike McMahon for Lisp machines in the 1970s and 1980s. [snip] > Unlike the original TECO-based Emacs, but like Multics Emacs, EINE was written in Lisp. It used Lisp Machine Lisp. The only one you might be able to run natively now is Hemlock: https://en.wikipedia.org/wiki/Hemlock_(text_editor) https://en.wikipedia.org/wiki/Hemlock_(text_editor) > Hemlock is a free Emacs text editor for most POSIX-compliant Unix systems. It follows the tradition of the Lisp Machine editor ZWEI and the ITS/TOPS-20 implementation of Emacs, but differs from XEmacs or GNU Emacs, the most popular Emacs variants, in that it is written in Common Lisp rather than Emacs Lisp and C—although it borrows features from the later editors.