├── .dir-locals.el ├── .gitignore ├── CONTRIBUTE.org ├── COPYING ├── Makefile ├── README.org ├── doc ├── .aspell.org.conf ├── .nosearch ├── Documentation_Standards.org ├── Makefile ├── dir ├── doc-setup.org ├── fdl.org ├── htmlxref.cnf ├── org-guide.org ├── org-manual.org ├── orgcard.tex ├── pdflayout.sty └── texinfo.tex ├── etc ├── Makefile ├── ORG-NEWS ├── csl │ ├── README │ ├── chicago-author-date.csl │ └── locales-en-US.xml ├── schema │ ├── OpenDocument-schema-v1.3+libreoffice.rnc │ ├── OpenDocument-schema-v1.3.rnc │ ├── od-manifest-schema-v1.2-os.rnc │ └── schemas.xml └── styles │ ├── OrgOdtContentTemplate.xml │ ├── OrgOdtStyles.xml │ └── README ├── lisp ├── Makefile ├── ob-C.el ├── ob-R.el ├── ob-awk.el ├── ob-calc.el ├── ob-clojure.el ├── ob-comint.el ├── ob-core.el ├── ob-css.el ├── ob-ditaa.el ├── ob-dot.el ├── ob-emacs-lisp.el ├── ob-eshell.el ├── ob-eval.el ├── ob-exp.el ├── ob-forth.el ├── ob-fortran.el ├── ob-gnuplot.el ├── ob-groovy.el ├── ob-haskell.el ├── ob-java.el ├── ob-js.el ├── ob-julia.el ├── ob-latex.el ├── ob-lilypond.el ├── ob-lisp.el ├── ob-lob.el ├── ob-lua.el ├── ob-makefile.el ├── ob-matlab.el ├── ob-maxima.el ├── ob-ocaml.el ├── ob-octave.el ├── ob-org.el ├── ob-perl.el ├── ob-plantuml.el ├── ob-processing.el ├── ob-python.el ├── ob-ref.el ├── ob-ruby.el ├── ob-sass.el ├── ob-scheme.el ├── ob-screen.el ├── ob-sed.el ├── ob-shell.el ├── ob-sql.el ├── ob-sqlite.el ├── ob-table.el ├── ob-tangle.el ├── ob.el ├── oc-basic.el ├── oc-biblatex.el ├── oc-bibtex.el ├── oc-csl.el ├── oc-natbib.el ├── oc.el ├── ol-bbdb.el ├── ol-bibtex.el ├── ol-docview.el ├── ol-doi.el ├── ol-eshell.el ├── ol-eww.el ├── ol-gnus.el ├── ol-info.el ├── ol-irc.el ├── ol-man.el ├── ol-mhe.el ├── ol-rmail.el ├── ol-w3m.el ├── ol.el ├── org-agenda.el ├── org-archive.el ├── org-attach-git.el ├── org-attach.el ├── org-capture.el ├── org-clock.el ├── org-colview.el ├── org-compat.el ├── org-crypt.el ├── org-ctags.el ├── org-cycle.el ├── org-datetree.el ├── org-duration.el ├── org-element-ast.el ├── org-element.el ├── org-entities.el ├── org-faces.el ├── org-feed.el ├── org-fold-core.el ├── org-fold.el ├── org-footnote.el ├── org-goto.el ├── org-habit.el ├── org-id.el ├── org-indent.el ├── org-inlinetask.el ├── org-keys.el ├── org-lint.el ├── org-list.el ├── org-macro.el ├── org-macs.el ├── org-mobile.el ├── org-mouse.el ├── org-num.el ├── org-pcomplete.el ├── org-persist.el ├── org-plot.el ├── org-protocol.el ├── org-refile.el ├── org-src.el ├── org-table.el ├── org-tempo.el ├── org-timer.el ├── org.el ├── ox-ascii.el ├── ox-beamer.el ├── ox-html.el ├── ox-icalendar.el ├── ox-koma-letter.el ├── ox-latex.el ├── ox-man.el ├── ox-md.el ├── ox-odt.el ├── ox-org.el ├── ox-publish.el ├── ox-texinfo.el └── ox.el ├── mk ├── default.mk ├── guidesplit.pl ├── manfull.pl ├── mansplit.pl ├── org-fixup.el ├── orgcard2txt.pl ├── server.mk └── targets.mk └── testing ├── README ├── examples ├── Basic.bib ├── agenda-file.org ├── agenda-file2.org ├── agenda-search.org ├── att1 │ ├── fileA │ └── fileB ├── att2 │ ├── fileC │ └── fileD ├── attachments.org ├── babel-dangerous.org ├── babel.el ├── babel.org ├── data │ └── ab │ │ └── cd123 │ │ └── fileE ├── diary-file ├── images │ └── Org mode logo mono-color.png ├── include.html ├── include.org ├── include2.org ├── link-in-heading.org ├── links.org ├── macro-templates.org ├── no-heading.org ├── normal.org ├── ob-C-test.org ├── ob-awk-test.in ├── ob-awk-test.org ├── ob-fortran-test.org ├── ob-header-arg-defaults.org ├── ob-lilypond-broken.ly ├── ob-lilypond-broken.org ├── ob-lilypond-test.error ├── ob-lilypond-test.ly ├── ob-lilypond-test.org ├── ob-maxima-test.org ├── ob-octave-test.org ├── ob-screen-test.org ├── ob-sed-test.org ├── org-exp.org ├── property-inheritance.org ├── pub-cache │ ├── config.org │ └── source.org ├── pub-symlink │ └── link.org ├── pub │ ├── a.org │ ├── b.org │ ├── file.txt │ ├── index │ │ ├── file1.org │ │ └── file2.org │ ├── link │ ├── noextension │ └── sub │ │ └── c.org ├── setupfile.org ├── setupfile3.org ├── sub-bib │ ├── include-global-bib.org │ └── include-relative-bib.org └── subdir │ └── setupfile2.org ├── lisp ├── test-duplicates-detector.el ├── test-ob-C.el ├── test-ob-R.el ├── test-ob-awk.el ├── test-ob-calc.el ├── test-ob-clojure.el ├── test-ob-comint.el ├── test-ob-emacs-lisp.el ├── test-ob-eshell.el ├── test-ob-exp.el ├── test-ob-fortran.el ├── test-ob-haskell-ghci.el ├── test-ob-header-arg-defaults.el ├── test-ob-java.el ├── test-ob-julia.el ├── test-ob-lilypond.el ├── test-ob-lob.el ├── test-ob-lua.el ├── test-ob-maxima.el ├── test-ob-octave.el ├── test-ob-perl.el ├── test-ob-plantuml.el ├── test-ob-python.el ├── test-ob-ruby.el ├── test-ob-scheme.el ├── test-ob-sed.el ├── test-ob-shell.el ├── test-ob-sql.el ├── test-ob-sqlite.el ├── test-ob-table.el ├── test-ob-tangle.el ├── test-ob.el ├── test-oc-basic.el ├── test-oc.el ├── test-ol-bbdb.el ├── test-ol.el ├── test-org-agenda.el ├── test-org-archive.el ├── test-org-attach-git.el ├── test-org-attach.el ├── test-org-capture.el ├── test-org-clock.el ├── test-org-colview.el ├── test-org-ctags.el ├── test-org-datetree.el ├── test-org-duration.el ├── test-org-element.el ├── test-org-feed.el ├── test-org-fold.el ├── test-org-footnote.el ├── test-org-info.el ├── test-org-inlinetask.el ├── test-org-lint.el ├── test-org-list.el ├── test-org-macro.el ├── test-org-macs.el ├── test-org-num.el ├── test-org-pcomplete.el ├── test-org-protocol.el ├── test-org-src.el ├── test-org-table.el ├── test-org-tempo.el ├── test-org-timer.el ├── test-org.el ├── test-ox-ascii.el ├── test-ox-beamer.el ├── test-ox-html.el ├── test-ox-icalendar.el ├── test-ox-latex.el ├── test-ox-man.el ├── test-ox-md.el ├── test-ox-publish.el ├── test-ox-texinfo.el ├── test-ox.el └── test-property-inheritance.el ├── org-batch-test-init.el └── org-test.el /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables -*- no-byte-compile: t; -*- 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((nil 5 | (indent-tabs-mode . t) 6 | (tab-width . 8) 7 | (fill-column . 70) 8 | (sentence-end-double-space . t)) 9 | (emacs-lisp-mode 10 | (indent-tabs-mode)) 11 | (org-mode 12 | (indent-tabs-mode) 13 | (org-adapt-indentation) 14 | (org-edit-src-content-indentation . 0) 15 | (org-footnote-auto-adjust . t) 16 | (org-footnote-auto-label . t) 17 | (org-footnote-define-inline . nil) 18 | (org-footnote-section . "Footnotes") 19 | (org-hide-emphasis-markers . nil))) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Don't bother tracking a bunch of stuff when building and installing 2 | # Org from the master git repository. 3 | 4 | # ...by ignoring everything created by 'make', 'make doc', `make info' 5 | # `make html_manual', `make release' 6 | 7 | *.aux 8 | *.bak 9 | *.cp 10 | *.cps 11 | *.diff 12 | *.dvi 13 | *.elc 14 | *.fn 15 | *.fns 16 | *.html 17 | *.info 18 | *.ky 19 | *.kys 20 | *.log 21 | *.patch 22 | *.pdf 23 | *.pg 24 | *.pgs 25 | *.ps 26 | *.toc 27 | *.tp 28 | *.vr 29 | *.vrs 30 | orgcard_letter.tex 31 | orgcard.txt 32 | org 33 | orgguide 34 | org-loaddefs.el 35 | org-version.el 36 | doc/org.texi 37 | doc/orgguide.texi 38 | doc/org-version.inc 39 | doc/org-version.tex 40 | org-*.tar* 41 | orgplus-*.tar* 42 | org-*.zip 43 | version.mk 44 | manual 45 | org_dual_license.texi 46 | ORGWEBPAGE/Changes.txt 47 | local*.mk 48 | .gitattributes 49 | mk/x11idle 50 | ChangeLog 51 | 52 | # Files generated during `make packages/org` in a clone of `elpa.git`. 53 | 54 | /org-pkg.el 55 | /org-autoloads.el 56 | /lisp/org-autoloads.el 57 | 58 | # texi2pdf --tidy 59 | 60 | doc/*.t2d 61 | 62 | # aspell word and replacement lists 63 | 64 | .aspell.org.pws 65 | .aspell.org.prepl 66 | 67 | # allow tmp and test directories that will not be tracked 68 | 69 | test 70 | t 71 | auto 72 | tmp 73 | TODO 74 | 75 | # and collateral damage from Emacs 76 | 77 | *~ 78 | .DS_Store 79 | *# 80 | .#* 81 | 82 | # 83 | # Local variables: 84 | # End: 85 | -------------------------------------------------------------------------------- /CONTRIBUTE.org: -------------------------------------------------------------------------------- 1 | See [[https://orgmode.org/worg/org-contribute.html][the org-contribute page on Worg]] for guidance on how to contribute 2 | effectively. 3 | 4 | We value a nice tone in our discussions: please check and respect the 5 | [[https://www.gnu.org/philosophy/kind-communication.en.html][GNU Kind Communications Guidelines]]. 6 | 7 | * Contribute as an Org user 8 | 9 | You can contribute by helping others in various channels. 10 | 11 | See [[https://orgmode.org/worg/org-contribute.html#org99b8f3e][these directions]]. 12 | 13 | * Contribute as an Emacs Lisp hacker 14 | 15 | You can contribute with bug reports and patches. 16 | 17 | See these [[https://orgmode.org/worg/org-contribute.html#org069b83a][directions]]. 18 | 19 | * As an Org maintainer 20 | 21 | We encourage you to volunteer to maintain one of the Org files. 22 | 23 | Just [[mailto:emacs-orgmode@gnu.org][send an email to the list]] explaining which file and your 24 | motivations. 25 | 26 | See what is [[https://orgmode.org/worg/org-maintenance.html][the role of a maintainer]]. 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile - for the org-mode distribution 2 | # GNU make is required 3 | # 4 | # This file is not part of GNU Emacs 5 | 6 | # set up environment 7 | include mk/default.mk # defaults, customizable via "local.mk" 8 | -include local.mk # optional local customization, use default.mk as template 9 | 10 | # default target is "all" unless overridden in local.mk 11 | all:: 12 | 13 | # Describe valid make targets for org-mode. 14 | .PHONY: targets help helpall 15 | targets: help 16 | help helpall:: 17 | $(info ) 18 | $(info Getting Help) 19 | $(info ============) 20 | $(info make help - show brief help) 21 | $(info make targets - ditto) 22 | $(info make helpall - show extended help) 23 | $(info ) 24 | $(info Build and Check) 25 | $(info ===============) 26 | $(info make - build Org Elisp and all documentation) 27 | $(info make all - ditto) 28 | $(info make compile - build Org Elisp files) 29 | $(info make single - build Org Elisp files, single Emacs per source) 30 | $(info make native - build Org natively compiled Elisp files) 31 | $(info make autoloads - create org-loaddefs.el to load Org in-place) 32 | $(info make test - build Org Elisp files and run test suite) 33 | $(info make vanilla - run Emacs with this Org-mode and no personal config) 34 | $(info make repro - like vanilla, but refresh compilation and enable debugging [use this to reproduce bugs]) 35 | helpall:: 36 | $(info make test-dirty - check without building first) 37 | $(info make compile-dirty - build only stale Org Elisp files) 38 | $(info ) 39 | $(info Compatibility) 40 | $(info =============) 41 | $(info make oldorg - what the old make did: compile autoloads info) 42 | $(info ) 43 | $(info Cleaning) 44 | $(info ========) 45 | $(info make clean - remove built Org Elisp files and documentation) 46 | $(info make cleanall - remove everything that can be built and all remnants) 47 | $(info make clean-install - remove previous Org installation) 48 | $(info ) 49 | $(info Configuration Check) 50 | $(info ===================) 51 | help helpall:: 52 | $(info make config - check main configuration) 53 | helpall:: 54 | $(info make config-version - check Org version) 55 | $(info make config-test - check test configuration) 56 | $(info make config-exe - check executables configuration) 57 | $(info make config-cmd - check command configuration) 58 | $(info make config-all - check all configuration) 59 | $(info ) 60 | $(info Documentation) 61 | $(info =============) 62 | help helpall:: 63 | $(info make doc - build all documentation) 64 | helpall:: 65 | $(info make docs - ditto) 66 | help helpall:: 67 | $(info make info - build Info documentation) 68 | helpall:: 69 | $(info make html - build HTML documentation) 70 | $(info make pdf - build PDF documentation) 71 | $(info make card - build reference cards) 72 | $(info make refcard - ditto) 73 | help helpall:: 74 | $(info ) 75 | $(info Installation) 76 | $(info ============) 77 | $(info make install - build and install Org) 78 | helpall:: 79 | $(info make install-etc - build and install files in /etc) 80 | $(info make install-lisp - build and install Org Elisp files) 81 | $(info make install-info - build and install Info documentation) 82 | $(info ) 83 | $(info Convenience) 84 | $(info ===========) 85 | $(info make up0 - pull from upstream) 86 | $(info make up1 - pull from upstream, build and check) 87 | $(info make up2 - pull from upstream, build, check and install) 88 | $(info make update - pull from upstream and build) 89 | $(info make update2 - pull from upstream, build and install) 90 | $(info make uncompiled - combine cleanlisp and autoloads) 91 | $(info make local.mk - create new local.mk as template for adaptation) 92 | help helpall:: 93 | $(info ) 94 | $(info Full documentation on Worg) 95 | $(info ==========================) 96 | $(info https://orgmode.org/worg/dev/org-build-system.html) 97 | @echo "" 98 | 99 | include mk/targets.mk # toplevel make machinery 100 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | This is a distribution of Org Mode, a major mode for keeping notes, 2 | authoring documents, computational notebooks, literate programming, 3 | maintaining to-do lists, planning projects, and more — in a fast and 4 | effective plain text system. 5 | 6 | Check the [[https://orgmode.org][Org Mode website]] for more. 7 | 8 | * Install Org 9 | 10 | Org is part of GNU Emacs: you probably don't need to install it. 11 | 12 | To install a more recent version, please use command: =M-x 13 | list-packages=, find "org" in the list, click on it, and click 14 | "Install" in the popped up window. 15 | 16 | * Join the GNU Project 17 | 18 | Org is part of GNU Emacs and GNU Emacs is part of the GNU Operating 19 | System, developed by the GNU Project. 20 | 21 | If you are the author of an awesome program and want to join us in 22 | writing Free (libre) Software, please consider making it an official 23 | GNU program and become a GNU Maintainer. Instructions on how to do 24 | this are here http://www.gnu.org/help/evaluation. 25 | 26 | Don't have a program to contribute? Look at all the other ways to 27 | help: https://www.gnu.org/help/help.html. 28 | 29 | And to learn more about Free (libre) Software in general, please read 30 | and share this page: https://gnu.org/philosophy/free-sw.html 31 | 32 | * License 33 | 34 | Org-mode is published under the [[https://www.gnu.org/licenses/gpl-3.0.html][GNU GPLv3 license]] or any later 35 | version, the same as GNU Emacs. 36 | 37 | Org-mode is free software: you can redistribute it and/or modify it 38 | under the terms of the GNU General Public License as published by the 39 | Free Software Foundation, either version 3 of the License, or (at your 40 | option) any later version. 41 | 42 | GNU Emacs is distributed in the hope that it will be useful, but 43 | WITHOUT ANY WARRANTY; without even the implied warranty of 44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 45 | General Public License for more details. 46 | 47 | You should have received a copy of the GNU General Public License 48 | along with Org mode. If not, see https://www.gnu.org/licenses/. 49 | -------------------------------------------------------------------------------- /doc/.aspell.org.conf: -------------------------------------------------------------------------------- 1 | # Aspell configuration for proof reading Org documentation. 2 | 3 | # Org documentation is written in American... 4 | 5 | master en_US-w_accents 6 | lang en_US 7 | 8 | # Assume the Org specific word and replacement lists are in the doc 9 | # directory and that any spell check is also run from there. Specify 10 | # this file when running aspell by some command like: 11 | # 12 | # $ aspell check --per-conf=".aspell.org.conf" org.texi 13 | 14 | personal ./.aspell.org.pws 15 | repl ./.aspell.org.prepl 16 | 17 | # Checking options. See man aspell. 18 | 19 | save-repl true 20 | sug-mode normal 21 | ignore-case false 22 | ignore-accents false 23 | 24 | # Filters 25 | 26 | # For some reason the following doesn't seem to work which stuffs up 27 | # trying to use Ispell mode from an Emacs buffer (at least I cannot 28 | # make it work) but aspell seems abot to recognise texinfo files 29 | # automatically when checking from the command line so it doesn't 30 | # matter much. 31 | 32 | # mode texinfo 33 | 34 | lset-filter tex:url 35 | 36 | # Let's be clear about what we choose to ignore. 37 | 38 | clear-f-texinfo-ignore 39 | 40 | add-f-texinfo-ignore c 41 | add-f-texinfo-ignore code 42 | add-f-texinfo-ignore command 43 | add-f-texinfo-ignore documentencoding 44 | add-f-texinfo-ignore email 45 | add-f-texinfo-ignore env 46 | add-f-texinfo-ignore file 47 | add-f-texinfo-ignore kbd 48 | add-f-texinfo-ignore macro 49 | add-f-texinfo-ignore option 50 | add-f-texinfo-ignore printindex 51 | add-f-texinfo-ignore samp 52 | add-f-texinfo-ignore set 53 | add-f-texinfo-ignore setfilename 54 | add-f-texinfo-ignore syncode 55 | add-f-texinfo-ignore url 56 | add-f-texinfo-ignore value 57 | add-f-texinfo-ignore var 58 | add-f-texinfo-ignore verb 59 | add-f-texinfo-ignore verbatiminclude 60 | add-f-texinfo-ignore vskip 61 | 62 | # Utility options 63 | 64 | backup true 65 | guess true 66 | suggest true 67 | 68 | # Miscellaneous 69 | # 70 | # Org documentation uses a lot of compound words. Try and ignore them 71 | # rather than including them in a specific word list. 72 | 73 | run-together-limit 2 74 | run-together-min 2 75 | 76 | # 77 | 78 | # Local variables: 79 | # fill-column: 72 80 | # mode: conf 81 | # End: 82 | -------------------------------------------------------------------------------- /doc/.nosearch: -------------------------------------------------------------------------------- 1 | No search 2 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: # we don't need default suffix rules 2 | ifeq ($(MAKELEVEL), 0) 3 | $(error This make needs to be started as a sub-make from the toplevel directory.) 4 | endif 5 | .PHONY: all info html pdf card manual guide install \ 6 | clean cleanall clean-install 7 | 8 | all: $(ORG_MAKE_DOC) 9 | 10 | info: org orgguide 11 | 12 | html: org.html orgguide.html 13 | 14 | pdf: org.pdf orgguide.pdf 15 | 16 | card: orgcard.pdf orgcard_letter.pdf orgguide.pdf 17 | 18 | ifneq ($(SERVERMK),) 19 | manual guide:: 20 | -$(RMR) $@ 21 | $(MKDIR) $@ 22 | manual:: org.texi org-version.inc 23 | $(TEXI2HTML) -o $@ $< 24 | ../mk/mansplit.pl $@/* 25 | guide:: orgguide.texi org-version.inc 26 | $(TEXI2HTML) -o $@ $< 27 | ../mk/guidesplit.pl $@/* 28 | endif 29 | 30 | # We increase GC threshold when generating documentation. This 31 | # imrpoves the performance significantly. See 32 | # https://yhetil.org/emacs-devel/9778F176-E724-4E61-B0FB-327BCDD316C0@acm.org 33 | # Too high number may cause memory overflow (for example, it has 34 | # happened in CI during automated build). We choose 50Mb threshold, 35 | # based on the above discussion. 36 | org.texi: org-manual.org 37 | $(BATCH) \ 38 | --eval '(add-to-list `load-path "../lisp")' \ 39 | --eval '(load "../mk/org-fixup.el")' \ 40 | --eval '(setq gc-cons-threshold (* 50 1000 1000))' \ 41 | --eval '(org-make-manual)' 42 | 43 | orgguide.texi: org-guide.org 44 | $(BATCH) \ 45 | --eval '(add-to-list `load-path "../lisp")' \ 46 | --eval '(load "../mk/org-fixup.el")' \ 47 | --eval '(setq gc-cons-threshold (* 50 1000 1000))' \ 48 | --eval '(org-make-guide)' 49 | 50 | org-version.inc: org.texi 51 | @echo "org-version: $(ORGVERSION) ($(GITVERSION))" 52 | @echo "@c automatically generated, do not edit" > org-version.inc 53 | @echo "@set VERSION $(ORGVERSION) ($(GITVERSION))" >> org-version.inc 54 | @echo "@set DATE $(DATE)" >> org-version.inc 55 | 56 | org-version.tex: orgcard.tex 57 | @printf "org-version: $(ORGVERSION) ($(GITVERSION))\n" 58 | @printf "%% automatically generated, do not edit\n" > org-version.tex 59 | @printf "\def\orgversionnumber{$(ORGVERSION)}\n" >> org-version.tex 60 | @printf "\def\\\\versionyear{$(YEAR)}\n" >> org-version.tex 61 | @printf "\def\year{$(YEAR)}\n" >> org-version.tex 62 | 63 | install: org orgguide 64 | if [ ! -d $(DESTDIR)$(infodir) ]; then $(MKDIR) $(DESTDIR)$(infodir); else true; fi ; 65 | $(CP) org.info $(DESTDIR)$(infodir) 66 | $(CP) orgguide.info $(DESTDIR)$(infodir) 67 | $(INSTALL_INFO) --infodir=$(DESTDIR)$(infodir) org.info 68 | $(INSTALL_INFO) --infodir=$(DESTDIR)$(infodir) orgguide.info 69 | 70 | clean: 71 | $(RM) *.pdf *.html *.info *_letter.tex org-version.inc org-version.tex \ 72 | *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.pg *.pgs *.toc \ 73 | *.tp *.tps *.vr *.vrs *.log *.ps 74 | cleanall: clean 75 | $(RM) org.texi orgguide.texi 76 | $(RMR) guide manual 77 | 78 | clean-install: 79 | $(RM) $(DESTDIR)$(infodir)/org* 80 | $(INSTALL_INFO) --infodir=$(DESTDIR)$(infodir) --remove org 81 | $(INSTALL_INFO) --infodir=$(DESTDIR)$(infodir) --remove orgguide 82 | 83 | .SUFFIXES: .texi .tex .txt _letter.tex 84 | 85 | %: %.texi org-version.inc 86 | $(MAKEINFO) --no-split $< -o $@.info 87 | 88 | # the following two lines work around a bug in some versions of texi2dvi 89 | %.pdf: LC_ALL=C 90 | %.pdf: LANG=C 91 | %.pdf: %.texi org-version.inc 92 | $(TEXI2PDF) $< 93 | %.pdf: %.tex org-version.tex 94 | PDFLATEX=$(PDFTEX) $(TEXI2PDF) $< 95 | 96 | %.html: %.texi org-version.inc 97 | $(TEXI2HTML) --no-split -o $@ $< 98 | ifneq ($(SERVERMK),) 99 | ../mk/manfull.pl $@ 100 | 101 | %.txt: %.tex 102 | perl ../mk/orgcard2txt.pl $< > $@ 103 | endif 104 | 105 | %_letter.tex: %.tex 106 | $(BATCH) \ 107 | --eval '(add-to-list `load-path "../lisp")' \ 108 | --eval '(load "org-compat.el")' \ 109 | --eval '(load "../mk/org-fixup.el")' \ 110 | --eval '(org-make-letterformat "$(" visits the Emacs manual, etc. 11 | 12 | In Emacs, you can click mouse button 2 on a menu item or cross reference 13 | to select it. 14 | 15 | * Menu: 16 | 17 | Emacs 18 | * Org Mode: (org). Outline-based notes management and organizer. 19 | * Org Guide: (orgguide). Abbreviated Org mode manual. 20 | -------------------------------------------------------------------------------- /doc/doc-setup.org: -------------------------------------------------------------------------------- 1 | # SETUPFILE for Org manual 2 | 3 | # Copyright (C) 2021-2025 Free Software Foundation, Inc. 4 | # 5 | # This file is part of GNU Emacs. 6 | # 7 | # GNU Emacs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # GNU Emacs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with GNU Emacs. If not, see . 19 | 20 | # XXX: We cannot use TODO keyword as a node starts with "TODO". 21 | #+todo: REVIEW FIXME | DONE 22 | #+property: header-args :eval no 23 | #+startup: overview nologdone 24 | 25 | # Use proper quote and backtick for code sections in PDF output 26 | # Cf. Texinfo manual 14.2 27 | #+texinfo_header: @set txicodequoteundirected 28 | #+texinfo_header: @set txicodequotebacktick 29 | 30 | # Contact Info 31 | #+texinfo_header: @set MAINTAINERSITE @uref{https://orgmode.org,maintainers webpage} 32 | #+texinfo_header: @set MAINTAINER Ihor Radchenko 33 | #+texinfo_header: @set MAINTAINEREMAIL @email{yantar92@posteo.net} 34 | #+texinfo_header: @set MAINTAINERCONTACT @uref{mailto:yantar92@posteo.net,contact the maintainer} 35 | 36 | #+options: H:4 num:t toc:t author:t \n:nil ::t |:t ^:nil -:t f:t *:t <:t e:t ':t 37 | #+options: d:nil todo:nil pri:nil tags:not-in-toc stat:nil broken-links:mark 38 | #+select_tags: export 39 | #+exclude_tags: noexport 40 | 41 | #+macro: cite @@texinfo:@cite{@@$1@@texinfo:}@@ 42 | #+macro: var @@texinfo:@var{@@$1@@texinfo:}@@ 43 | 44 | # The "version" macro extracts "Version" keyword from "org.el". It 45 | # returns major.minor version number. This is sufficient since bugfix 46 | # releases are not expected to add features and therefore imply manual 47 | # modifications. 48 | #+macro: version (eval (with-current-buffer (find-file-noselect "../lisp/org.el") (org-with-point-at 1 (if (re-search-forward "Version: +\\([0-9.]+\\)" nil t) (mapconcat #'identity (cl-subseq (split-string (match-string-no-properties 1) "\\.") 0 2) ".") (error "Missing \"Version\" keyword in \"org.el\""))))) 49 | 50 | # The "kbd" macro turns KBD into @kbd{KBD}. Additionally, it 51 | # encloses case-sensitive special keys (SPC, RET...) within @key{...}. 52 | #+macro: kbd (eval (org-texinfo-kbd-macro $1)) 53 | -------------------------------------------------------------------------------- /doc/htmlxref.cnf: -------------------------------------------------------------------------------- 1 | calc mono https://www.gnu.org/software/emacs/manual/html_mono/calc.html 2 | calc node https://www.gnu.org/software/emacs/manual/html_node/calc/ 3 | -------------------------------------------------------------------------------- /doc/pdflayout.sty: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2007-2013 Free Software Foundation, Inc. 2 | 3 | % This file is part of GNU Emacs. 4 | 5 | % GNU Emacs is free software: you can redistribute it and/or modify 6 | % it under the terms of the GNU General Public License as published by 7 | % the Free Software Foundation, either version 3 of the License, or 8 | % (at your option) any later version. 9 | 10 | % GNU Emacs is distributed in the hope that it will be useful, 11 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | % GNU General Public License for more details. 14 | 15 | % You should have received a copy of the GNU General Public License 16 | % along with GNU Emacs. If not, see . 17 | 18 | % This file defines `\pdflayout': 19 | % - \pdflayout=(0) is A4 portrait, 20 | % - \pdflayout=(1) is letter (US) portrait, 21 | % - \pdflayout=(0l) is A4 landscape. 22 | % - \pdflayout=(1l) is letter (US) landscape, 23 | 24 | \input ifpdf.sty 25 | 26 | \ifpdf 27 | \def\pdflayout=(#1#2){ 28 | \if0#1 % A4 29 | \pdfpagewidth=21cm 30 | \pdfpageheight=29.7cm 31 | \else\if1#1 % Letter 32 | \pdfpagewidth=8.5in 33 | \pdfpageheight=11in 34 | \letterpaper=1 35 | \fi\fi 36 | \if l#2 % Landscape 37 | \edef\oldwidth{\the\pdfpagewidth} 38 | \pdfpagewidth=\pdfpageheight 39 | \pdfpageheight=\oldwidth 40 | \fi 41 | } 42 | \else 43 | \def\pdflayout=(#1#2){} 44 | \fi 45 | -------------------------------------------------------------------------------- /etc/Makefile: -------------------------------------------------------------------------------- 1 | ETCDIRS = styles schema csl 2 | -include local.mk # optional local customization 3 | 4 | .NOTPARALLEL: # always run this make serially 5 | .SUFFIXES: # we don't need default suffix rules 6 | ifeq ($(MAKELEVEL), 0) 7 | $(error This make needs to be started as a sub-make from the toplevel directory.) 8 | endif 9 | 10 | .PHONY: all install clean cleanall clean-install 11 | 12 | all: 13 | 14 | install: $(ETCDIRS) 15 | for dir in $? ; do \ 16 | if [ ! -d $(DESTDIR)$(datadir)/$${dir} ] ; then \ 17 | $(MKDIR) $(DESTDIR)$(datadir)/$${dir} ; \ 18 | fi ; \ 19 | $(CP) $${dir}/* $(DESTDIR)$(datadir)/$${dir} ; \ 20 | done ; 21 | 22 | clean: 23 | 24 | cleanall: 25 | 26 | clean-install: $(ETCDIRS) 27 | for dir in $? ; do \ 28 | if [ -d $(DESTDIR)$(datadir)/$${dir} ] ; then \ 29 | $(RMR) $(DESTDIR)$(datadir)/$${dir} ; \ 30 | fi ; \ 31 | done ; 32 | -------------------------------------------------------------------------------- /etc/csl/README: -------------------------------------------------------------------------------- 1 | These data files are used by Org's oc-csl.el library. 2 | 3 | LICENSE INFORMATION 4 | 5 | chicago-author-date.csl 6 | locales-en-US.xml 7 | 8 | Both of these files are part of the Citation Style Language (CSL) 9 | project () and are released under the 10 | Creative Commons Attribution-ShareAlike 3.0 Unported license. 11 | -------------------------------------------------------------------------------- /etc/schema/od-manifest-schema-v1.2-os.rnc: -------------------------------------------------------------------------------- 1 | # Open Document Format for Office Applications (OpenDocument) Version 1.2 2 | # OASIS Standard, 29 September 2011 3 | # Manifest Relax-NG Schema 4 | # Source: http://docs.oasis-open.org/office/v1.2/os/ 5 | # Copyright (c) OASIS Open 2002-2011, 2013. All Rights Reserved. 6 | # 7 | # All capitalized terms in the following text have the meanings assigned to them 8 | # in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The 9 | # full Policy may be found at the OASIS website. 10 | # 11 | # This document and translations of it may be copied and furnished to others, and 12 | # derivative works that comment on or otherwise explain it or assist in its 13 | # implementation may be prepared, copied, published, and distributed, in whole or 14 | # in part, without restriction of any kind, provided that the above copyright 15 | # notice and this section are included on all such copies and derivative works. 16 | # However, this document itself may not be modified in any way, including by 17 | # removing the copyright notice or references to OASIS, except as needed for the 18 | # purpose of developing any document or deliverable produced by an OASIS 19 | # Technical Committee (in which case the rules applicable to copyrights, as set 20 | # forth in the OASIS IPR Policy, must be followed) or as required to translate it 21 | # into languages other than English. 22 | # 23 | # The limited permissions granted above are perpetual and will not be revoked by 24 | # OASIS or its successors or assigns. 25 | # 26 | # This document and the information contained herein is provided on an "AS IS" 27 | # basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT 28 | # LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT 29 | # INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR 30 | # FITNESS FOR A PARTICULAR PURPOSE. 31 | 32 | namespace manifest = 33 | "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" 34 | 35 | start = manifest 36 | manifest = element manifest:manifest { manifest-attlist, file-entry+ } 37 | manifest-attlist = attribute manifest:version { "1.2" } 38 | file-entry = 39 | element manifest:file-entry { file-entry-attlist, encryption-data? } 40 | file-entry-attlist = 41 | attribute manifest:full-path { \string } 42 | & attribute manifest:size { nonNegativeInteger }? 43 | & attribute manifest:media-type { \string } 44 | & attribute manifest:preferred-view-mode { 45 | "edit" | "presentation-slide-show" | "read-only" | namespacedToken 46 | }? 47 | & attribute manifest:version { \string }? 48 | encryption-data = 49 | element manifest:encryption-data { 50 | encryption-data-attlist, 51 | algorithm, 52 | start-key-generation?, 53 | key-derivation 54 | } 55 | encryption-data-attlist = 56 | attribute manifest:checksum-type { "SHA1/1K" | anyURI } 57 | & attribute manifest:checksum { base64Binary } 58 | algorithm = 59 | element manifest:algorithm { algorithm-attlist, anyElements } 60 | algorithm-attlist = 61 | attribute manifest:algorithm-name { "Blowfish CFB" | anyURI } 62 | & attribute manifest:initialisation-vector { base64Binary } 63 | anyAttListOrElements = 64 | attribute * { text }*, 65 | anyElements 66 | anyElements = 67 | element * { 68 | mixed { anyAttListOrElements } 69 | }* 70 | key-derivation = 71 | element manifest:key-derivation { key-derivation-attlist, empty } 72 | key-derivation-attlist = 73 | attribute manifest:key-derivation-name { "PBKDF2" | anyURI } 74 | & attribute manifest:salt { base64Binary } 75 | & attribute manifest:iteration-count { nonNegativeInteger } 76 | & attribute manifest:key-size { nonNegativeInteger }? 77 | start-key-generation = 78 | element manifest:start-key-generation { 79 | start-key-generation-attlist, empty 80 | } 81 | start-key-generation-attlist = 82 | attribute manifest:start-key-generation-name { "SHA1" | anyURI } 83 | & attribute manifest:key-size { nonNegativeInteger }? 84 | base64Binary = xsd:base64Binary 85 | namespacedToken = xsd:QName { pattern = "[^:]+:[^:]+" } 86 | nonNegativeInteger = xsd:nonNegativeInteger 87 | \string = xsd:string 88 | anyURI = xsd:anyURI 89 | -------------------------------------------------------------------------------- /etc/schema/schemas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /etc/styles/README: -------------------------------------------------------------------------------- 1 | The files OrgOdtContentTemplate.xml and OrgOdtStyles.xml have the 2 | following copyright information: 3 | 4 | Copyright (C) 2010-2025 Free Software Foundation, Inc. 5 | 6 | These files are part of GNU Emacs. 7 | 8 | GNU Emacs is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | GNU Emacs is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with GNU Emacs. If not, see . 20 | 21 | 22 | Author: Jambunathan K 23 | Keywords: outlines, hypermedia, calendar, wp 24 | URL: https://orgmode.org 25 | 26 | Commentary: 27 | 28 | These files are part of Org-mode's OpenDocument export module. 29 | 30 | OrgOdtContentTemplate.xml provides a template within which the content 31 | of an exported document is enclosed. This file contributes to 32 | "content.xml" file within an exported document and acts as a 33 | repository of automatic styles. 34 | 35 | OrgOdtStyles.xml contributes to "styles.xml" file within an exported 36 | document and acts as a repository of custom styles. 37 | -------------------------------------------------------------------------------- /lisp/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: # we don't need default suffix rules 2 | ifeq ($(MAKELEVEL), 0) 3 | $(error This make needs to be started as a sub-make from the toplevel directory.) 4 | endif 5 | 6 | LISPV := org-version.el 7 | LISPI := org-loaddefs.el 8 | LISPA := $(LISPV) $(LISPI) 9 | LISPB := $(LISPA:%el=%elc) org-install.elc 10 | LISPF := $(filter-out $(LISPA),$(sort $(wildcard *.el))) 11 | LISPC := $(filter-out $(LISPB) $(LISPN:%el=%elc),$(LISPF:%el=%elc)) 12 | LISPN := $(filter-out $(LISPB) $(LISPN:%el=%eln),$(LISPF:%el=%eln)) 13 | _ORGCM_ := dirall single native source slint1 slint2 14 | -include local.mk 15 | 16 | .PHONY: all compile compile-dirty \ 17 | $(_ORGCM_) $(_ORGCM_:%=compile-%) \ 18 | autoloads \ 19 | install clean cleanauto cleanall cleanelc clean-install 20 | 21 | # do not clean here, done in toplevel make 22 | all compile compile-dirty:: autoloads 23 | ifeq ($(filter-out $(_ORGCM_),$(ORGCM)),) 24 | $(MAKE) compile-$(ORGCM) 25 | else 26 | $(error ORGCM has illegal value $(ORGCM) (valid: $(_ORGCM_))) 27 | endif 28 | 29 | compile-dirall: dirall 30 | compile-single: single $(LISPC) 31 | compile-native: native $(LISPN) 32 | compile-source: source dirall 33 | compile-slint1: dirall slint1 34 | compile-slint2: source dirall slint1 35 | 36 | # internal 37 | dirall: 38 | @$(info ==================== $@ ====================) 39 | @$(ELCDIR) 40 | single: 41 | @$(info ==================== $@ ====================) 42 | native: 43 | @$(info ==================== $@ ====================) 44 | source: cleanelc 45 | @$(info ==================== $@ ====================) 46 | @$(foreach elc,$(LISPC),$(MAKE) $(elc) && $(RM) $(elc);) 47 | slint1: 48 | @$(info ==================== $@ ====================) 49 | @$(foreach elc,$(LISPC),$(RM) $(elc); $(MAKE) $(elc);) 50 | 51 | %.elc: %.el 52 | @$(info Compiling single $(abspath $<)...) 53 | -@$(ELC) $< 54 | 55 | %.eln: %.el 56 | @$(info Native compiling single $(abspath $<)...) 57 | -@$(ELN) $< 58 | 59 | autoloads: cleanauto $(LISPI) $(LISPV) 60 | 61 | $(LISPV): $(LISPF) 62 | @echo "org-version: $(ORGVERSION) ($(GITVERSION))" 63 | @$(RM) $(@) 64 | @$(MAKE_ORG_VERSION) 65 | 66 | $(LISPI): $(LISPV) $(LISPF) 67 | @echo "org-loaddefs: $(ORGVERSION) ($(GITVERSION))" 68 | @$(RM) $(@) 69 | @$(MAKE_ORG_INSTALL) 70 | 71 | install: compile $(LISPF) 72 | if [ ! -d $(DESTDIR)$(lispdir) ] ; then \ 73 | $(MKDIR) $(DESTDIR)$(lispdir) ; \ 74 | fi ; 75 | $(CP) $(LISPC) $(LISPF) $(LISPA) $(DESTDIR)$(lispdir) 76 | 77 | cleanauto clean cleanall:: 78 | $(RM) $(LISPA) $(LISPB) 79 | clean cleanall cleanelc:: 80 | $(RM) *.elc 81 | 82 | clean-install: 83 | if [ -d $(DESTDIR)$(lispdir) ] ; then \ 84 | $(RM) $(DESTDIR)$(lispdir)/org*.el* $(DESTDIR)$(lispdir)/ob*.el* $(DESTDIR)$(lispdir)/ol*.el* $(DESTDIR)$(lispdir)/ox*.el* ; \ 85 | fi ; 86 | -------------------------------------------------------------------------------- /lisp/ob-awk.el: -------------------------------------------------------------------------------- 1 | ;;; ob-awk.el --- Babel Functions for Awk -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2011-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Maintainer: Tyler Smith 7 | ;; Keywords: literate programming, reproducible research 8 | ;; URL: https://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; Babel's awk can use special header argument: 28 | ;; 29 | ;; - :in-file takes a path to a file of data to be processed by awk 30 | ;; 31 | ;; - :stdin takes an Org data or code block reference, the value of 32 | ;; which will be passed to the awk process through STDIN 33 | 34 | ;;; Code: 35 | 36 | (require 'org-macs) 37 | (org-assert-version) 38 | 39 | (require 'ob) 40 | (require 'org-compat) 41 | 42 | (declare-function org-babel-ref-resolve "ob-ref" (ref)) 43 | (declare-function orgtbl-to-generic "org-table" (table params)) 44 | 45 | (defvar org-babel-tangle-lang-exts) 46 | (add-to-list 'org-babel-tangle-lang-exts '("awk" . "awk")) 47 | 48 | (defvar org-babel-awk-command "awk" 49 | "Name of the awk executable command.") 50 | 51 | (defun org-babel-expand-body:awk (body params) 52 | "Expand BODY according to PARAMS, return the expanded body." 53 | (let ((prologue (cdr (assq :prologue params))) 54 | (epilogue (cdr (assq :epilogue params)))) 55 | (concat 56 | (and prologue (concat prologue "\n")) 57 | body 58 | (and epilogue (concat "\n" epilogue "\n"))))) 59 | 60 | (defun org-babel-execute:awk (body params) 61 | "Execute a block of Awk code BODY with org-babel. 62 | PARAMS is a plist of src block parameters . 63 | This function is called by `org-babel-execute-src-block'." 64 | (let* ((result-params (cdr (assq :result-params params))) 65 | (cmd-line (cdr (assq :cmd-line params))) 66 | (in-file (cdr (assq :in-file params))) 67 | (full-body (org-babel-expand-body:awk body params)) 68 | (code-file (let ((file (org-babel-temp-file "awk-"))) 69 | (with-temp-file file (insert full-body)) file)) 70 | (stdin (let ((stdin (cdr (assq :stdin params)))) 71 | (when stdin 72 | (let ((tmp (org-babel-temp-file "awk-stdin-")) 73 | (res (org-babel-ref-resolve stdin))) 74 | (with-temp-file tmp 75 | (insert (org-babel-awk-var-to-awk res))) 76 | tmp)))) 77 | (cmd (mapconcat #'identity 78 | (append 79 | (list org-babel-awk-command 80 | "-f" code-file cmd-line) 81 | (mapcar (lambda (pair) 82 | (format "-v %s='%s'" 83 | (car pair) 84 | (org-babel-awk-var-to-awk 85 | (cdr pair)))) 86 | (org-babel--get-vars params)) 87 | (list in-file)) 88 | " "))) 89 | (org-babel-reassemble-table 90 | (let ((results 91 | (cond 92 | (stdin (with-temp-buffer 93 | (call-process-shell-command cmd stdin (current-buffer)) 94 | (buffer-string))) 95 | (t (org-babel-eval cmd ""))))) 96 | (when results 97 | (org-babel-result-cond result-params 98 | results 99 | (let ((tmp (org-babel-temp-file "awk-results-"))) 100 | (with-temp-file tmp (insert results)) 101 | (org-babel-import-elisp-from-file tmp))))) 102 | (org-babel-pick-name 103 | (cdr (assq :colname-names params)) (cdr (assq :colnames params))) 104 | (org-babel-pick-name 105 | (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))) 106 | 107 | (defun org-babel-awk-var-to-awk (var &optional sep) 108 | "Return a printed value of VAR suitable for parsing with awk. 109 | SEP, when non-nil is a separator used when converting list values to awk 110 | table." 111 | (let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v))))) 112 | (cond 113 | ((and (listp var) (listp (car var))) 114 | (orgtbl-to-generic 115 | var 116 | (list :sep (or sep "\t") 117 | :fmt echo-var 118 | :with-special-rows nil))) 119 | ((listp var) 120 | (mapconcat echo-var var "\n")) 121 | (t (funcall echo-var var))))) 122 | 123 | (provide 'ob-awk) 124 | 125 | ;;; ob-awk.el ends here 126 | -------------------------------------------------------------------------------- /lisp/ob-css.el: -------------------------------------------------------------------------------- 1 | ;;; ob-css.el --- Babel Functions for CSS -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Since CSS can't be executed, this file exists solely for tangling 27 | ;; CSS from Org files. 28 | 29 | ;;; Code: 30 | 31 | (require 'org-macs) 32 | (org-assert-version) 33 | 34 | (require 'ob) 35 | 36 | (defvar org-babel-default-header-args:css '()) 37 | 38 | (defun org-babel-execute:css (body _params) 39 | "Execute BODY of CSS code. 40 | This function is called by `org-babel-execute-src-block'." 41 | body) 42 | 43 | (defun org-babel-prep-session:css (_session _params) 44 | "Return an error if the :session header argument is set. 45 | CSS does not support sessions." 46 | (error "CSS sessions are nonsensical")) 47 | 48 | (provide 'ob-css) 49 | 50 | ;;; ob-css.el ends here 51 | -------------------------------------------------------------------------------- /lisp/ob-ditaa.el: -------------------------------------------------------------------------------- 1 | ;;; ob-ditaa.el --- Babel Functions for ditaa -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating ditaa source code. 27 | ;; 28 | ;; This differs from most standard languages in that 29 | ;; 30 | ;; 1) there is no such thing as a "session" in ditaa 31 | ;; 32 | ;; 2) we are generally only going to return results of type "file" 33 | ;; 34 | ;; 3) we are adding the "file" and "cmdline" header arguments 35 | ;; 36 | ;; 4) there are no variables (at least for now) 37 | 38 | ;;; Code: 39 | 40 | (require 'org-macs) 41 | (org-assert-version) 42 | 43 | (require 'ob) 44 | (require 'org-compat) 45 | 46 | (defvar org-babel-default-header-args:ditaa 47 | '((:results . "file") 48 | (:exports . "results") 49 | (:java . "-Dfile.encoding=UTF-8")) 50 | "Default arguments for evaluating a ditaa source block.") 51 | 52 | (defcustom org-ditaa-jar-path (expand-file-name 53 | "ditaa.jar" 54 | (file-name-as-directory 55 | (expand-file-name 56 | "scripts" 57 | (file-name-as-directory 58 | (expand-file-name 59 | "../contrib" 60 | (file-name-directory (org-find-library-dir "org"))))))) 61 | "Path to the ditaa jar executable." 62 | :group 'org-babel 63 | :type 'string) 64 | 65 | (defcustom org-babel-ditaa-java-cmd "java" 66 | "Java executable to use when evaluating ditaa blocks." 67 | :group 'org-babel 68 | :type 'string) 69 | 70 | (defcustom org-ditaa-eps-jar-path 71 | (expand-file-name "DitaaEps.jar" (file-name-directory org-ditaa-jar-path)) 72 | "Path to the DitaaEps.jar executable." 73 | :group 'org-babel 74 | :version "24.4" 75 | :package-version '(Org . "8.0") 76 | :type 'string) 77 | 78 | (defcustom org-ditaa-jar-option "-jar" 79 | "Option for the ditaa jar file. 80 | Do not leave leading or trailing spaces in this string." 81 | :group 'org-babel 82 | :version "24.1" 83 | :type 'string) 84 | 85 | (defun org-babel-execute:ditaa (body params) 86 | "Execute BODY of Ditaa code with org-babel according to PARAMS. 87 | This function is called by `org-babel-execute-src-block'." 88 | (let* ((out-file (or (cdr (assq :file params)) 89 | (error 90 | "Ditaa code block requires :file header argument"))) 91 | (cmdline (cdr (assq :cmdline params))) 92 | (java (cdr (assq :java params))) 93 | (in-file (org-babel-temp-file "ditaa-")) 94 | (eps (cdr (assq :eps params))) 95 | (eps-file (when eps 96 | (org-babel-process-file-name (concat in-file ".eps")))) 97 | (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf") 98 | (cdr (assq :pdf params)))) 99 | (concat 100 | "epstopdf" 101 | " " eps-file 102 | " -o=" (org-babel-process-file-name out-file)))) 103 | (cmd (concat org-babel-ditaa-java-cmd 104 | " " java " " org-ditaa-jar-option " " 105 | (shell-quote-argument 106 | (expand-file-name 107 | (if eps org-ditaa-eps-jar-path org-ditaa-jar-path))) 108 | " " cmdline 109 | " " (org-babel-process-file-name in-file) 110 | " " (if pdf-cmd 111 | eps-file 112 | (org-babel-process-file-name out-file))))) 113 | (unless (file-exists-p org-ditaa-jar-path) 114 | (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) 115 | (with-temp-file in-file (insert body)) 116 | (shell-command cmd) 117 | (when pdf-cmd (shell-command pdf-cmd)) 118 | nil)) ;; signal that output has already been written to file 119 | 120 | (defun org-babel-prep-session:ditaa (_session _params) 121 | "Return an error because ditaa does not support sessions." 122 | (error "Ditaa does not support sessions")) 123 | 124 | (provide 'ob-ditaa) 125 | 126 | ;;; ob-ditaa.el ends here 127 | -------------------------------------------------------------------------------- /lisp/ob-dot.el: -------------------------------------------------------------------------------- 1 | ;;; ob-dot.el --- Babel Functions for dot -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Maintainer: Justin Abrahms 7 | ;; Keywords: literate programming, reproducible research 8 | ;; URL: https://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; Org-Babel support for evaluating dot source code. 28 | ;; 29 | ;; For information on dot see https://www.graphviz.org/ 30 | ;; 31 | ;; This differs from most standard languages in that 32 | ;; 33 | ;; 1) there is no such thing as a "session" in dot 34 | ;; 35 | ;; 2) we are generally only going to return results of type "file" 36 | ;; 37 | ;; 3) we are adding the "file" and "cmdline" header arguments 38 | ;; 39 | ;; 4) there are no variables (at least for now) 40 | 41 | ;;; Code: 42 | 43 | (require 'org-macs) 44 | (org-assert-version) 45 | 46 | (require 'ob) 47 | 48 | (defvar org-babel-default-header-args:dot 49 | '((:results . "file") (:exports . "results")) 50 | "Default arguments to use when evaluating a dot source block.") 51 | 52 | (defun org-babel-expand-body:dot (body params) 53 | "Expand BODY according to PARAMS, return the expanded body." 54 | (let ((vars (org-babel--get-vars params)) 55 | (prologue (cdr (assq :prologue params))) 56 | (epilogue (cdr (assq :epilogue params)))) 57 | (mapc 58 | (lambda (pair) 59 | (let ((name (symbol-name (car pair))) 60 | (value (cdr pair))) 61 | (setq body 62 | (replace-regexp-in-string 63 | (concat "$" (regexp-quote name)) 64 | (if (stringp value) value (format "%S" value)) 65 | body 66 | t 67 | t)))) 68 | vars) 69 | (concat 70 | (and prologue (concat prologue "\n")) 71 | body 72 | (and epilogue (concat "\n" epilogue "\n"))))) 73 | 74 | (defun org-babel-execute:dot (body params) 75 | "Execute Dot BODY with org-babel according to PARAMS. 76 | This function is called by `org-babel-execute-src-block'." 77 | (let* ((out-file (cdr (or (assq :file params) 78 | (error "You need to specify a :file parameter")))) 79 | (cmdline (or (cdr (assq :cmdline params)) 80 | (format "-T%s" (file-name-extension out-file)))) 81 | (cmd (or (cdr (assq :cmd params)) "dot")) 82 | (coding-system-for-read 'utf-8) ;use utf-8 with sub-processes 83 | (coding-system-for-write 'utf-8) 84 | (in-file (org-babel-temp-file "dot-"))) 85 | (with-temp-file in-file 86 | (insert (org-babel-expand-body:dot body params))) 87 | (org-babel-eval 88 | (concat cmd 89 | " " (org-babel-process-file-name in-file) 90 | " " cmdline 91 | " -o " (org-babel-process-file-name out-file)) "") 92 | nil)) ;; signal that output has already been written to file 93 | 94 | (defun org-babel-prep-session:dot (_session _params) 95 | "Return an error because Dot does not support sessions." 96 | (error "Dot does not support sessions")) 97 | 98 | (provide 'ob-dot) 99 | 100 | ;;; ob-dot.el ends here 101 | -------------------------------------------------------------------------------- /lisp/ob-emacs-lisp.el: -------------------------------------------------------------------------------- 1 | ;;; ob-emacs-lisp.el --- Babel Functions for Emacs-lisp Code -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating emacs-lisp code 27 | 28 | ;;; Code: 29 | 30 | (require 'org-macs) 31 | (org-assert-version) 32 | 33 | (require 'ob-core) 34 | 35 | (declare-function org-babel--get-vars "ob" (params)) 36 | (declare-function org-babel-result-cond "ob" (result-params scalar-form &rest table-forms)) 37 | (declare-function org-babel-reassemble-table "ob" (table colnames rownames)) 38 | (declare-function org-babel-pick-name "ob" (names selector)) 39 | 40 | (defconst org-babel-header-args:emacs-lisp '((lexical . :any)) 41 | "Emacs-lisp specific header arguments.") 42 | 43 | (defvar org-babel-default-header-args:emacs-lisp '((:lexical . "no")) 44 | "Default arguments for evaluating an emacs-lisp source block. 45 | 46 | A value of \"yes\" or t causes source blocks to be eval'd using 47 | lexical scoping. It can also be an alist mapping symbols to 48 | their value. It is used both as the optional LEXICAL argument to 49 | `eval', and as the value for `lexical-binding' in buffers created 50 | by `org-edit-src-code'.") 51 | 52 | (defun org-babel-expand-body:emacs-lisp (body params) 53 | "Expand BODY according to PARAMS, return the expanded body." 54 | (let ((vars (org-babel--get-vars params)) 55 | (print-level nil) 56 | (print-length nil) 57 | (prologue (cdr (assq :prologue params))) 58 | (epilogue (cdr (assq :epilogue params)))) 59 | (if (null vars) (concat body "\n") 60 | (format "(let (%s)\n%s%s%s\n)" 61 | (mapconcat 62 | (lambda (var) 63 | (format "%S" `(,(car var) ',(cdr var)))) 64 | vars "\n ") 65 | (if prologue (concat prologue "\n ") "") 66 | body 67 | (if epilogue (concat "\n " epilogue "\n") ""))))) 68 | 69 | (defun org-babel-execute:emacs-lisp (body params) 70 | "Execute emacs-lisp code BODY according to PARAMS." 71 | (let* ((lexical (cdr (assq :lexical params))) 72 | (session (cdr (assq :session params))) 73 | (result-params (cdr (assq :result-params params))) 74 | (body (format (if (member "output" result-params) 75 | "(with-output-to-string %s\n)" 76 | "(progn %s\n)") 77 | (org-babel-expand-body:emacs-lisp body params))) 78 | (result (eval (read (if (or (member "code" result-params) 79 | (member "pp" result-params)) 80 | (concat "(pp-to-string " body ")") 81 | body)) 82 | (org-babel-emacs-lisp-lexical lexical)))) 83 | (when (and session (not (equal session "none"))) 84 | (error "ob-emacs-lisp backend does not support sessions")) 85 | (org-babel-result-cond result-params 86 | (let ((print-level nil) 87 | (print-length nil)) 88 | (if (or (member "scalar" result-params) 89 | (member "verbatim" result-params)) 90 | (format "%S" result) 91 | (format "%s" result))) 92 | (org-babel-reassemble-table 93 | result 94 | (org-babel-pick-name (cdr (assq :colname-names params)) 95 | (cdr (assq :colnames params))) 96 | (org-babel-pick-name (cdr (assq :rowname-names params)) 97 | (cdr (assq :rownames params))))))) 98 | 99 | (defun org-babel-emacs-lisp-lexical (lexical) 100 | "Interpret :lexical source block argument. 101 | Convert LEXICAL into the form appropriate for `lexical-binding' 102 | and the LEXICAL argument to `eval'." 103 | (if (listp lexical) 104 | lexical 105 | (not (null (member lexical '("yes" "t")))))) 106 | 107 | (defun org-babel-edit-prep:emacs-lisp (info) 108 | "Set `lexical-binding' in Org edit buffer. 109 | Set `lexical-binding' in Org edit buffer according to the 110 | corresponding :lexical source block argument provide in the INFO 111 | channel, as returned by `org-babel-get-src-block-info'." 112 | (setq lexical-binding 113 | (org-babel-emacs-lisp-lexical 114 | (org-babel-read 115 | (cdr (assq :lexical (nth 2 info))))))) 116 | 117 | (defun org-babel-prep-session:emacs-lisp (_session _params) 118 | "Return an error because we do not support sessions." 119 | (error "ob-emacs-lisp backend does not support sessions")) 120 | 121 | (org-babel-make-language-alias "elisp" "emacs-lisp") 122 | 123 | (provide 'ob-emacs-lisp) 124 | 125 | ;;; ob-emacs-lisp.el ends here 126 | -------------------------------------------------------------------------------- /lisp/ob-eshell.el: -------------------------------------------------------------------------------- 1 | ;;; ob-eshell.el --- Babel Functions for Eshell -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2018-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: stardiviner 6 | ;; Maintainer: stardiviner 7 | ;; URL: https://github.com/stardiviner/ob-eshell 8 | ;; Keywords: literate programming, reproducible research 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; Org Babel support for evaluating Eshell source code. 28 | 29 | ;;; Code: 30 | 31 | (require 'org-macs) 32 | (org-assert-version) 33 | 34 | (require 'ob) 35 | (require 'eshell) 36 | 37 | (declare-function eshell-send-input "esh-mode" 38 | (&optional use-region queue-p no-newline)) 39 | 40 | (defvar eshell-last-output-start) 41 | (defvar eshell-last-output-end) 42 | (defvar eshell-last-input-end) 43 | 44 | (defvar org-babel-default-header-args:eshell '()) 45 | 46 | (defun org-babel-execute:eshell (body params) 47 | "Execute a block of Eshell code BODY with PARAMS. 48 | This function is called by `org-babel-execute-src-block'. 49 | 50 | The BODY argument is code which can be executed in Eshell. 51 | Eshell allows executing normal shell command and Elisp code. 52 | For more details, see Info node `(eshell) Top'. 53 | 54 | The PARAMS argument is passed to 55 | `org-babel-expand-body:generic' (which see)." 56 | (let* ((session (org-babel-eshell-initiate-session 57 | (cdr (assq :session params)))) 58 | (full-body (org-babel-expand-body:generic 59 | body params (org-babel-variable-assignments:eshell params)))) 60 | (if session 61 | (progn 62 | (with-current-buffer session 63 | (dolist (line (split-string full-body "\n")) 64 | (goto-char eshell-last-output-end) 65 | (insert line) 66 | (eshell-send-input)) 67 | ;; get output of last input 68 | ;; TODO: collect all output instead of last command's output. 69 | (goto-char eshell-last-input-end) 70 | (buffer-substring-no-properties (point) eshell-last-output-start))) 71 | (with-temp-buffer 72 | (eshell-command full-body t) 73 | (buffer-string))))) 74 | 75 | (defun org-babel-prep-session:eshell (session params) 76 | "Prepare SESSION according to the header arguments specified in PARAMS." 77 | (let* ((session (org-babel-eshell-initiate-session session)) 78 | ;; Eshell session buffer is read from variable `eshell-buffer-name'. 79 | (eshell-buffer-name session) 80 | (var-lines (org-babel-variable-assignments:eshell params))) 81 | (call-interactively #'eshell) 82 | (mapc #'eshell-command var-lines) 83 | session)) 84 | 85 | (defun ob-eshell-session-live-p (session) 86 | "Non-nil if Eshell SESSION exists." 87 | (get-buffer session)) 88 | 89 | (defun org-babel-eshell-initiate-session (&optional session _params) 90 | "Initiate a session named SESSION." 91 | (when (and session (not (string= session "none"))) 92 | (save-window-excursion 93 | (unless (ob-eshell-session-live-p session) 94 | (let ((eshell-buffer-name session)) (eshell)))) 95 | session)) 96 | 97 | (defun org-babel-variable-assignments:eshell (params) 98 | "Convert ob-eshell variables from PARAMS into Eshell variables assignments." 99 | (mapcar 100 | (lambda (pair) 101 | ;; Use `ignore' to suppress value in the command output. 102 | (format "(ignore (setq %s %S))" (car pair) (cdr pair))) 103 | (org-babel--get-vars params))) 104 | 105 | (defun org-babel-load-session:eshell (session body params) 106 | "Load BODY into SESSION with PARAMS." 107 | (save-window-excursion 108 | (let ((buffer (org-babel-prep-session:eshell session params))) 109 | (with-current-buffer buffer 110 | (goto-char (point-max)) 111 | (insert (org-babel-chomp body))) 112 | buffer))) 113 | 114 | (provide 'ob-eshell) 115 | 116 | ;;; ob-eshell.el ends here 117 | -------------------------------------------------------------------------------- /lisp/ob-forth.el: -------------------------------------------------------------------------------- 1 | ;;; ob-forth.el --- Babel Functions for Forth -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2014-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research, forth 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Requires the gforth forth compiler and `forth-mode' (see below). 27 | ;; https://www.gnu.org/software/gforth/ 28 | 29 | ;;; Requirements: 30 | 31 | ;; Session evaluation requires the gforth forth compiler as well as 32 | ;; `forth-mode' which is distributed with gforth (in gforth.el). 33 | 34 | ;;; Code: 35 | 36 | (require 'org-macs) 37 | (org-assert-version) 38 | 39 | (require 'ob) 40 | (require 'org-macs) 41 | 42 | (declare-function forth-proc "ext:gforth" ()) 43 | 44 | (defvar org-babel-default-header-args:forth '((:session . "yes")) 45 | "Default header arguments for forth code blocks.") 46 | 47 | (defun org-babel-execute:forth (body params) 48 | "Execute Forth BODY according to PARAMS. 49 | This function is called by `org-babel-execute-src-block'." 50 | (if (string= "none" (cdr (assq :session params))) 51 | (error "Non-session evaluation not supported for Forth code blocks") 52 | (let ((all-results (org-babel-forth-session-execute body params))) 53 | (if (member "output" (cdr (assq :result-params params))) 54 | (mapconcat #'identity all-results "\n") 55 | (car (last all-results)))))) 56 | 57 | (defun org-babel-forth-session-execute (body params) 58 | "Execute Forth BODY in session defined via PARAMS." 59 | (org-require-package 'forth-mode) 60 | (let ((proc (forth-proc)) 61 | (rx " \\(\n:\\|compiled\n\\|ok\n\\)") 62 | (result-start)) 63 | (with-current-buffer (process-buffer (forth-proc)) 64 | (mapcar (lambda (line) 65 | (setq result-start (progn (goto-char (process-mark proc)) 66 | (point))) 67 | (comint-send-string proc (concat line "\n")) 68 | ;; wait for forth to say "ok" 69 | (while (not (progn (goto-char result-start) 70 | (re-search-forward rx nil t))) 71 | (accept-process-output proc 0.01)) 72 | (let ((case (match-string 1))) 73 | (cond 74 | ((string= "ok\n" case) 75 | ;; Collect intermediate output. 76 | (buffer-substring (+ result-start 1 (length line)) 77 | (match-beginning 0))) 78 | ((string= "compiled\n" case)) 79 | ;; Ignore partial compilation. 80 | ((string= "\n:" case) 81 | ;; Report errors. 82 | (org-babel-eval-error-notify 1 83 | (buffer-substring 84 | (+ (match-beginning 0) 1) (point-max))) 85 | nil)))) 86 | (split-string (org-trim 87 | (org-babel-expand-body:generic body params)) 88 | "\n" 89 | 'omit-nulls))))) 90 | 91 | (provide 'ob-forth) 92 | 93 | ;;; ob-forth.el ends here 94 | -------------------------------------------------------------------------------- /lisp/ob-groovy.el: -------------------------------------------------------------------------------- 1 | ;;; ob-groovy.el --- Babel Functions for Groovy -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2013-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Miro Bezjak 6 | ;; Maintainer: Palak Mathur 7 | ;; Keywords: literate programming, reproducible research 8 | ;; URL: https://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | ;; Currently only supports the external execution. No session support yet. 27 | 28 | ;;; Requirements: 29 | ;; - Groovy language :: https://groovy-lang.org 30 | ;; - Groovy major mode :: Can be installed from MELPA or 31 | ;; https://github.com/russel/Emacs-Groovy-Mode 32 | 33 | ;;; Code: 34 | 35 | (require 'org-macs) 36 | (org-assert-version) 37 | 38 | (require 'ob) 39 | 40 | (defvar org-babel-tangle-lang-exts) ;; Autoloaded 41 | (add-to-list 'org-babel-tangle-lang-exts '("groovy" . "groovy")) 42 | (defvar org-babel-default-header-args:groovy '()) 43 | (defcustom org-babel-groovy-command "groovy" 44 | "Name of the command to use for executing Groovy code. 45 | May be either a command in the path, like groovy 46 | or an absolute path name, like /usr/local/bin/groovy 47 | parameters may be used, like groovy -v" 48 | :group 'org-babel 49 | :version "24.3" 50 | :type 'string) 51 | 52 | (defun org-babel-execute:groovy (body params) 53 | "Execute Groovy BODY according to PARAMS. 54 | This function is called by `org-babel-execute-src-block'." 55 | (let* ((processed-params (org-babel-process-params params)) 56 | (session (org-babel-groovy-initiate-session (nth 0 processed-params))) 57 | (result-params (nth 2 processed-params)) 58 | (result-type (cdr (assq :result-type params))) 59 | (full-body (org-babel-expand-body:generic 60 | body params)) 61 | (result (org-babel-groovy-evaluate 62 | session full-body result-type result-params))) 63 | 64 | (org-babel-reassemble-table 65 | result 66 | (org-babel-pick-name 67 | (cdr (assq :colname-names params)) (cdr (assq :colnames params))) 68 | (org-babel-pick-name 69 | (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))) 70 | 71 | (defvar org-babel-groovy-wrapper-method 72 | "class Runner extends Script { 73 | def out = new PrintWriter(new ByteArrayOutputStream()) 74 | def run() { %s } 75 | } 76 | 77 | println(new Runner().run()) 78 | ") 79 | 80 | (defun org-babel-groovy-evaluate 81 | (session body &optional result-type result-params) 82 | "Evaluate BODY in external Groovy process. 83 | SESSION must be nil as sessions are not yet supported. 84 | If RESULT-TYPE equals `output' then return standard output as a string. 85 | If RESULT-TYPE equals `value' then return the value of the last statement 86 | in BODY as elisp." 87 | (when session (error "Sessions are not (yet) supported for Groovy")) 88 | (pcase result-type 89 | (`output 90 | (let ((src-file (org-babel-temp-file "groovy_"))) 91 | (progn (with-temp-file src-file (insert body)) 92 | (org-babel-eval 93 | (concat org-babel-groovy-command " " src-file) "")))) 94 | (`value 95 | (let* ((src-file (org-babel-temp-file "groovy_")) 96 | (wrapper (format org-babel-groovy-wrapper-method body))) 97 | (with-temp-file src-file (insert wrapper)) 98 | (let ((raw (org-babel-eval 99 | (concat org-babel-groovy-command " " src-file) ""))) 100 | (org-babel-result-cond result-params 101 | raw 102 | (org-babel-script-escape raw))))))) 103 | 104 | 105 | (defun org-babel-prep-session:groovy (_session _params) 106 | "Prepare SESSION according to the header arguments specified in PARAMS." 107 | (error "Sessions are not (yet) supported for Groovy")) 108 | 109 | (defun org-babel-groovy-initiate-session (&optional _session) 110 | "Do nothing. 111 | Sessions are not supported in Groovy." 112 | nil) 113 | 114 | (provide 'ob-groovy) 115 | 116 | ;;; ob-groovy.el ends here 117 | -------------------------------------------------------------------------------- /lisp/ob-makefile.el: -------------------------------------------------------------------------------- 1 | ;;; ob-makefile.el --- Babel Functions for Makefile -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Thomas S. Dye 7 | ;; Keywords: literate programming, reproducible research 8 | ;; URL: https://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; This file exists solely for tangling a Makefile from Org files. 28 | 29 | ;;; Code: 30 | 31 | (require 'org-macs) 32 | (org-assert-version) 33 | 34 | (require 'ob) 35 | 36 | (defvar org-babel-default-header-args:makefile '()) 37 | 38 | (defun org-babel-execute:makefile (body _params) 39 | "Execute makefile BODY. 40 | Second function argument is ignored. 41 | This function is called by `org-babel-execute-src-block'." 42 | body) 43 | 44 | (defun org-babel-prep-session:makefile (_session _params) 45 | "Signal error; Make does not support sessions." 46 | (error "Makefile sessions are nonsensical")) 47 | 48 | (provide 'ob-makefile) 49 | 50 | ;;; ob-makefile.el ends here 51 | -------------------------------------------------------------------------------- /lisp/ob-matlab.el: -------------------------------------------------------------------------------- 1 | ;;; ob-matlab.el --- Babel support for Matlab -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2010-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Dan Davison 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Functions that are common to org-babel support for matlab and 27 | ;; octave are in org-babel-octave.el 28 | 29 | ;;; Requirements: 30 | 31 | ;; Matlab 32 | 33 | ;; matlab.el required for interactive emacs sessions and matlab-mode 34 | ;; major mode for source code editing buffer 35 | ;; https://matlab-emacs.sourceforge.net/ 36 | 37 | ;;; Code: 38 | 39 | (require 'org-macs) 40 | (org-assert-version) 41 | 42 | (require 'ob) 43 | (require 'ob-octave) 44 | 45 | ;; see ob-octave for matlab implementation 46 | 47 | (provide 'ob-matlab) 48 | 49 | ;;; ob-matlab.el ends here 50 | -------------------------------------------------------------------------------- /lisp/ob-org.el: -------------------------------------------------------------------------------- 1 | ;;; ob-org.el --- Babel Functions for Org Code Blocks -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2010-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; This is the simplest of code blocks, where upon evaluation the 27 | ;; contents of the code block are returned in a raw result. 28 | 29 | ;;; Code: 30 | 31 | (require 'org-macs) 32 | (org-assert-version) 33 | 34 | (require 'ob) 35 | 36 | (declare-function org-export-string-as "ox" 37 | (string backend &optional body-only ext-plist)) 38 | 39 | (defvar org-babel-default-header-args:org 40 | '((:results . "raw silent") (:exports . "code")) 41 | "Default arguments for evaluating an org source block.") 42 | 43 | (defvar org-babel-org-default-header 44 | "#+TITLE: default empty header\n" 45 | "Default header inserted during export of org blocks.") 46 | 47 | (defun org-babel-expand-body:org (body params) 48 | "Expand Org BODY according to PARAMS. 49 | $VAR instances are replaced by VAR values defined in PARAMS." 50 | (dolist (var (org-babel--get-vars params)) 51 | (setq body (replace-regexp-in-string 52 | (regexp-quote (format "$%s" (car var))) 53 | (format "%s" (cdr var)) 54 | body 'fixedcase 'literal))) 55 | 56 | (let ((prologue (cdr (assq :prologue params))) 57 | (epilogue (cdr (assq :epilogue params)))) 58 | (concat 59 | (and prologue (concat prologue "\n")) 60 | body 61 | (and epilogue (concat "\n" epilogue "\n"))))) 62 | 63 | (defun org-babel-execute:org (body params) 64 | "Execute a Org BODY according to PARAMS. 65 | The BODY is returned expanded as is or exported, if PARAMS define 66 | latex/html/ascii result type. 67 | This function is called by `org-babel-execute-src-block'." 68 | (let ((result-params (split-string (or (cdr (assq :results params)) ""))) 69 | (body (org-babel-expand-body:org 70 | (replace-regexp-in-string "^," "" body) params))) 71 | (cond 72 | ((member "latex" result-params) 73 | (org-export-string-as (concat "#+Title: \n" body) 'latex t)) 74 | ((member "html" result-params) (org-export-string-as body 'html t)) 75 | ((member "ascii" result-params) (org-export-string-as body 'ascii t)) 76 | (t body)))) 77 | 78 | (defun org-babel-prep-session:org (_session _params) 79 | "Return an error because org does not support sessions." 80 | (error "Org does not support sessions")) 81 | 82 | (provide 'ob-org) 83 | 84 | ;;; ob-org.el ends here 85 | -------------------------------------------------------------------------------- /lisp/ob-sass.el: -------------------------------------------------------------------------------- 1 | ;;; ob-sass.el --- Babel Functions for the Sass CSS generation language -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; For more information on sass see https://sass-lang.com/ 27 | ;; 28 | ;; This accepts a 'file' header argument which is the target of the 29 | ;; compiled sass. The default output type for sass evaluation is 30 | ;; either file (if a 'file' header argument was given) or scalar if no 31 | ;; such header argument was supplied. 32 | ;; 33 | ;; A 'cmdline' header argument can be supplied to pass arguments to 34 | ;; the sass command line. 35 | 36 | ;;; Requirements: 37 | 38 | ;; - sass-mode :: https://github.com/nex3/haml/blob/master/extra/sass-mode.el 39 | 40 | ;;; Code: 41 | 42 | (require 'org-macs) 43 | (org-assert-version) 44 | 45 | (require 'ob) 46 | 47 | (defvar org-babel-default-header-args:sass '()) 48 | 49 | (defun org-babel-execute:sass (body params) 50 | "Execute a block of Sass code with Babel. 51 | This function is called by `org-babel-execute-src-block'." 52 | (let* ((file (cdr (assq :file params))) 53 | (out-file (or file (org-babel-temp-file "sass-out-"))) 54 | (cmdline (cdr (assq :cmdline params))) 55 | (in-file (org-babel-temp-file "sass-in-")) 56 | (cmd (concat "sass " (or cmdline "") 57 | " " (org-babel-process-file-name in-file) 58 | " " (org-babel-process-file-name out-file)))) 59 | (with-temp-file in-file 60 | (insert (org-babel-expand-body:generic body params))) 61 | (org-babel-eval cmd "") 62 | (if file 63 | nil ;; signal that output has already been written to file 64 | (with-temp-buffer (insert-file-contents out-file) (buffer-string))))) 65 | 66 | (defun org-babel-prep-session:sass (_session _params) 67 | "Raise an error because sass does not support sessions." 68 | (error "Sass does not support sessions")) 69 | 70 | (provide 'ob-sass) 71 | 72 | ;;; ob-sass.el ends here 73 | -------------------------------------------------------------------------------- /lisp/ob-sed.el: -------------------------------------------------------------------------------- 1 | ;;; ob-sed.el --- Babel Functions for Sed Scripts -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2015-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Bjarte Johansen 6 | ;; Keywords: literate programming, reproducible research 7 | 8 | ;; This file is part of GNU Emacs. 9 | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation, either version 3 of the License, or 13 | ;; (at your option) any later version. 14 | 15 | ;; GNU Emacs is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with GNU Emacs. If not, see . 22 | 23 | ;;; Commentary: 24 | 25 | ;; Provides a way to evaluate sed scripts in Org mode. 26 | 27 | ;;; Usage: 28 | 29 | ;; Add to your Emacs config: 30 | 31 | ;; (org-babel-do-load-languages 32 | ;; 'org-babel-load-languages 33 | ;; '((sed . t))) 34 | 35 | ;; In addition to the normal header arguments, ob-sed also provides 36 | ;; :cmd-line and :in-file. :cmd-line allows one to pass other flags to 37 | ;; the sed command like the "--in-place" flag which makes sed edit the 38 | ;; file passed to it instead of outputting to standard out or to a 39 | ;; different file. :in-file is a header arguments that allows one to 40 | ;; tell Org Babel which file the sed script to act on. 41 | 42 | ;;; Code: 43 | 44 | (require 'org-macs) 45 | (org-assert-version) 46 | 47 | (require 'ob) 48 | 49 | (defvar org-babel-sed-command "sed" 50 | "Name of the sed executable command.") 51 | 52 | (defvar org-babel-tangle-lang-exts) 53 | (add-to-list 'org-babel-tangle-lang-exts '("sed" . "sed")) 54 | 55 | (defconst org-babel-header-args:sed 56 | '((:cmd-line . :any) 57 | (:in-file . :any)) 58 | "Sed specific header arguments.") 59 | 60 | (defvar org-babel-default-header-args:sed '() 61 | "Default arguments for evaluating a sed source block.") 62 | 63 | (defun org-babel-execute:sed (body params) 64 | "Execute a block of sed code with Org Babel. 65 | BODY is the source inside a sed source block and PARAMS is an 66 | association list over the source block configurations. This 67 | function is called by `org-babel-execute-src-block'." 68 | (let* ((result-params (cdr (assq :result-params params))) 69 | (cmd-line (cdr (assq :cmd-line params))) 70 | (in-file (cdr (assq :in-file params))) 71 | (code-file (let ((file (org-babel-temp-file "sed-"))) 72 | (with-temp-file file 73 | (insert body)) 74 | file)) 75 | (stdin (let ((stdin (cdr (assq :stdin params)))) 76 | (when stdin 77 | (let ((tmp (org-babel-temp-file "sed-stdin-")) 78 | (res (org-babel-ref-resolve stdin))) 79 | (with-temp-file tmp 80 | (insert res)) 81 | tmp)))) 82 | (cmd (mapconcat #'identity 83 | (remq nil 84 | (list org-babel-sed-command 85 | (format "-f \"%s\"" code-file) 86 | cmd-line 87 | in-file)) 88 | " "))) 89 | (org-babel-reassemble-table 90 | (let ((results 91 | (cond 92 | (stdin (with-temp-buffer 93 | (call-process-shell-command cmd stdin (current-buffer)) 94 | (buffer-string))) 95 | (t (org-babel-eval cmd ""))))) 96 | (when results 97 | (org-babel-result-cond result-params 98 | results 99 | (let ((tmp (org-babel-temp-file "sed-results-"))) 100 | (with-temp-file tmp (insert results)) 101 | (org-babel-import-elisp-from-file tmp))))) 102 | (org-babel-pick-name 103 | (cdr (assq :colname-names params)) (cdr (assq :colnames params))) 104 | (org-babel-pick-name 105 | (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))) 106 | 107 | (provide 'ob-sed) 108 | 109 | ;;; ob-sed.el ends here 110 | -------------------------------------------------------------------------------- /lisp/ob.el: -------------------------------------------------------------------------------- 1 | ;;; ob.el --- Working with Code Blocks in Org -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Authors: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; URL: https://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;;; Code: 27 | 28 | (require 'org-macs) 29 | (org-assert-version) 30 | 31 | (require 'org-macs) 32 | (require 'org-compat) 33 | (require 'org-keys) 34 | (require 'ob-eval) 35 | (require 'ob-core) 36 | (require 'ob-comint) 37 | (require 'ob-exp) 38 | (require 'ob-table) 39 | (require 'ob-lob) 40 | (require 'ob-ref) 41 | (require 'ob-tangle) 42 | 43 | (provide 'ob) 44 | 45 | ;; Local variables: 46 | ;; generated-autoload-file: "org-loaddefs.el" 47 | ;; End: 48 | 49 | ;;; ob.el ends here 50 | -------------------------------------------------------------------------------- /lisp/oc-bibtex.el: -------------------------------------------------------------------------------- 1 | ;;; oc-bibtex.el --- Vanilla citation processor for LaTeX -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2021-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Nicolas Goaziou 6 | 7 | ;; This file is part of GNU Emacs. 8 | 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; GNU Emacs is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with GNU Emacs. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;; This library registers the `bibtex' citation processor, which 25 | ;; provides the "export" capability for citations. It doesn't require 26 | ;; any LaTeX package. 27 | ;; 28 | ;; It supports the following citation styles: 29 | ;; 30 | ;; - nocite (n), 31 | ;; - default. 32 | ;; 33 | ;; Only suffixes are supported. Prefixes are ignored. 34 | ;; 35 | ;; Bibliography should consist of ".bib" files only. 36 | 37 | ;;; Code: 38 | 39 | (require 'org-macs) 40 | (org-assert-version) 41 | 42 | (require 'oc) 43 | 44 | (declare-function org-element-property "org-element-ast" (property node)) 45 | 46 | (declare-function org-export-data "org-export" (data info)) 47 | 48 | 49 | ;;; Export capability 50 | (defun org-cite-bibtex-export-bibliography (_keys files style &rest _) 51 | "Print references from bibliography FILES. 52 | FILES is a list of absolute file names. STYLE is the bibliography style, as 53 | a string or nil." 54 | (concat (and style (format "\\bibliographystyle{%s}\n" style)) 55 | (format "\\bibliography{%s}" 56 | (mapconcat #'file-name-sans-extension 57 | files 58 | ",")))) 59 | 60 | (defun org-cite-bibtex-export-citation (citation style _ info) 61 | "Export CITATION object. 62 | STYLE is the citation style, as a pair of strings or nil. INFO is the export 63 | state, as a property list." 64 | (let ((references (org-cite-get-references citation))) 65 | (format "\\%s%s{%s}" 66 | (pcase style 67 | (`(,(or "nocite" "n") . ,_) "nocite") 68 | (_ "cite")) 69 | (let ((suffix (cdr (org-cite-main-affixes citation)))) 70 | (if suffix 71 | (format "[%s]" (org-trim (org-export-data suffix info))) 72 | "")) 73 | (mapconcat (lambda (r) (org-element-property :key r)) 74 | references 75 | ",")))) 76 | 77 | 78 | ;;; Register `bibtex' processor 79 | (org-cite-register-processor 'bibtex 80 | :export-bibliography #'org-cite-bibtex-export-bibliography 81 | :export-citation #'org-cite-bibtex-export-citation 82 | :cite-styles 83 | '((("nocite" "n")) 84 | (("nil")))) 85 | 86 | (provide 'oc-bibtex) 87 | ;;; oc-bibtex.el ends here 88 | -------------------------------------------------------------------------------- /lisp/ol-docview.el: -------------------------------------------------------------------------------- 1 | ;;; ol-docview.el --- Links to Docview mode buffers -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2009-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Jan Böcker 6 | ;; Keywords: outlines, hypermedia, calendar, text 7 | ;; URL: https://orgmode.org 8 | ;; 9 | ;; This file is part of GNU Emacs. 10 | ;; 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ;; 25 | ;;; Commentary: 26 | 27 | ;; This file implements links to open files in doc-view-mode. 28 | ;; Org mode loads this module by default - if this is not what you want, 29 | ;; configure the variable `org-modules'. 30 | 31 | ;; The links take the form 32 | ;; 33 | ;; docview::: 34 | ;; 35 | ;; for example: [[docview:~/.elisp/org/doc/org.pdf::1][Org-Mode Manual]] 36 | ;; 37 | ;; Autocompletion for inserting links is supported; you will be 38 | ;; prompted for a file and a page number. 39 | ;; 40 | ;; If you use org-store-link in a doc-view mode buffer, the stored 41 | ;; link will point to the current page. 42 | 43 | ;;; Code: 44 | 45 | (require 'org-macs) 46 | (org-assert-version) 47 | 48 | (require 'doc-view) 49 | (require 'ol) 50 | 51 | (declare-function doc-view-goto-page "doc-view" (page)) 52 | (declare-function image-mode-window-get "image-mode" (prop &optional winprops)) 53 | (declare-function org-open-file "org" (path &optional in-emacs line search)) 54 | 55 | (org-link-set-parameters "docview" 56 | :follow #'org-docview-open 57 | :export #'org-docview-export 58 | :store #'org-docview-store-link) 59 | 60 | (defun org-docview-export (link description backend _info) 61 | "Export a docview LINK with DESCRIPTION for BACKEND." 62 | (let ((path (if (string-match "\\(.+\\)::.+" link) (match-string 1 link) 63 | link)) 64 | (desc (or description link))) 65 | (when (stringp path) 66 | (setq path (expand-file-name path)) 67 | (cond 68 | ((eq backend 'html) (format "%s" path desc)) 69 | ((eq backend 'latex) (format "\\href{%s}{%s}" path desc)) 70 | ((eq backend 'ascii) (format "[%s] (<%s>)" desc path)) 71 | (t path))))) 72 | 73 | (defun org-docview-open (link _) 74 | "Open docview: LINK." 75 | (string-match "\\(.*?\\)\\(?:::\\([0-9]+\\)\\)?$" link) 76 | (let ((path (match-string 1 link)) 77 | (page (and (match-beginning 2) 78 | (string-to-number (match-string 2 link))))) 79 | ;; Let Org mode open the file (in-emacs = 1) to ensure 80 | ;; org-link-frame-setup is respected. 81 | (if (file-exists-p path) 82 | (org-open-file path 1) 83 | (error "No such file: %s" path)) 84 | (when page (doc-view-goto-page page)))) 85 | 86 | (defun org-docview-store-link (&optional _interactive?) 87 | "Store a link to a docview buffer." 88 | (when (eq major-mode 'doc-view-mode) 89 | ;; This buffer is in doc-view-mode 90 | (let* ((path buffer-file-name) 91 | (page (image-mode-window-get 'page)) 92 | (link (concat "docview:" path "::" (number-to-string page)))) 93 | (org-link-store-props 94 | :type "docview" 95 | :link link 96 | :description path)))) 97 | 98 | (defun org-docview-complete-link () 99 | "Use the existing file name completion for file. 100 | Links to get the file name, then ask the user for the page number 101 | and append it." 102 | (concat (replace-regexp-in-string "^file:" "docview:" (org-link-complete-file)) 103 | "::" 104 | (read-from-minibuffer "Page:" "1"))) 105 | 106 | (provide 'ol-docview) 107 | 108 | ;;; ol-docview.el ends here 109 | -------------------------------------------------------------------------------- /lisp/ol-doi.el: -------------------------------------------------------------------------------- 1 | ;;; ol-doi.el --- DOI links support in Org -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2021-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Nicolas Goaziou 6 | 7 | ;; This file is part of GNU Emacs. 8 | 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; GNU Emacs is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with GNU Emacs. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;; This library introduces the "doi" link type in Org, and provides 25 | ;; code for opening and exporting such links. 26 | 27 | ;;; Code: 28 | 29 | (require 'org-macs) 30 | (org-assert-version) 31 | 32 | (require 'ol) 33 | 34 | (defcustom org-link-doi-server-url "https://doi.org/" 35 | "The URL of the DOI server." 36 | :group 'org-link-follow 37 | :version "24.3" 38 | :type 'string 39 | :safe #'stringp) 40 | 41 | (defun org-link-doi-open (path arg) 42 | "Open a \"doi\" type link. 43 | PATH is a the path to search for, as a string. 44 | ARG is passed to `browse-url'." 45 | (browse-url (url-encode-url (concat org-link-doi-server-url path)) arg)) 46 | 47 | (defun org-link-doi-export (path desc backend info) 48 | "Export a \"doi\" type link. 49 | PATH is the DOI name. DESC is the description of the link, or 50 | nil. BACKEND is a symbol representing the backend used for 51 | export. INFO is a plist containing the export parameters." 52 | (let ((uri (concat org-link-doi-server-url path))) 53 | (pcase backend 54 | (`html 55 | (format "%s" uri (or desc uri))) 56 | (`latex 57 | (if desc (format "\\href{%s}{%s}" uri desc) 58 | (format "\\url{%s}" uri))) 59 | (`ascii 60 | (if (not desc) (format "<%s>" uri) 61 | (concat (format "[%s]" desc) 62 | (and (not (plist-get info :ascii-links-to-notes)) 63 | (format " (<%s>)" uri))))) 64 | (`texinfo 65 | (if (not desc) (format "@uref{%s}" uri) 66 | (format "@uref{%s, %s}" uri desc))) 67 | (_ uri)))) 68 | 69 | (org-link-set-parameters "doi" 70 | :follow #'org-link-doi-open 71 | :export #'org-link-doi-export) 72 | 73 | 74 | (provide 'org-link-doi) 75 | (provide 'ol-doi) 76 | ;;; ol-doi.el ends here 77 | -------------------------------------------------------------------------------- /lisp/ol-eshell.el: -------------------------------------------------------------------------------- 1 | ;;; ol-eshell.el --- Links to Working Directories in Eshell -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2011-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Konrad Hinsen 6 | 7 | ;; This file is part of GNU Emacs. 8 | 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; GNU Emacs is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with GNU Emacs. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;;; Code: 25 | 26 | (require 'org-macs) 27 | (org-assert-version) 28 | 29 | (require 'eshell) 30 | (require 'esh-mode) 31 | (require 'ol) 32 | 33 | (declare-function eshell/pwd "em-dirs.el" (&rest args)) 34 | 35 | (org-link-set-parameters "eshell" 36 | :follow #'org-eshell-open 37 | :store #'org-eshell-store-link) 38 | 39 | (defun org-eshell-open (link _) 40 | "Switch to an eshell buffer and execute a command line for LINK. 41 | The LINK can be just a command line (executed in the default 42 | eshell buffer) or a command line prefixed by a buffer name 43 | followed by a colon." 44 | (let* ((buffer-and-command 45 | (if (string-match "\\([A-Za-z0-9+*-]+\\):\\(.*\\)" link) 46 | (list (match-string 1 link) 47 | (match-string 2 link)) 48 | (list eshell-buffer-name link))) 49 | (eshell-buffer-name (car buffer-and-command)) 50 | (command (cadr buffer-and-command))) 51 | (if (get-buffer eshell-buffer-name) 52 | (pop-to-buffer 53 | eshell-buffer-name 54 | (if (boundp 'display-comint-buffer-action) ; Emacs >= 29, <= 30 55 | display-comint-buffer-action 56 | '(display-buffer-same-window (inhibit-same-window) (category . comint)))) 57 | (eshell)) 58 | (goto-char (point-max)) 59 | (eshell-kill-input) 60 | (insert command) 61 | (eshell-send-input))) 62 | 63 | (defun org-eshell-store-link (&optional _interactive?) 64 | "Store eshell link. 65 | When opened, the link switches back to the current eshell buffer and 66 | the current working directory." 67 | (when (eq major-mode 'eshell-mode) 68 | (let* ((command (concat "cd " (eshell/pwd))) 69 | (link (concat (buffer-name) ":" command))) 70 | (org-link-store-props 71 | :link (concat "eshell:" link) 72 | :description command)))) 73 | 74 | (provide 'ol-eshell) 75 | 76 | ;;; ol-eshell.el ends here 77 | -------------------------------------------------------------------------------- /lisp/ol-man.el: -------------------------------------------------------------------------------- 1 | ;;; ol-man.el --- Links to man pages -*- lexical-binding: t; -*- 2 | ;; 3 | ;; Copyright (C) 2020-2025 Free Software Foundation, Inc. 4 | ;; Author: Carsten Dominik 5 | ;; Keywords: outlines, hypermedia, calendar, text 6 | ;; URL: https://orgmode.org 7 | ;; 8 | ;; This file is part of GNU Emacs. 9 | ;; 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation, either version 3 of the License, or 13 | ;; (at your option) any later version. 14 | 15 | ;; GNU Emacs is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with GNU Emacs. If not, see . 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 | ;; 24 | ;;; Commentary: 25 | 26 | ;; This file implements links to man pages from within Org mode. 27 | 28 | ;;; Code: 29 | 30 | (require 'org-macs) 31 | (org-assert-version) 32 | 33 | (require 'ol) 34 | 35 | (org-link-set-parameters "man" 36 | :complete #'org-man-complete 37 | :follow #'org-man-open 38 | :export #'org-man-export 39 | :store #'org-man-store-link) 40 | 41 | (defcustom org-man-command 'man 42 | "The Emacs command to be used to display a man page." 43 | :group 'org-link 44 | :type '(choice (const man) (const :tag "WoMan (obsolete)" woman))) 45 | 46 | (declare-function Man-translate-references "man" (ref)) 47 | (defun org-man-open (path _) 48 | "Visit the manpage on PATH. 49 | PATH should be a topic that can be thrown at the man command. 50 | If PATH contains extra ::STRING which will use `occur' to search 51 | matched strings in man buffer." 52 | (require 'man) ; For `Man-translate-references' 53 | (string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path) 54 | (let* ((command (match-string 1 path)) 55 | ;; FIXME: Remove after we drop Emacs 29 support. 56 | ;; Working around security bug #66390. 57 | (command (if (not (equal (Man-translate-references ";id") ";id")) 58 | ;; We are on Emacs that escapes man command args 59 | ;; (see Emacs commit 820f0793f0b). 60 | command 61 | ;; Older Emacs without the fix - escape the 62 | ;; arguments ourselves. 63 | (mapconcat 'identity 64 | (mapcar #'shell-quote-argument 65 | (split-string command "\\s-+")) 66 | " "))) 67 | (search (match-string 2 path)) 68 | (buffer (funcall org-man-command command))) 69 | (when search 70 | (with-current-buffer buffer 71 | (goto-char (point-min)) 72 | (unless (search-forward search nil t) 73 | (let ((process (get-buffer-process buffer))) 74 | (while (process-live-p process) 75 | (accept-process-output process))) 76 | (goto-char (point-min)) 77 | (search-forward search)) 78 | (forward-line -1) 79 | (let ((point (point))) 80 | (let ((window (get-buffer-window buffer))) 81 | (set-window-point window point) 82 | (set-window-start window point))))))) 83 | 84 | (defun org-man-store-link (&optional _interactive?) 85 | "Store a link to a README file." 86 | (when (memq major-mode '(Man-mode woman-mode)) 87 | ;; This is a man page, we do make this link 88 | (let* ((page (org-man-get-page-name)) 89 | (link (concat "man:" page)) 90 | (description (format "Manpage for %s" page))) 91 | (org-link-store-props 92 | :type "man" 93 | :link link 94 | :description description)))) 95 | 96 | (defun org-man-get-page-name () 97 | "Extract the page name from the buffer name." 98 | ;; This works for both `Man-mode' and `woman-mode'. 99 | (if (string-match " \\(\\S-+\\)\\*" (buffer-name)) 100 | (match-string 1 (buffer-name)) 101 | (error "Cannot create link to this man page"))) 102 | 103 | (defun org-man-export (link description backend) 104 | "Export a man page LINK with DESCRIPTION. 105 | BACKEND is the current export backend." 106 | (let ((path (format "http://man.he.net/?topic=%s§ion=all" link)) 107 | (desc (or description link))) 108 | (cond 109 | ((eq backend 'html) (format "%s" path desc)) 110 | ((eq backend 'latex) (format "\\href{%s}{%s}" path desc)) 111 | ((eq backend 'texinfo) (format "@uref{%s,%s}" path desc)) 112 | ((eq backend 'ascii) (format "[%s] (<%s>)" desc path)) 113 | ((eq backend 'md) (format "[%s](%s)" desc path)) 114 | (t path)))) 115 | 116 | (defvar Man-completion-cache) ; Defined in `man'. 117 | (defun org-man-complete (&optional _arg) 118 | "Complete man pages for `org-insert-link'." 119 | (require 'man) 120 | (concat 121 | "man:" 122 | (let ((completion-ignore-case t) ; See `man' comments. 123 | (Man-completion-cache)) ; See `man' implementation. 124 | (completing-read 125 | "Manual entry: " 126 | 'Man-completion-table)))) 127 | 128 | (provide 'ol-man) 129 | 130 | ;;; ol-man.el ends here 131 | -------------------------------------------------------------------------------- /lisp/ol-rmail.el: -------------------------------------------------------------------------------- 1 | ;;; ol-rmail.el --- Links to Rmail Messages -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2004-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Carsten Dominik 6 | ;; Keywords: outlines, hypermedia, calendar, text 7 | ;; URL: https://orgmode.org 8 | ;; 9 | ;; This file is part of GNU Emacs. 10 | ;; 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ;; 25 | ;;; Commentary: 26 | 27 | ;; This file implements links to Rmail messages from within Org mode. 28 | ;; Org mode loads this module by default - if this is not what you 29 | ;; want, configure the variable `org-modules'. 30 | 31 | ;;; Code: 32 | 33 | (require 'org-macs) 34 | (org-assert-version) 35 | 36 | (require 'ol) 37 | 38 | ;; Declare external functions and variables 39 | (declare-function rmail-show-message "rmail" (&optional n no-summary)) 40 | (declare-function rmail-what-message "rmail" (&optional pos)) 41 | (declare-function rmail-toggle-header "rmail" (&optional arg)) 42 | (declare-function rmail "rmail" (&optional file-name-arg)) 43 | (declare-function rmail-widen "rmail" ()) 44 | (defvar rmail-current-message) ; From rmail.el 45 | (defvar rmail-header-style) ; From rmail.el 46 | (defvar rmail-file-name) ; From rmail.el 47 | 48 | ;; Install the link type 49 | (org-link-set-parameters "rmail" 50 | :follow #'org-rmail-open 51 | :store #'org-rmail-store-link) 52 | 53 | ;; Implementation 54 | (defun org-rmail-store-link (&optional _interactive?) 55 | "Store a link to an Rmail folder or message." 56 | (when (or (eq major-mode 'rmail-mode) 57 | (eq major-mode 'rmail-summary-mode)) 58 | (save-window-excursion 59 | (save-restriction 60 | (when (eq major-mode 'rmail-summary-mode) 61 | (rmail-show-message rmail-current-message)) 62 | (when (fboundp 'rmail-narrow-to-non-pruned-header) 63 | (rmail-narrow-to-non-pruned-header)) 64 | (when (eq rmail-header-style 'normal) 65 | (rmail-toggle-header -1)) 66 | (let* ((folder buffer-file-name) 67 | (message-id (mail-fetch-field "message-id")) 68 | (from (mail-fetch-field "from")) 69 | (to (mail-fetch-field "to")) 70 | (subject (mail-fetch-field "subject")) 71 | (date (mail-fetch-field "date")) 72 | desc link) 73 | (org-link-store-props 74 | :type "rmail" :from from :to to :date date 75 | :subject subject :message-id message-id) 76 | (setq message-id (org-unbracket-string "<" ">" message-id)) 77 | (setq desc (org-link-email-description)) 78 | (setq link (concat "rmail:" folder "#" message-id)) 79 | (org-link-add-props :link link :description desc) 80 | (rmail-show-message rmail-current-message) 81 | link))))) 82 | 83 | (defun org-rmail-open (path _) 84 | "Follow an Rmail message link to the specified PATH." 85 | (let (folder article) 86 | (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 87 | (error "Error in Rmail link")) 88 | (setq folder (match-string 1 path) 89 | article (match-string 3 path)) 90 | (org-rmail-follow-link folder article))) 91 | 92 | (defun org-rmail-follow-link (folder article) 93 | "Follow an Rmail link to FOLDER and ARTICLE." 94 | (require 'rmail) 95 | (cond ((null article) (setq article "")) 96 | ((stringp article) 97 | (setq article (org-link-add-angle-brackets article))) 98 | (t (user-error "Wrong RMAIL link format"))) 99 | (let (message-number) 100 | (save-excursion 101 | (save-window-excursion 102 | (rmail (if (string= folder "RMAIL") rmail-file-name folder)) 103 | (setq message-number 104 | (save-restriction 105 | (rmail-widen) 106 | (goto-char (point-max)) 107 | (if (re-search-backward 108 | (concat "^Message-ID:\\s-+" (regexp-quote article)) 109 | nil t) 110 | (rmail-what-message)))))) 111 | (if message-number 112 | (progn 113 | (rmail (if (string= folder "RMAIL") rmail-file-name folder)) 114 | (rmail-show-message message-number) 115 | message-number) 116 | (error "Message not found")))) 117 | 118 | (provide 'ol-rmail) 119 | 120 | ;;; ol-rmail.el ends here 121 | -------------------------------------------------------------------------------- /mk/guidesplit.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Work on the files that are created by makeinfo for html output 3 | # split into many small files. 4 | 5 | # This will walk though the files listed on the command line, install 6 | # Sebastian Rose's key reader and add a small top-level-only table 7 | # of contents that will be placed into a special region and visible 8 | # in all subfiles. The small contents is a constant and has to be updated 9 | # by hand, currently. 10 | 11 | $contents = < 13 |

Table of Contents

14 | 34 | 35 | 36 | EOF 37 | 38 | $script = <<'EOF'; 39 | 40 | 41 | 47 | EOF 48 | 49 | while ($page = shift) { 50 | system "mv $page $page.orig"; 51 | open IN,"<$page.orig" or die "Cannot read from $page.orig\n"; 52 | undef $/; 53 | $all = ; 54 | close IN; 55 | 56 | $all =~ s//$&\n$script/; 57 | $all =~ s/^/\n$contents/m; 58 | 59 | open OUT,">$page" or die "Cannot write to $page\n"; 60 | print OUT $all; 61 | close OUT; 62 | system "rm $page.orig"; 63 | } 64 | -------------------------------------------------------------------------------- /mk/manfull.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $failures = 0; 4 | 5 | while ($page = shift) { 6 | system "mv $page $page.orig"; 7 | open IN,"<$page.orig" or die "Cannot read from $page.orig\n"; 8 | open OUT,">$page" or die "Cannot write to $page\n"; 9 | 10 | $toc = undef; 11 | 12 | while () { 13 | if (//) { 14 | print OUT; 15 | print OUT ''; 16 | } elsif (/
/) { 17 | print OUT; 18 | print OUT '

This is the official manual for the latest Org mode release.

'; 19 | } elsif (/

Table of Contents<\/h2>|

/) { 20 | print OUT; 21 | print OUT 'https://orgmode.org
'; 22 | $toc = 1; 23 | } elsif (/<\/div>/ and $toc) { 24 | print OUT "

"; 25 | $toc = 0; 26 | } else { 27 | print OUT; 28 | } 29 | } 30 | system "rm $page.orig"; 31 | 32 | if (!defined($toc) || $toc != 0) { 33 | ++$failures; 34 | print STDERR "Patching of $page failed\n"; 35 | } 36 | } 37 | 38 | $failures == 0 or die "Patching of $failures files failed\n"; 39 | -------------------------------------------------------------------------------- /mk/mansplit.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Work on the files that are created by makeinfo for html output 3 | # split into many small files. 4 | 5 | # This will walk though the files listed on the command line, install 6 | # Sebastian Rose's key reader and add a small top-level-only table 7 | # of contents that will be placed into a special region and visible 8 | # in all subfiles. The small contents is a constant and has to be updated 9 | # by hand, currently. 10 | 11 | $contents = < 13 |

This is the official manual for the latest Org-mode release.

14 |

Table of Contents

15 | 41 | 42 | 43 | EOF 44 | 45 | 46 | $script = <<'EOF'; 47 | 48 | 49 | 55 | EOF 56 | 57 | while ($page = shift) { 58 | system "mv $page $page.orig"; 59 | open IN,"<$page.orig" or die "Cannot read from $page.orig\n"; 60 | undef $/; 61 | $all = ; 62 | close IN; 63 | 64 | $all =~ s//$&\n$script/; 65 | $all =~ s/^/\n$contents/m; 66 | 67 | open OUT,">$page" or die "Cannot write to $page\n"; 68 | print OUT $all; 69 | close OUT; 70 | system "rm $page.orig"; 71 | } 72 | -------------------------------------------------------------------------------- /mk/orgcard2txt.pl: -------------------------------------------------------------------------------- 1 | # orgcard2txt.pl - a script to generate orgcard.txt from orgcard.tex 2 | # Copyright (C) 2010, 2013 Osamu OKANO 3 | # 4 | # Version: 0.1 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # Usage: 20 | # ====== 21 | # perl orgcard2txt.pl orgcard.tex > orgcard.txt 22 | use strict; 23 | use warnings; 24 | 25 | sub rep_esc{ 26 | my $s = shift @_; 27 | $s =~ s/\\kbd\{([^}]+)\}/$1/g; 28 | $s =~ s/\$\^([0-9])\$/[$1]/g; 29 | $s =~ s/\\rm //g; 30 | $s =~ s/\\\///g; 31 | $s =~ s/\\\^\{\}/^/g; 32 | $s =~ s/\\}/}/g; 33 | $s =~ s/\\\{/{/g; 34 | $s =~ s/\\\#/#/g; 35 | $s =~ s/\\\^/^/g; 36 | $s =~ s/\\\%/%/g; 37 | $s =~ s/\\\_/_/g; 38 | $s =~ s/\\\&/&/g; 39 | $s =~ s/\\\$/\$/g; 40 | $s =~ s/\$\\leftrightarrow\$/<->/g; 41 | $s =~ s/\$\\pm 1\$/±1/g; 42 | $s =~ s/``\{\\tt ([^}]+)}''/`$1'/g; 43 | return $s; 44 | } 45 | my $page=0; 46 | my $orgversionnumber; 47 | 48 | open(IN,"org-version.tex"); 49 | while(){ 50 | last if(/\f/); 51 | $orgversionnumber = $1 if /\\def\\orgversionnumber\{([^}]+)}/; 52 | } 53 | close(IN); 54 | 55 | print <){ 71 | if(/\f/){ 72 | $page = $page + 1; 73 | next; 74 | } 75 | next if($page != 1); 76 | next if(/^%/); 77 | next if /Org Mode Reference Card \([12]\/2\)/; 78 | next if /\\centerline\{\(for version \\orgversionnumber\)}/; 79 | next if /\(for version \)/; 80 | next if /\\newcolumn/; 81 | next if /\\copyrightnotice/; 82 | next if /\\bye/; 83 | next if /\\title\{([^}]+)}/; 84 | chomp; 85 | # print "b:$_\n"; 86 | s/([^\\])\%.+$/$1/; 87 | # print "a:$_\n"; 88 | if (/\\section\{(.+)}/){ 89 | my $sec = rep_esc($1); 90 | print "================================================================================\n"; 91 | print "$sec\n"; 92 | print "================================================================================\n"; 93 | next; 94 | } 95 | if (/{\\bf (.+)}/){ 96 | my $bf = rep_esc($1); 97 | print "--------------------------------------------------------------------------------\n"; 98 | print "$bf\n"; 99 | print "--------------------------------------------------------------------------------\n"; 100 | next; 101 | } 102 | if (/^{\\it (.+)}/){ 103 | my $it = rep_esc($1); 104 | print "--------------------------------------------------------------------------------\n"; 105 | print "$it\n"; 106 | print "--------------------------------------------------------------------------------\n"; 107 | next; 108 | } 109 | if(/^\\key\{(.+)}\s*$/||/^\\metax\{(.+)}\s*$/){ 110 | my ($k,$v) = split(/}\{/,$1); 111 | my $k2 = &rep_esc($k); 112 | my $v2 = &rep_esc($v); 113 | # print "$k2\t$v2\n"; 114 | ($key,$value)=($k2,$v2); 115 | write; 116 | next; 117 | } 118 | my $line = rep_esc($_); 119 | $line =~ s/{\\it ([^}]+)}/$1/g; 120 | $line =~ s/{\\tt ([^}]+)}/$1/g; 121 | print "$line\n"; 122 | } 123 | close(IN); 124 | -------------------------------------------------------------------------------- /mk/server.mk: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------- 2 | # This file is used to upload the Org documentation to the server 3 | #---------------------------------------------------------------- 4 | .PHONY: helpserver \ 5 | doc-up \ 6 | upload \ 7 | tagwarn version 8 | 9 | help helpserver:: 10 | $(info ) 11 | $(info Maintenance) 12 | $(info ===========) 13 | $(info upload - clean up, populate the server with documentation) 14 | 15 | helpserver:: 16 | @echo "" 17 | 18 | #---------------------------------------------------------------------- 19 | 20 | SERVROOT ?= upload 21 | SERVERMK ?= true # or just any value at all, really 22 | 23 | #---------------------------------------------------------------------- 24 | 25 | release: cleanall info pdf card tagwarn 26 | 27 | PKG_TAG = $(shell date +%Y%m%d) 28 | PKG_DOC = "Outline-based notes management and organizer" 29 | PKG_REQ = "" # marmalade chokes on explicit "nil" 30 | 31 | tagwarn: 32 | $(if $(filter-out $(ORGVERSION), $(GITVERSION)), \ 33 | $(info ======================================================) \ 34 | $(info = =) \ 35 | $(info = A release should only be made from a revision that =) \ 36 | $(info = has an annotated tag! =) \ 37 | $(info = =) \ 38 | $(info ======================================================)) 39 | 40 | version: 41 | @echo ORGVERSION=$(ORGVERSION) GITVERSION=$(GITVERSION)$(ORGDIST) 42 | @echo "ORGVERSION ?= $(ORGVERSION)" > mk/version.mk 43 | @echo "GITVERSION ?= $(GITVERSION)" >> mk/version.mk 44 | 45 | doc-up: info pdf card html 46 | $(MAKE) -C doc manual guide 47 | $(CP) doc/org.html $(SERVROOT) 48 | $(CP) doc/orgcard.pdf $(SERVROOT) 49 | $(CP) doc/orgcard_letter.pdf $(SERVROOT) 50 | $(CP) doc/org.pdf $(SERVROOT) 51 | $(CP) doc/orgguide.html $(SERVROOT) 52 | $(CP) doc/orgguide.pdf $(SERVROOT) 53 | $(CP) doc/manual/* $(SERVROOT)/manual 54 | $(CP) doc/guide/* $(SERVROOT)/guide 55 | 56 | upload: cleanall doc-up 57 | -------------------------------------------------------------------------------- /mk/targets.mk: -------------------------------------------------------------------------------- 1 | .EXPORT_ALL_VARIABLES: 2 | # Additional distribution files 3 | DISTFILES_extra= Makefile etc 4 | 5 | LISPDIRS = lisp 6 | OTHERDIRS = doc etc 7 | CLEANDIRS = testing mk 8 | SUBDIRS = $(OTHERDIRS) $(LISPDIRS) 9 | INSTSUB = $(SUBDIRS:%=install-%) 10 | ORG_MAKE_DOC ?= info html pdf 11 | 12 | ifneq ($(wildcard .git),) 13 | # Use the org.el header. 14 | ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \ 15 | --visit lisp/org.el --eval '(princ (lm-header "version"))')) 16 | GITVERSION := $(shell git describe --match release\* --abbrev=6 HEAD 2>/dev/null || echo "${ORGVERSION}-$(shell git describe --match release\* --abbrev=6 --always HEAD)") 17 | GITSTATUS := $(shell git status -uno --porcelain) 18 | else 19 | -include mk/version.mk 20 | GITVERSION ?= N/A 21 | ORGVERSION ?= N/A 22 | endif 23 | DATE := $(shell date +%Y-%m-%d) 24 | YEAR := $(shell date +%Y) 25 | ifneq ($(GITSTATUS),) 26 | GITVERSION := $(GITVERSION:.dirty=).dirty 27 | endif 28 | 29 | .PHONY: all oldorg update update2 up0 up1 up2 single native $(SUBDIRS) \ 30 | check test test-dirty install install-info $(INSTSUB) \ 31 | info html pdf card refcard doc docs \ 32 | autoloads cleanall clean $(CLEANDIRS:%=clean%) \ 33 | clean-install cleanelc cleandirs \ 34 | cleanlisp cleandoc cleandocs cleantest \ 35 | compile compile-dirty uncompiled \ 36 | config config-test config-exe config-all config-eol config-version \ 37 | vanilla repro 38 | 39 | CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC 40 | CONF_DEST = lispdir infodir datadir testdir 41 | CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE 42 | CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO 43 | CONF_CALL = BATCH BATCHL ELC ELN ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION 44 | config-eol:: EOL = \# 45 | config-eol:: config-all 46 | config config-all:: 47 | $(info ) 48 | $(info ========= Emacs executable and Installation paths) 49 | $(foreach var,$(CONF_BASE),$(info $(var) = $($(var))$(EOL))) 50 | $(foreach var,$(CONF_DEST),$(info $(var) = $(DESTDIR)$($(var))$(EOL))) 51 | config-test config-all:: 52 | $(info ) 53 | $(info ========= Test configuration) 54 | $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL))) 55 | config-exe config-all:: 56 | $(info ) 57 | $(info ========= Executables used by make) 58 | $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL))) 59 | config-cmd config-all:: 60 | $(info ) 61 | $(info ========= Commands used by make) 62 | $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL))) 63 | config config-test config-exe config-all config-version:: 64 | $(info ========= Org version) 65 | $(info make: Org mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir))) 66 | @echo "" 67 | 68 | oldorg: compile info # what the old makefile did when no target was specified 69 | uncompiled: cleanlisp autoloads # for developing 70 | refcard: card 71 | update update2:: up0 clean autoloads all 72 | 73 | single: ORGCM=single 74 | single: compile 75 | 76 | native: ORGCM=native 77 | native: compile 78 | 79 | .PRECIOUS: local.mk 80 | local.mk: 81 | $(info ======================================================) 82 | $(info = Invoke "make help" for a synopsis of make targets. =) 83 | $(info = Created a default local.mk template. =) 84 | $(info = Setting "oldorg" as the default target. =) 85 | $(info = Please adapt local.mk to your local setup! =) 86 | $(info ======================================================) 87 | -@$(MAKE_LOCAL_MK) 88 | 89 | all compile:: 90 | $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;) 91 | compile compile-dirty:: 92 | $(MAKE) -C lisp $@ 93 | all clean-install:: 94 | $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;) 95 | 96 | vanilla: 97 | -@$(NOBATCH) & 98 | 99 | check test:: compile 100 | check test test-dirty:: 101 | -$(MKDIR) $(testdir) 102 | TMPDIR=$(testdir) $(BTEST) 103 | ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection 104 | $(MAKE) cleantest 105 | endif 106 | 107 | up0 up1 up2:: 108 | git checkout $(GIT_BRANCH) 109 | git remote update 110 | git pull 111 | up1 up2:: clean autoloads test-dirty 112 | up2 update2:: 113 | $(SUDO) $(MAKE) install 114 | 115 | install: $(INSTSUB) 116 | 117 | install-info: install-doc 118 | 119 | doc docs: $(ORG_MAKE_DOC) 120 | 121 | info html pdf card: 122 | $(MAKE) -C doc $@ 123 | 124 | $(INSTSUB): 125 | $(MAKE) -C $(@:install-%=%) install 126 | 127 | autoloads: lisp 128 | $(MAKE) -C $< $@ 129 | 130 | repro: cleanall autoloads 131 | -@$(REPRO) & 132 | 133 | cleandirs: 134 | $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;) 135 | 136 | clean: cleanlisp cleandoc 137 | 138 | cleanall: cleandirs cleantest 139 | -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} + 140 | -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} + 141 | 142 | $(CLEANDIRS:%=clean%): 143 | -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} + 144 | 145 | cleanelc: 146 | $(MAKE) -C lisp $@ 147 | 148 | cleanlisp cleandoc: 149 | $(MAKE) -C $(@:clean%=%) clean 150 | 151 | cleandocs: 152 | $(MAKE) -C doc clean 153 | -$(FIND) doc -name \*~ -exec $(RM) {} \; 154 | 155 | cleantest: 156 | # git-annex creates non-writable directories so that the files within 157 | # them can't be removed; if rm fails, try to recover by making all 158 | # directories writable 159 | -$(RMR) $(testdir) || { \ 160 | $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \ 161 | $(RMR) $(testdir) ; \ 162 | } 163 | -------------------------------------------------------------------------------- /testing/examples/Basic.bib: -------------------------------------------------------------------------------- 1 | @book{friends, 2 | title = {{{LaTeX}} and Friends}, 3 | author = {van Dongen, M.R.C.}, 4 | date = {2012}, 5 | location = {Berlin}, 6 | publisher = {Springer}, 7 | doi = {10.1007/978-3-642-23816-1}, 8 | isbn = {9783642238161} 9 | } 10 | 11 | @InCollection{Geyer2011, 12 | author = {Geyer, Charles J}, 13 | title = {{Introduction to Markov\plus Chain Monte Carlo}}, 14 | year = 2011, 15 | booktitle = {{Handbook of Markov Chain Monte Carlo}}, 16 | editor = {Brooks, Steve and Gelman, Andrew and Jones, Galin and Meng, 17 | Xiao-Li}, 18 | publisher = {CRC press}, 19 | pages = 45, 20 | } 21 | -------------------------------------------------------------------------------- /testing/examples/agenda-file.org: -------------------------------------------------------------------------------- 1 | * Test Agenda 2 | 3 | <2017-03-10 Fri> 4 | * test agenda 5 | SCHEDULED: <2017-07-19 Wed> 6 | ** subnote 7 | * test code 216bc1ff1d862e78183e38ee9a4da504919b9878 8 | <2019-01-08 Tue> 9 | * test agenda non-scheduled 10 | #+begin_src org 11 | SCHEDULED: <2022-01-03 Mon> 12 | #+end_src 13 | * colon scheduled entry 14 | : SCHEDULED: <2022-01-03 Mon> 15 | * begin_example scheduled entry 16 | #+begin_example 17 | SCHEDULED: <2022-01-03 Mon> 18 | #+end_example 19 | * test timestamp inside properties 20 | :PROPERTIES: 21 | :CREATED: <2022-03-22 Tue> 22 | :END: 23 | * test sexp timestamp inside properties 24 | :PROPERTIES: 25 | :CREATED: <%%(diary-date 03 25 2022)> 26 | :END: 27 | -------------------------------------------------------------------------------- /testing/examples/agenda-file2.org: -------------------------------------------------------------------------------- 1 | * TODO one 2 | SCHEDULED: <2024-01-17 Wed 09:30-10:00> 3 | * TODO two 4 | SCHEDULED: <2024-01-17 Wed 10:00-12:30> 5 | * TODO three 6 | SCHEDULED: <2024-01-17 Wed 13:00-15:00> 7 | * TODO four 8 | SCHEDULED: <2024-01-17 Wed 19:00> 9 | * TODO five 10 | <2024-01-17 Wed 19:00>--<2024-01-18 Thu 18:00> 11 | -------------------------------------------------------------------------------- /testing/examples/agenda-search.org: -------------------------------------------------------------------------------- 1 | * Test heading with text 2 | foo 3 | * Test heading with inlinetask 4 | foo 5 | ****************** inline 6 | text inside inlinetask 7 | ****************** END 8 | bar 9 | -------------------------------------------------------------------------------- /testing/examples/att1/fileA: -------------------------------------------------------------------------------- 1 | Text in fileA 2 | -------------------------------------------------------------------------------- /testing/examples/att1/fileB: -------------------------------------------------------------------------------- 1 | Text in fileB 2 | -------------------------------------------------------------------------------- /testing/examples/att2/fileC: -------------------------------------------------------------------------------- 1 | Text in fileC -------------------------------------------------------------------------------- /testing/examples/att2/fileD: -------------------------------------------------------------------------------- 1 | text in fileD 2 | -------------------------------------------------------------------------------- /testing/examples/attachments.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Org attach testfile 2 | Used to test and verify the functionality of org-attach. 3 | 4 | * H1 5 | :PROPERTIES: 6 | :DIR: att1 7 | :END: 8 | A link to one attachment: [[attachment:fileA]] 9 | 10 | ** H1.1 11 | A link to another attachment: [[attachment:fileB]] 12 | 13 | ** H1.2 14 | :PROPERTIES: 15 | :DIR: att2 16 | :END: 17 | 18 | * H2 19 | :PROPERTIES: 20 | :ID: abcd123 21 | :END: 22 | 23 | * H3 24 | :PROPERTIES: 25 | :DIR: att1 26 | :ID: abcd1234 27 | :END: 28 | 29 | ** H3.1 30 | :PROPERTIES: 31 | :ID: abcd12345 32 | :END: 33 | -------------------------------------------------------------------------------- /testing/examples/babel-dangerous.org: -------------------------------------------------------------------------------- 1 | #+Title: dangerous code block examples which should be isolated 2 | #+OPTIONS: ^:nil 3 | 4 | * no default value for vars 5 | :PROPERTIES: 6 | :ID: f2df5ba6-75fa-4e6b-8441-65ed84963627 7 | :END: 8 | 9 | There is no default value assigned to =x= variable. This is not permitted 10 | anymore. 11 | 12 | #+name: carre 13 | #+begin_src python :var x 14 | return x*x 15 | #+end_src 16 | -------------------------------------------------------------------------------- /testing/examples/babel.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t; -*- 2 | (string-match-p "^#[[:digit:]]+$" "#123") 3 | 4 | ;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]] 5 | ;; detangle changes 6 | ;; linked content to detangle:1 ends here 7 | -------------------------------------------------------------------------------- /testing/examples/data/ab/cd123/fileE: -------------------------------------------------------------------------------- 1 | peek-a-boo 2 | -------------------------------------------------------------------------------- /testing/examples/diary-file: -------------------------------------------------------------------------------- 1 | 2019-01-08 test code: f0bcf0cd8bad93c1451bb6e1b2aaedef5cce7cbb 2 | -------------------------------------------------------------------------------- /testing/examples/images/Org mode logo mono-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bzg/org-mode/c356e1c9b750740a9066ebddb53be055531fa076/testing/examples/images/Org mode logo mono-color.png -------------------------------------------------------------------------------- /testing/examples/include.html: -------------------------------------------------------------------------------- 1 |

HTML!

2 | -------------------------------------------------------------------------------- /testing/examples/include.org: -------------------------------------------------------------------------------- 1 | Small Org file with an include keyword. 2 | 3 | #+BEGIN_SRC emacs-lisp :exports results 4 | (+ 2 1) 5 | #+END_SRC 6 | 7 | #+INCLUDE: "include2.org" 8 | 9 | * Heading 10 | body 11 | 12 | * Another heading 13 | :PROPERTIES: 14 | :CUSTOM_ID: ah 15 | :END: 16 | 1 17 | 2 18 | 3 19 | 20 | * A headline with a table 21 | :PROPERTIES: 22 | :CUSTOM_ID: ht 23 | :END: 24 | #+CAPTION: a table 25 | #+NAME: tbl 26 | | 1 | 27 | 28 | * drawer-headline 29 | :PROPERTIES: 30 | :CUSTOM_ID: dh 31 | :END: 32 | :LOGBOOK: 33 | drawer 34 | :END: 35 | content 36 | -------------------------------------------------------------------------------- /testing/examples/include2.org: -------------------------------------------------------------------------------- 1 | Success! 2 | -------------------------------------------------------------------------------- /testing/examples/link-in-heading.org: -------------------------------------------------------------------------------- 1 | this file has a link in it's heading, which can cause problems 2 | 3 | * [[http://www.example.com][example]] 4 | 5 | what a weird heading... 6 | 7 | #+begin_src emacs-lisp 8 | ;; a8b1d111-eca8-49f0-8930-56d4f0875155 9 | (message "my heading has a link") 10 | #+end_src 11 | -------------------------------------------------------------------------------- /testing/examples/links.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Testing various links types 2 | 3 | * Plain links 4 | 5 | - https://orgmode.org 6 | - [[https://orgmode.org][Org mode website]] 7 | - mailto:bzg@gnu.org 8 | 9 | * Links to files 10 | 11 | - file:///home/ 12 | - [[file:normal.org][normal.org]] 13 | - [[file:normal.org::3][normal.org (third line)]] 14 | - file:normal.org::example 15 | - file:normal.org::* top 16 | - id:eaefc396-8943-4666-be6a-d5a1dbb05480 17 | 18 | * External links 19 | :PROPERTIES: 20 | :ID: eaefc396-8943-4666-be6a-d5a1dbb05480 21 | :END: 22 | 23 | - info:Org 24 | - [[info:org:External links]] 25 | - [[shell:ls -l]] 26 | - elisp:org-agenda 27 | - [[elisp:(find-file-other-frame "normal.org")]] 28 | 29 | -------------------------------------------------------------------------------- /testing/examples/macro-templates.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Macro templates 2 | #+MACRO: included-macro success 3 | -------------------------------------------------------------------------------- /testing/examples/no-heading.org: -------------------------------------------------------------------------------- 1 | This is an example file for use by the Org mode tests. 2 | 3 | This file is special because it has no headings, which can be 4 | erroneously assumed by some code. 5 | 6 | #+begin_src emacs-lisp :tangle no 7 | ;; 94839181-184f-4ff4-a72f-94214df6f5ba 8 | (message "I am code") 9 | #+end_src 10 | -------------------------------------------------------------------------------- /testing/examples/normal.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Example file 2 | #+OPTIONS: num:nil ^:nil 3 | #+STARTUP: hideblocks 4 | 5 | This is an example file for use by the Org mode tests. 6 | 7 | * top 8 | ** code block 9 | :PROPERTIES: 10 | :header-args: :tangle yes 11 | :CUSTOM_ID: code-block-section 12 | :END: 13 | Here are a couple of code blocks. 14 | 15 | #+begin_src emacs-lisp :tangle no 16 | ;; 94839181-184f-4ff4-a72f-94214df6f5ba 17 | (message "I am code") 18 | #+end_src 19 | * accumulating properties in drawers 20 | :PROPERTIES: 21 | :header-args+: :var bar=2 22 | :header-args: :var foo=1 23 | :ID: 75282ba2-f77a-4309-a970-e87c149fe125 24 | :END: 25 | 26 | #+begin_src emacs-lisp :results silent 27 | (list bar foo) 28 | #+end_src 29 | -------------------------------------------------------------------------------- /testing/examples/ob-C-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-C tests 2 | #+OPTIONS: ^:nil 3 | * Simple tests 4 | :PROPERTIES: 5 | :ID: fa6db330-e960-4ea2-ac67-94bb845b8577 6 | :END: 7 | #+source: simple 8 | #+begin_src cpp :includes "" :results silent 9 | std::cout << 42; 10 | return 0; 11 | #+end_src 12 | 13 | #+source: simple 14 | #+begin_src cpp :includes :results silent 15 | std::cout << 42; 16 | return 0; 17 | #+end_src 18 | 19 | #+source: simple 20 | #+begin_src D :results silent 21 | writefln ("%s", 42); 22 | #+end_src 23 | 24 | #+source: integer_var 25 | #+begin_src cpp :var q=12 :includes "" :results silent 26 | std::cout << q; 27 | return 0; 28 | #+end_src 29 | 30 | #+source: integer_var 31 | #+begin_src D :var q=12 :results silent 32 | writefln ("%s", q); 33 | #+end_src 34 | 35 | #+source: two_var 36 | #+begin_src cpp :var q=12 :var p=10 :includes "" :results silent 37 | std::cout << p+q; 38 | return 0; 39 | #+end_src 40 | 41 | #+source: two_var 42 | #+begin_src D :var q=12 :var p=10 :results silent 43 | writefln ("%s", p+q); 44 | #+end_src 45 | 46 | #+source: string_var 47 | #+begin_src cpp :var q="word" :includes '( ) :results silent 48 | std::cout << q << ' ' << std::strlen(q); 49 | return 0; 50 | #+end_src 51 | 52 | #+source: string_var 53 | #+begin_src D :var q="word" :results silent 54 | writefln ("%s %s", q, q.length); 55 | #+end_src 56 | 57 | #+source: define 58 | #+begin_src cpp :defines N 42 :includes "" :results silent 59 | std::cout << N; 60 | return 0; 61 | #+end_src 62 | 63 | * Array 64 | :PROPERTIES: 65 | :ID: 2df1ab83-3fa3-462a-a1f3-3aef6044a874 66 | :END: 67 | #+source: array 68 | #+begin_src cpp :includes "" :results vector :results silent 69 | for (int i=1; i<3; i++) { 70 | std::cout << i << '\n'; 71 | } 72 | return 0; 73 | #+end_src 74 | 75 | #+source: array 76 | #+begin_src D :results vector :results silent 77 | foreach (i; 1..3) 78 | writefln ("%s", i); 79 | #+end_src 80 | 81 | * Matrix 82 | :PROPERTIES: 83 | :ID: cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5 84 | :END: 85 | #+name: C-matrix 86 | | 1 | 2 | 87 | | 3 | 4 | 88 | 89 | #+source: list_var 90 | #+begin_src cpp :var a='("abc" "def") :includes "" :results silent 91 | std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n'; 92 | #+end_src 93 | 94 | #+source: list_var 95 | #+begin_src D :var a='("abc" "def") :results silent 96 | writefln ("%s%s%s", a[0], a[1], a.length); 97 | #+end_src 98 | 99 | #+source: vector_var 100 | #+begin_src cpp :var a='[1 2] :includes "" :results silent 101 | std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n'; 102 | #+end_src 103 | 104 | #+source: vector_var 105 | #+begin_src D :var a='[1 2] :results silent 106 | writefln ("%s%s%s", a[0], a[1], a.length); 107 | #+end_src 108 | 109 | #+source: list_list_var 110 | #+begin_src cpp :var q=C-matrix :includes "" :results silent 111 | std::cout << q[0][0] << ' ' << q[1][0] << '\n' 112 | << q[0][1] << ' ' << q[1][1] << '\n'; // transpose 113 | #+end_src 114 | 115 | #+source: list_list_var 116 | #+begin_src D :var q=C-matrix :results silent 117 | writefln ("%s %s", q[0][0], q[1][0]); 118 | writefln ("%s %s", q[0][1], q[1][1]); // transpose 119 | #+end_src 120 | 121 | * Inhomogeneous table 122 | :PROPERTIES: 123 | :ID: e112bc2e-419a-4890-99c2-7ac4779531cc 124 | :END: 125 | 126 | #+name: tinomogen 127 | | day | quty | 128 | |-----------+------| 129 | | monday | 34 | 130 | | tuesday | 41 | 131 | | wednesday | 56 | 132 | | thursday | 17 | 133 | | friday | 12 | 134 | | saturday | 7 | 135 | | sunday | 4 | 136 | 137 | #+source: inhomogeneous_table 138 | #+begin_src cpp :var tinomogen=tinomogen :results silent :includes 139 | int main() 140 | { 141 | int i, j; 142 | for (i=0; i :results output verbatim raw 173 | std::cout << "\"line 1\"\n"; 174 | std::cout << "\"line 2\"\n"; 175 | std::cout << "\"line 3\"\n"; 176 | #+end_src 177 | -------------------------------------------------------------------------------- /testing/examples/ob-awk-test.in: -------------------------------------------------------------------------------- 1 | # an input file for awk test 2 | 15 -------------------------------------------------------------------------------- /testing/examples/ob-awk-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-awk tests 2 | #+OPTIONS: ^:nil 3 | 4 | * Simple tests 5 | :PROPERTIES: 6 | :ID: 9e998b2a-3581-43fe-b26d-07d3c507b86a 7 | :END: 8 | Run without input stream 9 | #+begin_src awk :output silent :results silent 10 | BEGIN { 11 | print 42 12 | } 13 | #+end_src 14 | 15 | Use a code block output as an input 16 | #+begin_src awk :stdin genseq :results silent 17 | { 18 | print 42+$1 19 | } 20 | #+end_src 21 | 22 | Use input file 23 | #+name: genfile 24 | #+begin_src awk :in-file ob-awk-test.in :results silent 25 | $0~/[\t]*#/{ 26 | # skip comments 27 | next 28 | } 29 | { 30 | print $1*10 31 | } 32 | #+end_src 33 | 34 | #+name: awk-table-input 35 | | a | b | c | 36 | 37 | #+begin_src awk :var a=awk-table-input 38 | BEGIN{ print a; } 39 | #+end_src 40 | 41 | * Input data generators 42 | A code block to generate input stream 43 | #+name: genseq 44 | #+begin_src emacs-lisp :results silent 45 | (print "1") 46 | #+end_src 47 | -------------------------------------------------------------------------------- /testing/examples/ob-fortran-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-fortran tests 2 | #+OPTIONS: ^:nil 3 | 4 | * simple programs 5 | :PROPERTIES: 6 | :ID: 459384e8-1797-4f11-867e-dde0473ea7cc 7 | :END: 8 | #+name: hello 9 | #+begin_src fortran :results silent 10 | print *, 'Hello world' 11 | #+end_src 12 | 13 | #+name: fortran_parameter 14 | #+begin_src fortran :results silent 15 | integer, parameter :: i = 10 16 | write (*, '(i2)') i 17 | #+end_src 18 | 19 | * variable resolution 20 | :PROPERTIES: 21 | :ID: d8d1dfd3-5f0c-48fe-b55d-777997e02242 22 | :END: 23 | #+begin_src fortran :var N = 15 :results silent 24 | write (*, '(i2)') N 25 | #+end_src 26 | 27 | Define for preprocessed fortran 28 | #+begin_src fortran :defines N 42 :results silent 29 | implicit none 30 | write (*, '(i2)') N 31 | #+end_src 32 | 33 | #+begin_src fortran :var s="word" :results silent 34 | write (*, '(a4)') s 35 | #+end_src 36 | * arrays 37 | :PROPERTIES: 38 | :ID: c28569d9-04ce-4cad-ab81-1ea29f691465 39 | :END: 40 | Real array as input 41 | #+begin_src fortran :var s='(1.0 2.0 3.0) :results silent 42 | write (*, '(3f5.2)'), s 43 | #+end_src 44 | 45 | #+name: test_tbl 46 | | 1.0 | 47 | | 2.0 | 48 | 49 | #+begin_src fortran :var s=test_tbl :results silent 50 | write (*, '(2f5.2)'), s 51 | #+end_src 52 | 53 | * matrix 54 | :PROPERTIES: 55 | :ID: 3f73ab19-d25a-428d-8c26-e8c6aa933976 56 | :END: 57 | Real matrix as input 58 | #+name: fortran-input-matrix1 59 | | 0.0 | 42.0 | 60 | | 0.0 | 0.0 | 61 | | 0.0 | 0.0 | 62 | 63 | #+name: fortran-input-matrix2 64 | | 0.0 | 0.0 | 0.0 | 65 | | 0.0 | 0.0 | 42.0 | 66 | 67 | #+begin_src fortran :var s=fortran-input-matrix1 :results silent 68 | write (*, '(i2)'), nint(s(1,2)) 69 | #+end_src 70 | 71 | #+begin_src fortran :var s=fortran-input-matrix2 :results silent 72 | write (*, '(i2)'), nint(s(2,3)) 73 | #+end_src 74 | 75 | * failing 76 | :PROPERTIES: 77 | :ID: 891ead4a-f87a-473c-9ae0-1cf348bcd04f 78 | :END: 79 | Should fail (TODO: add input variables for the case with explicit 80 | program statement) 81 | #+begin_src fortran :var s="word" :results silent 82 | program ex 83 | print *, "output of ex program" 84 | end program ex 85 | #+end_src 86 | 87 | Fails to compile (TODO: error check in ob-fortran.el) 88 | #+begin_src fortran :var s='(1 ()) :results silent 89 | print *, s 90 | #+end_src 91 | 92 | Should fail to compile with gfortran 93 | #+begin_src fortran :flags --std=f95 --pedantic-error :results silent 94 | program ex 95 | integer*8 :: i 96 | end program ex 97 | #+end_src 98 | 99 | * programs input parameters 100 | :PROPERTIES: 101 | :ID: 2d5330ea-9934-4737-9ed6-e1d3dae2dfa4 102 | :END: 103 | Pass parameters to the program 104 | #+begin_src fortran :cmdline "23" :results silent 105 | character(len=255) :: cmd 106 | call get_command_argument(1, cmd) 107 | write (*,*) trim(cmd) 108 | #+end_src 109 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-broken.ly: -------------------------------------------------------------------------------- 1 | line 1 2 | line 2 3 | line 3 4 | line 4 5 | line 5 6 | line 6 7 | line 7 8 | line 8 9 | line 9 10 | line 10 11 | line 11 12 | line 12 13 | line 13 14 | line 14 15 | line 15 16 | line 16 17 | line 17 18 | line 18 19 | line 19 20 | line 20 21 | line 21 22 | line 22 23 | line 23 24 | line 24 25 | line 25 26 | line 26 27 | line 27 28 | line 28 29 | line 29 30 | line 30 31 | 32 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-broken.org: -------------------------------------------------------------------------------- 1 | * Faulty lilypond org file for test purposes (do not adjust) 2 | line 2 3 | line 3 4 | line 4 5 | line 5 6 | line 6 7 | line 7 8 | line 8 9 | line 9 10 | line 10 11 | line 11 12 | line 12 13 | line 13 14 | line 14 15 | line 15 16 | line 16 17 | line 17 18 | line 18 19 | line 19 20 | line 20 21 | line 21 22 | line 22 23 | line 23 24 | line 24 25 | line 25 26 | line 26 27 | line 27 28 | line 28 29 | line 29 30 | line 30 31 | line 31 32 | line 32 33 | line 33 34 | line 34 35 | line 35 36 | line 36 37 | line 37 38 | line 38 39 | line 39 40 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-test.error: -------------------------------------------------------------------------------- 1 | Processing `xxx' 2 | Parsing... 3 | /path/to/tangled/file/test.ly:25:0: error: syntax error, unexpected \score, expecting '=' 4 | 5 | \score { 6 | Interpreting music... [8][16][24][32] 7 | Preprocessing graphical objects... 8 | Interpreting music... 9 | MIDI output to `xxx' 10 | Finding the ideal number of pages... 11 | Fitting music on 2 or 3 pages... 12 | Drawing systems... 13 | Layout output to `xxx' 14 | Converting to `xxx'... 15 | error: failed files: "/Path/to/tangled/file/test.ly/example.ly" 16 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-test.ly: -------------------------------------------------------------------------------- 1 | 2 | % [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*LilyPond%2520Version][LilyPond-Version:1]] 3 | 4 | \version "2.12.3" 5 | 6 | % LilyPond-Version:1 ends here 7 | 8 | % [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*lilypond%2520block%2520for%2520test%2520purposes][lilypond-block-for-test-purposes:1]] 9 | 10 | \score { 11 | \relative c' { 12 | c8 d e f g a b c | 13 | b a g f e d c4 | 14 | } 15 | 16 | % lilypond-block-for-test-purposes:1 ends here 17 | 18 | % [[file:~/.emacs.d/martyn/martyn/ob-lilypond/test/test-build/test.org::*lilypond%2520block%2520for%2520test%2520purposes][lilypond-block-for-test-purposes:2]] 19 | 20 | \layout { 21 | } 22 | \midi { 23 | \context { 24 | \Score 25 | tempoWholesPerMinute = #(ly:make-moment 150 4) 26 | } 27 | } 28 | } 29 | 30 | % lilypond-block-for-test-purposes:2 ends here 31 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-test.org: -------------------------------------------------------------------------------- 1 | * Test org lilypond file 2 | 3 | This is a simple file for test purposes 4 | 5 | ** LilyPond Version 6 | 7 | #+begin_src lilypond 8 | 9 | \version "2.12.3" 10 | 11 | #+end_src 12 | 13 | ** DONE lilypond block for test purposes 14 | 15 | #+begin_src lilypond 16 | 17 | \score { 18 | \relative c' { 19 | c8 d e f g a b c | 20 | b a g f e d c4 | 21 | } 22 | 23 | #+end_src 24 | 25 | #+begin_src lilypond 26 | 27 | \layout { 28 | } 29 | \midi { 30 | \context { 31 | \Score 32 | tempoWholesPerMinute = #(ly:make-moment 150 4) 33 | } 34 | } 35 | } 36 | 37 | #+end_src 38 | -------------------------------------------------------------------------------- /testing/examples/ob-maxima-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-maxima tests 2 | #+OPTIONS: ^:nil 3 | 4 | * Simple tests 5 | :PROPERTIES: 6 | :ID: b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8 7 | :END: 8 | #+begin_src maxima :var s=4 :results silent 9 | print(s); 10 | #+end_src 11 | 12 | Pass a string 13 | #+begin_src maxima :var fun="sin(x)" :var q=2 :results silent 14 | print(diff(fun, x, q))$ 15 | #+end_src 16 | 17 | * Graphic output 18 | Graphic output 19 | #+begin_src maxima :var a=0.5 :results graphics :file maxima-test-sin.png 20 | plot2d(sin(a*x), [x, 0, 2*%pi])$ 21 | #+end_src 22 | 23 | #+begin_src maxima :results graphics :file maxima-test-3d.png 24 | plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2])$ 25 | #+end_src 26 | 27 | ** Use the ~draw~ package 28 | This test exercises the ~:graphics-pkg~ header argument. 29 | #+name: ob-maxima/draw 30 | #+begin_src maxima :var a=0.5 :results graphics file :file ./maxima-test-cos.png :graphics-pkg draw 31 | draw2d(explicit(cos(a*x), x, -%pi, %pi))$ 32 | #+end_src 33 | 34 | * Output to a file 35 | Output to a file 36 | #+begin_src maxima :file maxima-test-ouput.out 37 | for i:1 thru 10 do print(i)$ 38 | #+end_src 39 | * List input 40 | :PROPERTIES: 41 | :ID: b5561c6a-73cd-453a-ba5e-62ad84844de6 42 | :END: 43 | Simple list as an input 44 | #+begin_src maxima :var a=(list 1 2 3) :results silent :results verbatim 45 | print(a)$ 46 | #+end_src 47 | 48 | #+begin_src maxima :var a=(list 1 (list 1 2) 3) :results silent :results verbatim 49 | print(a+1); 50 | #+end_src 51 | 52 | * Table input 53 | :PROPERTIES: 54 | :ID: 400ee228-6b12-44fd-8097-7986f0f0db43 55 | :END: 56 | #+name: test_tbl_col 57 | | 1.0 | 58 | | 2.0 | 59 | 60 | #+name: test_tbl_row 61 | | 1.0 | 2.0 | 62 | 63 | #+begin_src maxima :var s=test_tbl_col :results silent :results verbatim 64 | print(s+1.0); 65 | #+end_src 66 | 67 | #+begin_src maxima :var s=test_tbl_row :results silent :results verbatim 68 | print(s+1.0); 69 | #+end_src 70 | 71 | Matrix 72 | #+name: test_tbl_mtr 73 | | 1.0 | 1.0 | 74 | 75 | #+begin_src maxima :var s=test_tbl_mtr :results silent :results verbatim 76 | ms: apply(matrix, s); 77 | print(ms); 78 | #+end_src 79 | 80 | * Construct a table from the output 81 | :PROPERTIES: 82 | :ID: cc158527-b867-4b1d-8ae0-b8c713a90fd7 83 | :END: 84 | #+begin_src maxima :results silent 85 | with_stdout("/dev/null", load(numericalio))$ 86 | m: genmatrix (lambda([i,j], i+j-1), 3, 3)$ 87 | write_data(m, "/dev/stdout")$ 88 | #+end_src 89 | 90 | * LaTeX output 91 | #+begin_src maxima :exports both :results latex :results verbatim 92 | assume(x>0); 93 | tex(ratsimp(diff(%e^(a*x), x))); 94 | #+end_src 95 | 96 | #+results: 97 | #+BEGIN_LaTeX 98 | $$a\,e^{a\,x}$$ 99 | #+END_LaTeX 100 | 101 | * Batch 102 | :PROPERTIES: 103 | :header-args:maxima: :exports both :results verbatim :batch batch 104 | :END: 105 | 106 | Exercise the ~:batch~ header argument. These tests are also defined in 107 | ~testing/lisp/test-ob-maxima.el~. The test name is name of the ~ert~ 108 | test. 109 | 110 | #+name: ob-maxima/batch+verbatim 111 | #+begin_src maxima 112 | (assume(z>0), 113 | integrate(exp(-t)*t^z, t, 0, inf)); 114 | #+end_src 115 | 116 | #+name: ob-maxima/batch+verbatim+quiet 117 | #+begin_src maxima :cmdline --quiet 118 | (assume(z>0), 119 | integrate(exp(-t)*t^z, t, 0, inf)); 120 | #+end_src 121 | 122 | #+name: ob-maxima/batch+verbatim+:lisp 123 | #+begin_src maxima :cmdline --quiet 124 | :lisp #$(assume(z>0),integrate(exp(-t)*t^z, t, 0, inf));#$ 125 | #+end_src 126 | 127 | #+name: ob-maxima/batch+verbatim+empty-string 128 | #+begin_src maxima :cmdline --quiet 129 | ""; 130 | #+end_src 131 | 132 | #+name: ob-maxima/batch+verbatim+whitespace-string 133 | #+begin_src maxima :cmdline --quiet 134 | " "; 135 | #+end_src 136 | 137 | #+name: ob-maxima/batch+verbatim+syntax-error 138 | #+begin_src maxima :cmdline --quiet 139 | ; 140 | #+end_src 141 | 142 | #+name: ob-maxima/batch+verbatim+eof-error 143 | #+begin_src maxima :cmdline --quiet 144 | x: 145 | #+end_src 146 | -------------------------------------------------------------------------------- /testing/examples/ob-octave-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-octave tests 2 | #+OPTIONS: ^:nil 3 | 4 | * Simple tests 5 | :PROPERTIES: 6 | :ID: 54dcd61d-cf6c-4d7a-b9e5-854953c8a753 7 | :END: 8 | Number output 9 | #+begin_src octave :exports results :results silent 10 | ans = 10 11 | #+end_src 12 | 13 | Array output 14 | #+begin_src octave :exports results :results silent 15 | ans = 1:4' 16 | #+end_src 17 | 18 | * Input tests 19 | :PROPERTIES: 20 | :ID: cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba 21 | :END: 22 | Input an integer variable 23 | #+begin_src octave :exports results :results silent :var s=42 24 | ans = s 25 | #+end_src 26 | 27 | Input an array 28 | #+begin_src octave :exports results :results silent :var s='(1.0 2.0 3.0) 29 | ans = s 30 | #+end_src 31 | 32 | Input a matrix 33 | #+begin_src octave :exports results :results silent :var s='((1 2) (3 4)) 34 | ans = s 35 | #+end_src 36 | 37 | Input a string 38 | #+begin_src octave :exports results :results silent :var s="test" 39 | ans = s(1:2) 40 | #+end_src 41 | 42 | Input elisp nil 43 | #+begin_src octave :exports results :results silent :var s='nil 44 | ans = s 45 | #+end_src 46 | 47 | 48 | * Graphical tests 49 | 50 | Graphics file. This test is performed by =ob-octave/graphics-file= in =testing/lisp/test-ob-octave.el=. 51 | #+begin_src octave :results file graphics :file sombrero.png 52 | sombrero; 53 | #+end_src 54 | 55 | Graphics file in a session. This test is performed by =ob-octave/graphics-file-session= in =testing/lisp/test-ob-octave.el=. 56 | #+begin_src octave :session :results graphics file :file sombrero.png 57 | sombrero; 58 | #+end_src 59 | 60 | Graphics file with a space in name. This test is performed by =ob-octave/graphics-file-space= in =testing/lisp/test-ob-octave.el=. 61 | #+begin_src octave :results graphics file :file sombrero hat.png 62 | sombrero; 63 | #+end_src 64 | -------------------------------------------------------------------------------- /testing/examples/ob-screen-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-screen tests 2 | #+begin_src screen :session create-tmpdir 3 | mkdir -p $TMPDIR 4 | cd $TMPDIR 5 | #+end_src 6 | -------------------------------------------------------------------------------- /testing/examples/ob-sed-test.org: -------------------------------------------------------------------------------- 1 | #+PROPERTY: results silent scalar 2 | #+Title: a collection of examples for ob-sed tests 3 | 4 | * Test simple execution of sed script 5 | :PROPERTIES: 6 | :ID: C7E7CA6A-2601-42C9-B534-4102D62E458D 7 | :END: 8 | 9 | #+NAME: ex1 10 | #+BEGIN_EXAMPLE 11 | An example sentence. 12 | #+END_EXAMPLE 13 | 14 | #+BEGIN_SRC sed :stdin ex1 15 | s/n example/ processed/ 16 | 2 d 17 | #+END_SRC 18 | 19 | * Test :in-file header argument 20 | :PROPERTIES: 21 | :ID: 54EC49AA-FE9F-4D58-812E-00FC87FAF562 22 | :END: 23 | 24 | #+BEGIN_SRC sed :in-file test1.txt 25 | s/test/tested/ 26 | #+END_SRC 27 | 28 | * Test :cmd-line header argument 29 | :PROPERTIES: 30 | :ID: E3C6A8BA-39FF-4840-BA8E-90D5C4365AB1 31 | :END: 32 | 33 | /Note:/ Use =-i.backup= instead of just =-i= because the BSD =sed=, 34 | unlike the GNU =sed=, requires =-i =. 35 | 36 | #+BEGIN_SRC sed :in-file test2.txt :cmd-line "-i.backup" 37 | s/test/tested again/ 38 | #+END_SRC 39 | -------------------------------------------------------------------------------- /testing/examples/org-exp.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for export tests 2 | #+OPTIONS: ^:nil 3 | 4 | * stripping commas from within blocks on export 5 | :PROPERTIES: 6 | :ID: 76d3a083-67fa-4506-a41d-837cc48158b5 7 | :END: 8 | The following commas should not be removed. 9 | 10 | #+begin_src r 11 | a <- c(1 12 | , 2 13 | , 3) 14 | #+end_src 15 | -------------------------------------------------------------------------------- /testing/examples/property-inheritance.org: -------------------------------------------------------------------------------- 1 | :PROPERTIES: 2 | :header-args: :var foo=1 3 | :header-args+: :var bar=2 4 | :END: 5 | 6 | #+begin_src emacs-lisp 7 | (+ foo bar) 8 | #+end_src 9 | 10 | * overwriting a file-wide property 11 | :PROPERTIES: 12 | :header-args: :var foo=7 13 | :END: 14 | 15 | #+begin_src emacs-lisp 16 | foo 17 | #+end_src 18 | 19 | * appending to a file-wide property 20 | :PROPERTIES: 21 | :header-args+: :var baz=3 22 | :END: 23 | 24 | #+begin_src emacs-lisp 25 | (+ foo bar baz) 26 | #+end_src 27 | 28 | -------------------------------------------------------------------------------- /testing/examples/pub-cache/config.org: -------------------------------------------------------------------------------- 1 | #+OPTIONS: author:nil 2 | 3 | This is included. 4 | -------------------------------------------------------------------------------- /testing/examples/pub-cache/source.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Test 2 | #+INCLUDE: config.org 3 | 4 | Nothing special 5 | -------------------------------------------------------------------------------- /testing/examples/pub-symlink/link.org: -------------------------------------------------------------------------------- 1 | Symlink 2 | -------------------------------------------------------------------------------- /testing/examples/pub/a.org: -------------------------------------------------------------------------------- 1 | #+title: A 2 | #+date: <2014-03-04 Tue> 3 | 4 | * Headline1 5 | :PROPERTIES: 6 | :CUSTOM_ID: a1 7 | :END: 8 | 9 | [[file:b.org::*Headline1]] 10 | -------------------------------------------------------------------------------- /testing/examples/pub/b.org: -------------------------------------------------------------------------------- 1 | #+title: b 2 | #+date: <2012-03-29 Thu> 3 | 4 | * Headline1 5 | :PROPERTIES: 6 | :CUSTOM_ID: b1 7 | :END: 8 | 9 | [[file:a.org::#a1]] 10 | -------------------------------------------------------------------------------- /testing/examples/pub/file.txt: -------------------------------------------------------------------------------- 1 | Text 2 | -------------------------------------------------------------------------------- /testing/examples/pub/index/file1.org: -------------------------------------------------------------------------------- 1 | #+title: File 1 2 | 3 | * Section on foo 4 | #+index: foo 5 | 6 | * Section on bar 7 | #+index: bar 8 | -------------------------------------------------------------------------------- /testing/examples/pub/index/file2.org: -------------------------------------------------------------------------------- 1 | #+title: File 2 2 | 3 | * Section on baz 4 | #+index: baz 5 | 6 | * Section on foo 7 | #+index: foo 8 | -------------------------------------------------------------------------------- /testing/examples/pub/link: -------------------------------------------------------------------------------- 1 | ../pub-symlink -------------------------------------------------------------------------------- /testing/examples/pub/noextension: -------------------------------------------------------------------------------- 1 | No extension -------------------------------------------------------------------------------- /testing/examples/pub/sub/c.org: -------------------------------------------------------------------------------- 1 | #+title: C 2 | #+date: <2013-03-20 Wed> 3 | -------------------------------------------------------------------------------- /testing/examples/setupfile.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: subdir/setupfile2.org 2 | -------------------------------------------------------------------------------- /testing/examples/setupfile3.org: -------------------------------------------------------------------------------- 1 | #+BIND: variable value 2 | #+DESCRIPTION: l2 3 | #+LANGUAGE: en 4 | #+SELECT_TAGS: b 5 | #+TITLE: b 6 | #+PROPERTY: a 1 7 | -------------------------------------------------------------------------------- /testing/examples/sub-bib/include-global-bib.org: -------------------------------------------------------------------------------- 1 | #+bibliography: /foo.bib 2 | -------------------------------------------------------------------------------- /testing/examples/sub-bib/include-relative-bib.org: -------------------------------------------------------------------------------- 1 | #+bibliography: ./foo.bib 2 | -------------------------------------------------------------------------------- /testing/examples/subdir/setupfile2.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: ../setupfile3.org 2 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-awk.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-awk.el --- tests for ob-awk.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov 4 | ;; Authors: Sergey Litvinov 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (org-test-for-executable "awk") 23 | (unless (featurep 'ob-awk) 24 | (signal 'missing-test-dependency '("Support for Awk code blocks"))) 25 | 26 | (ert-deftest ob-awk/input-none () 27 | "Test with no input file" 28 | (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a" 29 | (org-babel-next-src-block) 30 | (should (= 42 (org-babel-execute-src-block))))) 31 | 32 | (ert-deftest ob-awk/input-src-block-1 () 33 | "Test a code block as an input" 34 | (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a" 35 | (org-babel-next-src-block 2) 36 | (should (= 43 (org-babel-execute-src-block))))) 37 | 38 | (ert-deftest ob-awk/input-src-block-2 () 39 | "Test a code block as an input" 40 | (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a" 41 | (org-babel-next-src-block 3) 42 | (should (= 150 (org-babel-execute-src-block))))) 43 | 44 | (ert-deftest ob-awk/tabular-input () 45 | "Test a code block as an input" 46 | (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a" 47 | (org-babel-next-src-block 4) 48 | (should (equal '(("a" "b" "c")) (org-babel-execute-src-block))))) 49 | 50 | (provide 'test-ob-awk) 51 | ;;; test-ob-awk.el ends here 52 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-clojure.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-clojure.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2018-2025 Free Software Foundation, Inc. 4 | ;; Authors: stardiviner 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Comments: 22 | 23 | ;; Org tests for ob-clojure.el live here 24 | 25 | ;;; Code: 26 | 27 | (unless (featurep 'ob-clojure) 28 | (signal 'missing-test-dependency '("Support for Clojure code blocks"))) 29 | 30 | ;; FIXME: The old tests where totally off. We need to write new tests. 31 | 32 | (provide 'test-ob-clojure) 33 | 34 | ;;; test-ob-clojure.el ends here 35 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-comint.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-comint.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2024 Matthew Trzcinski 4 | ;; Authors: Matthew Trzcinski 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | 22 | ;;; Comment: 23 | 24 | ;; See testing/README for how to run tests. 25 | 26 | 27 | ;;; Requirements: 28 | 29 | 30 | ;;; Code: 31 | (ert-deftest test-org-babel-comint/prompt-filter-removes-prompt () 32 | "Test that prompt is actually removed." 33 | (let* ((prompt "org_babel_sh_prompt> ") 34 | (results "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' 35 | # print message 36 | echo \"hello world\" 37 | echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' 38 | ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 39 | org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" 40 | org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 41 | org_babel_sh_prompt> ")) 42 | (should (string= 43 | (org-trim (string-join (mapcar #'org-trim (org-babel-comint--prompt-filter results prompt)) "\n") "\n") 44 | "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' 45 | # print message 46 | echo \"hello world\" 47 | echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' 48 | ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 49 | \"hello world\" 50 | ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59")))) 51 | 52 | (ert-deftest test-org-babel-comint/echo-filter-removes-echo () 53 | "Test that echo is actually removed." 54 | (let* ((echo "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' 55 | # print message 56 | echo \"hello world\" 57 | echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'") 58 | (result "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59' 59 | # print message 60 | echo \"hello world\" 61 | echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59' 62 | ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 63 | org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" 64 | org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 65 | org_babel_sh_prompt> ")) 66 | (should (string= 67 | (org-babel-comint--echo-filter result echo) 68 | "\nob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59 69 | org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\" 70 | org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59 71 | org_babel_sh_prompt> ")))) 72 | 73 | (provide 'test-ob-comint) 74 | 75 | ;;; test-ob-comint.el ends here 76 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-eshell.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-eshell.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2018 stardiviner 4 | ;; Authors: stardiviner 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Comment: 22 | 23 | ;; Template test file for Org tests 24 | 25 | ;;; Code: 26 | (unless (featurep 'ob-eshell) 27 | (signal 'missing-test-dependency '("Support for Eshell code blocks"))) 28 | 29 | (ert-deftest ob-eshell/execute () 30 | "Test ob-eshell execute." 31 | (should 32 | (string= 33 | (org-test-with-temp-text 34 | "#+begin_src eshell 35 | echo 2 36 | #+end_src" 37 | (org-babel-execute-src-block) 38 | (goto-char (org-babel-where-is-src-block-result)) 39 | (forward-line) 40 | (buffer-substring-no-properties (point) (line-end-position))) 41 | ": 2"))) 42 | 43 | (ert-deftest ob-eshell/variables-assignment () 44 | "Test ob-eshell variables assignment." 45 | (should 46 | (string= 47 | (org-test-with-temp-text 48 | "#+begin_src eshell :var hi=\"hello, world\" 49 | echo $hi 50 | #+end_src" 51 | (org-babel-execute-src-block) 52 | (goto-char (org-babel-where-is-src-block-result)) 53 | (forward-line) 54 | (buffer-substring-no-properties (point) (line-end-position))) 55 | ": hello, world"))) 56 | 57 | (ert-deftest ob-eshell/session () 58 | "Test ob-eshell session." 59 | (should 60 | (string= 61 | (org-test-with-temp-text 62 | "#+begin_src eshell :session 63 | (setq hi \"hello, world\") 64 | #+end_src 65 | 66 | #+begin_src eshell :session 67 | echo $hi 68 | #+end_src" 69 | (org-babel-execute-src-block) 70 | (org-babel-next-src-block) 71 | (org-babel-execute-src-block) 72 | (goto-char (org-babel-where-is-src-block-result)) 73 | (forward-line) 74 | (buffer-substring-no-properties (point) (line-end-position))) 75 | ": hello, world"))) 76 | 77 | (provide 'test-ob-eshell) 78 | 79 | ;;; test-ob-eshell.el ends here 80 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-fortran.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-fortran.el --- tests for ob-fortran.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov 4 | ;; Authors: Sergey Litvinov 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (org-test-for-executable "gfortran") 23 | (unless (featurep 'ob-fortran) 24 | (signal 'missing-test-dependency '("Support for Fortran code blocks"))) 25 | 26 | (ert-deftest ob-fortran/simple-program () 27 | "Test of hello world program." 28 | (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" 29 | (org-babel-next-src-block) 30 | (should (equal "Hello world" (org-babel-execute-src-block))))) 31 | 32 | (ert-deftest ob-fortran/fortran-var-program () 33 | "Test a fortran variable" 34 | (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" 35 | (org-babel-next-src-block 2) 36 | (should (= 10 (org-babel-execute-src-block))))) 37 | 38 | (ert-deftest ob-fortran/input-var () 39 | "Test :var" 40 | (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 41 | (org-babel-next-src-block) 42 | (should (= 15 (org-babel-execute-src-block))))) 43 | 44 | (ert-deftest ob-fortran/preprocessor-var () 45 | "Test preprocessed fortran" 46 | (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 47 | (org-babel-next-src-block 2) 48 | (should (= 42 (org-babel-execute-src-block))))) 49 | 50 | (ert-deftest ob-fortran/character-var () 51 | "Test string input" 52 | (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 53 | (org-babel-next-src-block 3) 54 | (should (equal "word" (org-babel-execute-src-block))))) 55 | 56 | (ert-deftest ob-fortran/list-var () 57 | "Test real array input" 58 | (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465" 59 | (org-babel-next-src-block) 60 | (should (equal "1.00 2.00 3.00" (org-babel-execute-src-block))))) 61 | 62 | (ert-deftest ob-fortran/list-var-from-table () 63 | "Test real array from a table" 64 | (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465" 65 | (org-babel-next-src-block 2) 66 | (should (equal "1.00 2.00" (org-babel-execute-src-block))))) 67 | 68 | (ert-deftest ob-fortran/list-matrix-from-table1 () 69 | "Test real matrix from a table" 70 | (org-test-at-id "3f73ab19-d25a-428d-8c26-e8c6aa933976" 71 | (org-babel-next-src-block 1) 72 | (should (= 42 (org-babel-execute-src-block))))) 73 | 74 | (ert-deftest ob-fortran/list-matrix-from-table2 () 75 | "Test real matrix from a table" 76 | (org-test-at-id "3f73ab19-d25a-428d-8c26-e8c6aa933976" 77 | (org-babel-next-src-block 2) 78 | (should (= 42 (org-babel-execute-src-block))))) 79 | 80 | (ert-deftest ob-fortran/no-variables-with-main () 81 | "Test :var with explicit 'program'" 82 | (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 83 | (org-babel-next-src-block) 84 | (should-error (org-babel-execute-src-block)) 85 | :type 'error)) 86 | 87 | (ert-deftest ob-fortran/wrong-list () 88 | "Test wrong input list" 89 | (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 90 | (org-babel-next-src-block 2) 91 | (org-babel-execute-src-block) 92 | (when (should (buffer-live-p (get-buffer org-babel-error-buffer-name))) 93 | (kill-buffer org-babel-error-buffer-name)) 94 | :type 'error)) 95 | 96 | (ert-deftest ob-fortran/compiler-flags () 97 | "Test compiler's flags" 98 | (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 99 | (org-babel-next-src-block 3) 100 | (org-babel-execute-src-block) 101 | (when (should (buffer-live-p (get-buffer org-babel-error-buffer-name))) 102 | (kill-buffer org-babel-error-buffer-name)) 103 | :type 'error)) 104 | 105 | (ert-deftest ob-fortran/command-arguments () 106 | "Test real array from a table" 107 | (org-test-at-id "2d5330ea-9934-4737-9ed6-e1d3dae2dfa4" 108 | (org-babel-next-src-block) 109 | (should (= 23 (org-babel-execute-src-block))))) 110 | 111 | (provide 'test-ob-fortran) 112 | 113 | ;;; test-ob-fortran.el ends here 114 | 115 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-header-arg-defaults.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-header-arg-defaults.el --- tests for default header args from properties -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2013, 2014, 2019 Achim Gratz 4 | ;; Authors: Achim Gratz 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | 23 | (ert-deftest test-ob-header-arg-defaults/global/call () 24 | (org-test-at-id "3fdadb69-5d15-411e-aad0-f7860cdd7816" 25 | (org-babel-next-src-block 1) 26 | (forward-line -1) 27 | (should (equal "ge1/gh2/--3/ge4/ge5/--6/--7/--8/--9" 28 | (org-babel-execute-src-block nil (org-babel-lob-get-info)))))) 29 | 30 | (ert-deftest test-ob-header-arg-defaults/global/noweb () 31 | (org-test-at-id "3fdadb69-5d15-411e-aad0-f7860cdd7816" 32 | (org-babel-next-src-block 1) 33 | (should (equal "ge1/gh2/--3/ge4/ge5/--6/--7" 34 | (org-babel-execute-src-block))))) 35 | 36 | (ert-deftest test-ob-header-arg-defaults/tree/overwrite/call () 37 | (should 38 | (equal "ge1/gh2/--3/ge4/ge5/--6/th7/te8/--9" 39 | (org-test-at-id "a9cdfeda-9f31-4bb5-b694-2cf452f07dfd" 40 | (org-babel-next-src-block 1) 41 | (forward-line -1) 42 | (org-babel-execute-src-block nil (org-babel-lob-get-info)))))) 43 | 44 | (ert-deftest test-ob-header-arg-defaults/tree/overwrite/noweb () 45 | (should 46 | (equal "--1/--2/--3/--4/--5/--6/th7/te8/--9" 47 | (org-test-at-id "a9cdfeda-9f31-4bb5-b694-2cf452f07dfd" 48 | (org-babel-next-src-block 1) 49 | (org-babel-execute-src-block))))) 50 | 51 | (ert-deftest test-ob-header-arg-defaults/tree/accumulate/call () 52 | (should 53 | (equal "ge1/th2/th3/ge4/te5/--6" 54 | (org-test-at-id "1d97d258-fd50-4107-a095-e4625bffc57b" 55 | (org-babel-next-src-block 1) 56 | (forward-line -1) 57 | (org-babel-execute-src-block nil (org-babel-lob-get-info)))))) 58 | 59 | (ert-deftest test-ob-header-arg-defaults/tree/accumulate/noweb () 60 | (should 61 | (equal "ge1/th2/th3/ge4/te5/--6/--7/--8" 62 | (org-test-at-id "1d97d258-fd50-4107-a095-e4625bffc57b" 63 | (org-babel-next-src-block 1) 64 | (org-babel-execute-src-block))))) 65 | 66 | (ert-deftest test-ob-header-arg-defaults/tree/complex/call () 67 | (should 68 | (equal "gh1/th2/--3/gh4/te5/--6" 69 | (org-test-at-id "fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2" 70 | (org-babel-next-src-block 1) 71 | (forward-line -1) 72 | (org-babel-execute-src-block nil (org-babel-lob-get-info)))))) 73 | 74 | (ert-deftest test-ob-header-arg-defaults/tree/complex/noweb () 75 | (should 76 | (equal "gh1/th2/--3/gh4/te5/--6/--7/--8/--9" 77 | (org-test-at-id "fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2" 78 | (org-babel-next-src-block 1) 79 | (org-babel-execute-src-block))))) 80 | 81 | (provide 'test-ob-header-arg-defaults) 82 | 83 | ;;; test-ob-header-arg-defaults.el ends here 84 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-perl.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-perl.el --- tests for ob-perl.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2013, 2014, 2019 Achim Gratz 4 | ;; Authors: Achim Gratz 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (org-test-for-executable "perl") 23 | (unless (featurep 'ob-perl) 24 | (signal 'missing-test-dependency '("Support for perl code blocks"))) 25 | 26 | (ert-deftest test-ob-perl/simple-output () 27 | (org-test-with-temp-text " 28 | #+header: :results output 29 | #+begin_src perl 30 | print qq(Hi Mom!$/I'm home.); 31 | #+end_src" 32 | (org-babel-next-src-block) 33 | (should (equal "Hi Mom!\nI'm home." 34 | (org-babel-execute-src-block))))) 35 | 36 | (ert-deftest test-ob-perl/simple-value () 37 | (org-test-with-temp-text " 38 | #+header: :results value 39 | #+begin_src perl 40 | qq(Hi Mom!$/I'm home.); 41 | #+end_src" 42 | (org-babel-next-src-block) 43 | (should (equal '(("Hi Mom!") ("I'm home.")) 44 | (org-babel-execute-src-block))))) 45 | 46 | (ert-deftest test-ob-perl/table-passthrough-colnames-nil () 47 | (org-test-with-temp-text "#+name: eg 48 | | col1 | col2 | 49 | |------+------| 50 | | a | 1 | 51 | | b | 2.0 | 52 | 53 | #+header: :colnames nil 54 | #+header: :var x = eg 55 | #+begin_src perl 56 | #+end_src" 57 | (org-babel-next-src-block) 58 | (should (equal '(("col1" "col2") hline ("a" 1) ("b" 2.0)) 59 | (org-babel-execute-src-block))))) 60 | 61 | (ert-deftest test-ob-perl/table-passthrough-colnames-no () 62 | (org-test-with-temp-text "#+name: eg 63 | | col1 | col2 | 64 | |------+------| 65 | | a | 1 | 66 | | b | 2.0 | 67 | 68 | #+header: :colnames no 69 | #+header: :var x = eg 70 | #+begin_src perl 71 | #+end_src" 72 | (org-babel-next-src-block) 73 | (should (equal '(("col1" "col2") ("a" 1) ("b" 2.0)) 74 | (org-babel-execute-src-block))))) 75 | 76 | (provide 'test-ob-perl) 77 | 78 | ;;; test-ob-perl.el ends here 79 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-plantuml.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-plantuml.el --- tests for ob-plantuml.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2016, 2019 Thibault Marin 4 | ;; Authors: Thibault Marin 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (require 'ob-plantuml) 23 | 24 | (ert-deftest test-ob-plantuml/single-var () 25 | "Test file output with input variable." 26 | (should 27 | (string= 28 | "@startuml 29 | !define CLASSNAME test_class 30 | class CLASSNAME 31 | @enduml" 32 | (let ((org-plantuml-jar-path nil)) 33 | (org-test-with-temp-text 34 | "#+name: variable_value 35 | : test_class 36 | 37 | #+header: :file tmp.puml 38 | #+header: :var CLASSNAME=variable_value 39 | #+begin_src plantuml 40 | class CLASSNAME 41 | #+end_src" 42 | (org-babel-next-src-block) 43 | (let ((src-block-info (cdr (org-babel-get-src-block-info)))) 44 | (org-babel-plantuml-make-body 45 | (car src-block-info) 46 | (car (cdr src-block-info))))))))) 47 | 48 | 49 | (ert-deftest test-ob-plantuml/prologue () 50 | "Test file output with prologue." 51 | (should 52 | (string= 53 | "@startuml 54 | skinparam classBackgroundColor #FF0000 55 | class test_class 56 | @enduml" 57 | (let ((org-plantuml-jar-path nil)) 58 | (org-test-with-temp-text 59 | "#+header: :file tmp.puml 60 | #+header: :prologue skinparam classBackgroundColor #FF0000 61 | #+begin_src plantuml 62 | class test_class 63 | #+end_src" 64 | (org-babel-next-src-block) 65 | (let ((src-block-info (cdr (org-babel-get-src-block-info)))) 66 | (org-babel-plantuml-make-body 67 | (car src-block-info) 68 | (car (cdr src-block-info))))))))) 69 | 70 | (provide 'test-ob-plantuml) 71 | 72 | ;;; test-ob-plantuml.el ends here 73 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-ruby.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-ruby.el --- tests for ob-ruby.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2013-2015, 2019 Oleh Krehel 4 | ;; Authors: Oleh Krehel 5 | 6 | ;; This program is free software; you can redistribute it and/or modify 7 | ;; it under the terms of the GNU General Public License as published by 8 | ;; the Free Software Foundation, either version 3 of the License, or 9 | ;; (at your option) any later version. 10 | 11 | ;; This program is distributed in the hope that it will be useful, 12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;; GNU General Public License for more details. 15 | 16 | ;; You should have received a copy of the GNU General Public License 17 | ;; along with this program. If not, see . 18 | 19 | ;;; Code: 20 | (org-test-for-executable "ruby") 21 | (unless (featurep 'ob-ruby) 22 | (signal 'missing-test-dependency '("Support for Ruby code blocks"))) 23 | (unless (featurep 'inf-ruby) 24 | (signal 'missing-test-dependency '("inf-ruby"))) 25 | 26 | (ert-deftest test-ob-ruby/session-output-1 () 27 | (should (equal (org-test-with-temp-text "#+begin_src ruby :session org-test-ruby :results output 28 | s = \"1\" 29 | s = \"2\" 30 | s = \"3\" 31 | puts s 32 | s = \"4\" 33 | #+end_src" 34 | (org-babel-execute-maybe) 35 | (substring-no-properties 36 | (buffer-string))) 37 | "#+begin_src ruby :session org-test-ruby :results output 38 | s = \"1\" 39 | s = \"2\" 40 | s = \"3\" 41 | puts s 42 | s = \"4\" 43 | #+end_src 44 | 45 | #+RESULTS: 46 | : 3 47 | "))) 48 | (ert-deftest test-ob-ruby/session-output-2 () 49 | (should (equal (org-test-with-temp-text "#+begin_src ruby :session org-test-ruby :results output 50 | puts s 51 | s = \"5\" 52 | #+end_src" 53 | (org-babel-execute-maybe) 54 | (substring-no-properties 55 | (buffer-string))) 56 | "#+begin_src ruby :session org-test-ruby :results output 57 | puts s 58 | s = \"5\" 59 | #+end_src 60 | 61 | #+RESULTS: 62 | : 4 63 | "))) 64 | (ert-deftest test-ob-ruby/session-output-3 () 65 | (should (equal (org-test-with-temp-text "#+begin_src ruby :session org-test-ruby :results output 66 | puts s 67 | s = \"6\" 68 | #+end_src" 69 | (org-babel-execute-maybe) 70 | (substring-no-properties 71 | (buffer-string))) 72 | "#+begin_src ruby :session org-test-ruby :results output 73 | puts s 74 | s = \"6\" 75 | #+end_src 76 | 77 | #+RESULTS: 78 | : 5 79 | "))) 80 | 81 | (provide 'test-ob-ruby) 82 | 83 | ;;; test-ob-ruby.el ends here 84 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-scheme.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-scheme.el --- Tests for Babel scheme -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017, 2019 Nicolas Goaziou 4 | 5 | ;; Author: Nicolas Goaziou 6 | 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | 22 | ;; Unit tests for Org Babel Scheme. 23 | 24 | ;;; Code: 25 | 26 | (unless (featurep 'ob-scheme) 27 | (signal 'missing-test-dependency '("Support for Scheme code blocks"))) 28 | (unless (featurep 'geiser) 29 | (signal 'missing-test-dependency '("geiser"))) 30 | (unless (version<= "27.1" emacs-version) 31 | (signal 'missing-test-dependency '("Geiser required for Scheme code blocks needs Emacs >=27.1"))) 32 | 33 | (ert-deftest test-ob-scheme/tables () 34 | "Test table output." 35 | (equal "#+begin_src scheme 36 | '(1 2 3) 37 | #+end_src 38 | 39 | #+RESULTS: 40 | | 1 | 2 | 3 | 41 | " 42 | (org-test-with-temp-text "#+begin_src scheme\n'(1 2 3)\n#+end_src" 43 | (org-babel-execute-maybe) 44 | (buffer-string)))) 45 | 46 | (ert-deftest test-ob-scheme/verbatim () 47 | "Test verbatim output." 48 | (should 49 | (equal ": (1 2 3)\n" 50 | (org-test-with-temp-text "#+begin_src scheme :results verbatim\n'(1 2 3)\n#+end_src" 51 | (org-babel-execute-src-block) 52 | (let ((case-fold-search t)) (search-forward "#+results")) 53 | (buffer-substring-no-properties (line-beginning-position 2) 54 | (point-max)))))) 55 | 56 | (ert-deftest test-ob-scheme/list () 57 | "Test list output." 58 | (should 59 | (equal "- 1\n- 2\n- 3\n" 60 | (org-test-with-temp-text "#+begin_src scheme :results list\n'(1 2 3)\n#+end_src" 61 | (org-babel-execute-maybe) 62 | (let ((case-fold-search t)) (search-forward "#+results")) 63 | (buffer-substring-no-properties (line-beginning-position 2) 64 | (point-max)))))) 65 | 66 | (ert-deftest test-ob-scheme/prologue () 67 | "Test :prologue parameter." 68 | (should 69 | (equal "#+begin_src scheme :prologue \"(define x 2)\" 70 | x 71 | #+end_src 72 | 73 | #+RESULTS: 74 | : 2 75 | " 76 | (org-test-with-temp-text 77 | "#+begin_src scheme :prologue \"(define x 2)\"\nx\n#+end_src" 78 | (org-babel-execute-maybe) 79 | (buffer-string)))) 80 | (should 81 | (equal 82 | "#+begin_src scheme :prologue \"(define x 2)\" :var y=1 83 | x 84 | #+end_src 85 | 86 | #+RESULTS: 87 | : 2 88 | " 89 | (org-test-with-temp-text 90 | "#+begin_src scheme :prologue \"(define x 2)\" :var y=1\nx\n#+end_src" 91 | (org-babel-execute-maybe) 92 | (buffer-string))))) 93 | 94 | (ert-deftest test-ob-scheme/unspecified () 95 | "Test <#unspecified> return value." 96 | (should 97 | (equal "#+begin_src scheme 98 | \(define (mysquare x) 99 | (* x x)) 100 | #+end_src 101 | 102 | #+RESULTS: 103 | : # 104 | " 105 | (org-test-with-temp-text 106 | "#+begin_src scheme 107 | (define (mysquare x) 108 | (* x x)) 109 | #+end_src" 110 | (org-babel-execute-maybe) 111 | (buffer-string))))) 112 | 113 | 114 | (provide 'test-ob-scheme) 115 | ;;; test-ob-scheme.el ends here 116 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-sed.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-sed.el --- tests for ob-sed.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2015, 2019 Bjarte Johansen 4 | ;; Authors: Bjarte Johansen 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | 23 | (require 'ob-sed) 24 | (org-test-for-executable "sed") 25 | (unless (featurep 'ob-sed) 26 | (signal 'missing-test-dependency '("Support for Sed code blocks"))) 27 | 28 | (ert-deftest ob-sed-test/simple-execution-of-script () 29 | "Test simple execution of script." 30 | (org-test-at-id "C7E7CA6A-2601-42C9-B534-4102D62E458D" 31 | (org-babel-next-src-block) 32 | (should (string= "A processed sentence." 33 | (org-babel-execute-src-block))))) 34 | 35 | (ert-deftest ob-sed-test/in-file-header-argument () 36 | "Test :in-file header argument." 37 | (org-test-at-id "54EC49AA-FE9F-4D58-812E-00FC87FAF562" 38 | (let ((default-directory temporary-file-directory)) 39 | (with-temp-buffer 40 | (insert "A test file.") 41 | (write-file "test1.txt")) 42 | (org-babel-next-src-block) 43 | (should (string= "A tested file." 44 | (org-babel-execute-src-block)))))) 45 | 46 | (ert-deftest ob-sed-test/cmd-line-header-argument () 47 | "Test :cmd-line header argument." 48 | (org-test-at-id "E3C6A8BA-39FF-4840-BA8E-90D5C4365AB1" 49 | (let ((default-directory temporary-file-directory)) 50 | (with-temp-buffer 51 | (insert "A test file.") 52 | (write-file "test2.txt")) 53 | (org-babel-next-src-block) 54 | (org-babel-execute-src-block) 55 | (should (string= "A tested again file.\n" 56 | (with-temp-buffer 57 | (insert-file-contents "test2.txt") 58 | (buffer-string))))))) 59 | 60 | 61 | (provide 'test-ob-sed) 62 | ;;; test-ob-sed ends here 63 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-sqlite.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-sqlite.el --- tests for ob-sqlite.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017, 2019 Eduardo Bellani 4 | 5 | ;; Author: Eduardo Bellani 6 | ;; Keywords: lisp 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (org-test-for-executable "sqlite3") 23 | (unless (featurep 'ob-sqlite) 24 | (signal 'missing-test-dependency '("Support for sqlite code blocks"))) 25 | 26 | (ert-deftest ob-sqlite/table-variables-with-commas () 27 | "Test of a table variable that contains commas. This guarantees that this code path results in a valid CSV." 28 | (should 29 | (equal '(("Mr Test A. Sql" 30 | "Minister for Science, Eternal Happiness, and Finance")) 31 | (org-test-with-temp-text 32 | "#+name: test_table1 33 | | \"Mr Test A. Sql\" | Minister for Science, Eternal Happiness, and Finance | 34 | 35 | #+begin_src sqlite :db /tmp/test.db :var tb=test_table1 36 | drop table if exists TestTable; 37 | create table TestTable(person, job); 38 | .mode csv TestTable 39 | .import $tb TestTable 40 | select * from TestTable; 41 | #+end_src" 42 | (org-babel-next-src-block) 43 | (org-babel-execute-src-block))))) 44 | 45 | (ert-deftest ob-sqlite/in-memory () 46 | "Test in-memory temporariness." 47 | (should 48 | (equal 0 49 | (progn 50 | (org-test-with-temp-text 51 | "#+BEGIN_SRC sqlite 52 | PRAGMA user_version = 1; 53 | #+END_SRC" 54 | (org-babel-execute-src-block)) 55 | (org-test-with-temp-text 56 | "#+BEGIN_SRC sqlite 57 | PRAGMA user_version; 58 | #+END_SRC" 59 | (org-babel-execute-src-block)))))) 60 | 61 | (ert-deftest ob-sqlite/in-file () 62 | "Test in-file permanency." 63 | (should 64 | (equal 1 65 | (let ((file (org-babel-temp-file "test" ".sqlite"))) 66 | (org-test-with-temp-text 67 | (format "#+BEGIN_SRC sqlite :db %s 68 | PRAGMA user_version = 1; 69 | #+END_SRC" file) 70 | (org-babel-execute-src-block)) 71 | (org-test-with-temp-text 72 | (format "#+BEGIN_SRC sqlite :db %s 73 | PRAGMA user_version; 74 | #+END_SRC" file) 75 | (org-babel-execute-src-block)))))) 76 | 77 | (provide 'test-ob-sqlite) 78 | ;;; test-ob-sqlite.el ends here 79 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-table.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-table.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2011-2014, 2019 Eric Schulte 4 | ;; Authors: Eric Schulte 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Comments: 22 | 23 | ;; Template test file for Org tests 24 | 25 | ;;; Code: 26 | 27 | (ert-deftest test-ob-table/sbe () 28 | "Test that `sbe' can be used to call code blocks from inside tables." 29 | (org-test-with-temp-text 30 | "#+name: take-sqrt 31 | #+begin_src emacs-lisp :var n=9 32 | (sqrt n) 33 | #+end_src" 34 | ;; Symbol src block name. 35 | (should (equal "2.0" (org-sbe take-sqrt (n "4")))) 36 | ;; String src block name. 37 | (should (equal "2.0" (org-sbe "take-sqrt" (n "4"))))) 38 | (org-test-with-temp-text 39 | "#+name: identity 40 | #+begin_src emacs-lisp :var x=1 41 | x 42 | #+end_src" 43 | ;; Escape quotes. 44 | (should 45 | (equal "123°34'23.34\"otherthing" 46 | (org-sbe identity (x $"123°34'23.34\"otherthing")))))) 47 | 48 | (provide 'test-ob-table) 49 | 50 | ;;; test-ob-table.el ends here 51 | -------------------------------------------------------------------------------- /testing/lisp/test-ol-bbdb.el: -------------------------------------------------------------------------------- 1 | ;;; test-ol-bbdb.el --- tests for ol-bbdb.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2018, 2019 Marco Wahl 4 | 5 | ;; Author: 6 | ;; Keywords: calendar 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Commentary: 22 | 23 | ;; Test some of ol-bbdb.el. 24 | 25 | ;;; Code: 26 | 27 | (require 'ol-bbdb) 28 | 29 | (ert-deftest test-org-bbdb-anniv-extract-date () 30 | (should (equal nil (org-bbdb-anniv-extract-date "foo"))) 31 | (should (equal '(9 22 2018) (org-bbdb-anniv-extract-date "2018-09-22"))) 32 | (should (equal '(9 22 nil) (org-bbdb-anniv-extract-date "09-22")))) 33 | 34 | (provide 'test-ol-bbdb) 35 | 36 | ;;; test-org-bbdb.el ends here 37 | -------------------------------------------------------------------------------- /testing/lisp/test-org-attach-git.el: -------------------------------------------------------------------------------- 1 | ;;; test-org-attach-git.el --- Tests for Org Attach with git-annex -*- lexical-binding: t; -*- 2 | ;; 3 | ;; Copyright (c) 2016, 2019 Erik Hetzner 4 | ;; Authors: Erik Hetzner 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (org-test-for-executable "git-annex") 23 | (require 'org-attach-git) 24 | (require 'cl-lib) 25 | 26 | (defmacro test-org-attach-git/with-annex (&rest body) 27 | `(let ((tmpdir (make-temp-file "org-annex-test" t "/"))) 28 | (unwind-protect 29 | (let ((default-directory tmpdir) 30 | (org-attach-id-dir tmpdir)) 31 | ;; Ignore global git config. 32 | (with-environment-variables 33 | (("GIT_CONFIG_GLOBAL" (concat tmpdir ".global-config")) 34 | ("GIT_CONFIG_SYSTEM" "")) 35 | ;; Otherwise, some git operations may err. 36 | (shell-command "git config --global user.email \"john.doe@example.com\"") 37 | (shell-command "git config --global user.name \"John Doe\"") 38 | (shell-command "git init") 39 | (shell-command "git annex init") 40 | ,@body))))) 41 | 42 | (ert-deftest test-org-attach-git/use-annex () 43 | (test-org-attach-git/with-annex 44 | (let ((org-attach-git-annex-cutoff 1)) 45 | (should (org-attach-git-use-annex))) 46 | 47 | (let ((org-attach-git-annex-cutoff nil)) 48 | (should-not (org-attach-git-use-annex)))) 49 | 50 | ;; test with non annex directory 51 | (let ((tmpdir (make-temp-file "org-annex-test" t "/"))) 52 | (unwind-protect 53 | (let ((default-directory tmpdir) 54 | (org-attach-id-dir tmpdir)) 55 | (shell-command "git init") 56 | (should-not (org-attach-git-use-annex))) 57 | (delete-directory tmpdir 'recursive)))) 58 | 59 | (ert-deftest test-org-attach-git/get-maybe () 60 | (test-org-attach-git/with-annex 61 | (let ((path (expand-file-name "test-file")) 62 | (annex-dup (make-temp-file "org-annex-test" t "/"))) 63 | (with-temp-buffer 64 | (insert "hello world\n") 65 | (write-file path)) 66 | (shell-command "git annex add test-file") 67 | (shell-command "git annex sync") 68 | ;; Set up remote & copy files there 69 | (let ((annex-original default-directory) 70 | (default-directory annex-dup)) 71 | (shell-command (format "git clone %s ." (shell-quote-argument annex-original))) 72 | (shell-command "git annex init dup") 73 | (shell-command (format "git remote add original %s" (shell-quote-argument annex-original))) 74 | (shell-command "git annex get test-file") 75 | (shell-command "git annex sync")) 76 | (shell-command (format "git remote add dup %s" (shell-quote-argument annex-dup))) 77 | (shell-command "git annex sync") 78 | (shell-command "git annex drop --force test-file") 79 | ;; test getting the file from the dup when we should ALWAYS get 80 | (should (not (file-exists-p (file-symlink-p (expand-file-name "test-file"))))) 81 | (let ((org-attach-git-annex-auto-get t)) 82 | (org-attach-git-annex-get-maybe (expand-file-name "test-file")) 83 | ;; check that the file has the right contents 84 | (with-temp-buffer 85 | (insert-file-contents path) 86 | (should (string-equal "hello world\n" (buffer-string))))) 87 | ;; test getting the file from the dup when we should NEVER get 88 | (shell-command "git annex drop --force test-file") 89 | (let ((org-attach-git-annex-auto-get nil)) 90 | (should-error (org-attach-git-annex-get-maybe (expand-file-name "test-file")))) 91 | (let ((org-attach-git-annex-auto-get 'ask) 92 | (called nil)) 93 | (cl-letf (((symbol-function 'y-or-n-p) 94 | (lambda (_) (setq called 'was-called) t))) 95 | (org-attach-git-annex-get-maybe (expand-file-name "test-file")) 96 | ;; check that the file has the right contents 97 | (with-temp-buffer 98 | (insert-file-contents path) 99 | (should (string-equal "hello world\n" (buffer-string)))) 100 | (should (eq called 'was-called))))))) 101 | 102 | (provide 'test-org-attach-git) 103 | ;;; test-org-attach-git.el ends here 104 | -------------------------------------------------------------------------------- /testing/lisp/test-org-feed.el: -------------------------------------------------------------------------------- 1 | ;;; test-org-feed.el --- Tests for org-feed.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2016, 2019 Michael Brand 4 | 5 | ;; Author: Michael Brand 6 | 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | 22 | ;; Unit tests for Org Feed library. 23 | 24 | ;;; Code: 25 | 26 | (require 'org-feed) 27 | 28 | (ert-deftest test-org-feed/fill-template () 29 | "Test `org-feed-format-entry' template specifications." 30 | 31 | ;; When working on these tests consider to also change 32 | ;; `test-org-capture/fill-template'. 33 | 34 | ;; %(sexp) placeholder. 35 | (should 36 | (equal "success!" 37 | (org-feed-format-entry nil "%(concat \"success\" \"!\")" nil))) 38 | ;; %a placeholder. 39 | (should 40 | (equal "[[https://orgmode.org]]\n" 41 | (org-feed-format-entry '(:link "https://orgmode.org") "%a" nil))) 42 | ;; %t and %T placeholders. 43 | (should 44 | (equal (format-time-string (org-time-stamp-format nil nil)) 45 | (org-feed-format-entry nil "%t" nil))) 46 | (should 47 | (string-match-p 48 | "<2016-01-02 \\S-+>" 49 | (org-feed-format-entry 50 | '(:pubDate "Sat, 02 Jan 2016 12:00:00 +0000") "%t" nil))) 51 | (should 52 | (equal (format-time-string (org-time-stamp-format t nil)) 53 | (org-feed-format-entry nil "%T" nil))) 54 | (should 55 | (string-match-p 56 | "<2016-01-02 \\S-+ 12:00>" 57 | (org-feed-format-entry 58 | '(:pubDate "Sat, 02 Jan 2016 12:00:00 +0000") "%T" nil))) 59 | ;; %u and %U placeholders. 60 | (should 61 | (equal (format-time-string (org-time-stamp-format nil t)) 62 | (org-feed-format-entry nil "%u" nil))) 63 | (should 64 | (string-match-p 65 | "[2016-01-02 \\S-+]" 66 | (org-feed-format-entry 67 | '(:pubDate "Sat, 02 Jan 2016 12:00:00 +0000") "%u" nil))) 68 | (should 69 | (equal (format-time-string (org-time-stamp-format t t)) 70 | (org-feed-format-entry nil "%U" nil))) 71 | (should 72 | (string-match-p 73 | "[2016-01-02 \\S-+ 12:00]" 74 | (org-feed-format-entry 75 | '(:pubDate "Sat, 02 Jan 2016 12:00:00 +0000") "%U" nil))) 76 | ;; %h placeholder. Make sure sexp placeholders are not expanded 77 | ;; when they are inserted through this one. 78 | (should 79 | (equal "success!" 80 | (org-feed-format-entry '(:title "success!") "%h" nil))) 81 | (should 82 | (equal "%(concat \"no \" \"evaluation\")" 83 | (org-feed-format-entry 84 | '(:title "%(concat \"no \" \"evaluation\")") "%h" nil))) 85 | ;; Test %-escaping with \ character. 86 | (should 87 | (equal "%h" 88 | (org-feed-format-entry '(:title "success!") "\\%h" nil))) 89 | (should 90 | (equal "\\success!" 91 | (org-feed-format-entry '(:title "success!") "\\\\%h" nil))) 92 | (should 93 | (equal "\\%h" 94 | (org-feed-format-entry '(:title "success!") "\\\\\\%h" nil))) 95 | ;; More than one placeholder in the same template. 96 | (should 97 | (equal "success! success! success! success!" 98 | (org-feed-format-entry '(:title "success!") "%h %h %h %h" nil))) 99 | ;; %(sexp) placeholder with an input containing the traps %, ", ) 100 | ;; and \n all at once which is complicated to parse. 101 | (should 102 | (equal 103 | "5 % Less (See\n Item \"3)\" Somewhere)" 104 | (org-feed-format-entry 105 | '(:title "5 % less (see\n item \"3)\" somewhere)") 106 | "%(capitalize \"%h\")" nil)))) 107 | 108 | 109 | 110 | 111 | (provide 'test-org-feed) 112 | ;;; test-org-feed.el ends here 113 | -------------------------------------------------------------------------------- /testing/lisp/test-org-inlinetask.el: -------------------------------------------------------------------------------- 1 | ;;; test-org-inlinetask.el --- Tests for org-inlinetask.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) Marco Wahl 4 | ;; Authors: Marco Wahl 5 | 6 | ;; This program is free software; you can redistribute it and/or modify 7 | ;; it under the terms of the GNU General Public License as published by 8 | ;; the Free Software Foundation, either version 3 of the License, or 9 | ;; (at your option) any later version. 10 | 11 | ;; This program is distributed in the hope that it will be useful, 12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;; GNU General Public License for more details. 15 | 16 | ;; You should have received a copy of the GNU General Public License 17 | ;; along with this program. If not, see . 18 | 19 | ;;; Comments: 20 | 21 | ;; Tests for org-inlinetask.el. 22 | 23 | ;;; Code: 24 | 25 | (require 'org-inlinetask) 26 | 27 | 28 | ;;; Test movement 29 | 30 | (ert-deftest test-org-inlinetask/org-inlinetask-goto-end () 31 | ;; Goto end. 32 | (should 33 | (equal 34 | (let ((org-inlinetask-min-level 5) 35 | (org-adapt-indentation t)) 36 | (org-test-with-temp-text 37 | "** H 38 | ***** I 39 | ***** END 40 | foo" 41 | (org-inlinetask-goto-end) 42 | (insert "") 43 | (buffer-string))) 44 | "** H 45 | ***** I 46 | ***** END 47 | foo")) 48 | 49 | ;; Goto end. End is buffer end. 50 | (should 51 | (equal 52 | (let ((org-inlinetask-min-level 5) 53 | (org-adapt-indentation t)) 54 | (org-test-with-temp-text 55 | "** H 56 | ***** I 57 | ***** END" 58 | (org-inlinetask-goto-end) 59 | (insert "") 60 | (buffer-string))) 61 | "** H 62 | ***** I 63 | ***** END")) 64 | 65 | ;; Goto end. Starting somewhere. 66 | (should 67 | (equal 68 | (let ((org-inlinetask-min-level 5) 69 | (org-adapt-indentation t)) 70 | (org-test-with-temp-text 71 | "** H 72 | ***** I 73 | ***** END 74 | ***** I 75 | ***** END" 76 | (org-inlinetask-goto-end) 77 | (insert "") 78 | (buffer-string))) 79 | "** H 80 | ***** I 81 | ***** END 82 | ***** I 83 | ***** END")) 84 | 85 | (should 86 | (equal 87 | (let ((org-inlinetask-min-level 5) 88 | (org-adapt-indentation t)) 89 | (org-test-with-temp-text 90 | "** H 91 | ***** I 92 | inside 93 | ***** END 94 | ***** I 95 | ***** END" 96 | (org-inlinetask-goto-end) 97 | (insert "") 98 | (buffer-string))) 99 | "** H 100 | ***** I 101 | inside 102 | ***** END 103 | ***** I 104 | ***** END"))) 105 | 106 | (ert-deftest test-org-inlinetask/inlinetask-within-plain-list () 107 | "Fold inlinetasks in plain-lists. 108 | Report: 109 | http://lists.gnu.org/archive/html/emacs-orgmode/2017-12/msg00502.html" 110 | (should 111 | (org-test-with-temp-text 112 | "* Test 113 | - x 114 | - a 115 | *************** List folding stopped here 116 | *************** END 117 | - b 118 | " 119 | (org-cycle-internal-local) 120 | (invisible-p (1- (search-forward "- b")))))) 121 | 122 | (ert-deftest test-org-inlinetask/folding-directly-consecutive-tasks/0 () 123 | "Fold directly consecutive inlinetasks." 124 | (should 125 | (org-test-with-temp-text 126 | "* Test 127 | - x 128 | - a 129 | *************** List folding stopped here 130 | *************** END 131 | *************** List folding stopped here 132 | *************** END 133 | - b 134 | " 135 | (org-cycle-internal-local) 136 | (invisible-p (1- (search-forward "- b")))))) 137 | 138 | (ert-deftest test-org-inlinetask/folding-directly-consecutive-tasks/1 () 139 | "Fold directly consecutive inlinetasks." 140 | (should 141 | (org-test-with-temp-text 142 | "* Test 143 | *************** p1 144 | p2 145 | *************** END 146 | *************** p3 147 | p4 148 | *************** END 149 | " 150 | (org-flag-subtree t) 151 | (org-cycle) 152 | (and 153 | (not (invisible-p (1- (search-forward "p1")))) 154 | (invisible-p (1- (search-forward "p2"))) 155 | (not (invisible-p (1- (search-forward "p3")))) 156 | (invisible-p (1- (search-forward "p4"))))))) 157 | 158 | 159 | 160 | (provide 'test-org-inlinetask) 161 | 162 | ;;; test-org-inlinetask.el ends here 163 | -------------------------------------------------------------------------------- /testing/lisp/test-org-tempo.el: -------------------------------------------------------------------------------- 1 | ;;; test-org-tempo.el --- Tests for org-tempo.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017, 2019 Rasmus Pank Roulund 4 | 5 | ;; Author: Rasmus Pank Roulund 6 | 7 | ;; This file is not part of GNU Emacs. 8 | 9 | ;; This program is free software; you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; This program is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with this program. If not, see . 21 | 22 | ;;; Code: 23 | 24 | (require 'org-tempo) 25 | 26 | (unless (featurep 'org-tempo) 27 | (signal 'missing-test-dependency '("org-tempo"))) 28 | 29 | (ert-deftest test-org-tempo/completion () 30 | "Test that blocks and keywords are expanded correctly by org-tempo." 31 | ;; Tempo completion should recognize snippet keywords and expand with tab 32 | (should 33 | (equal (org-test-with-temp-text "" 34 | (org-tempo-setup) 35 | (tempo-complete-tag) 36 | (buffer-string)) 37 | "#+latex: ")) 38 | ;; Tempo completion should recognize snippet Blocks 39 | (should 40 | (equal (org-test-with-temp-text "" 41 | (org-tempo-setup) 42 | (call-interactively 'org-cycle) 43 | (buffer-string)) 44 | "#+begin_export latex\n\n#+end_export")) 45 | ;; Tab should work for expansion. 46 | (should 47 | (equal (org-test-with-temp-text "" 48 | (org-tempo-setup) 49 | (tempo-complete-tag) 50 | (buffer-string)) 51 | (org-test-with-temp-text "" 52 | (org-tempo-setup) 53 | (org-cycle) 54 | (buffer-string)))) 55 | ;; Tempo should not expand unknown snippets 56 | (equal (org-test-with-temp-text "" 67 | (org-tempo-setup) 68 | (tempo-complete-tag) 69 | (goto-char (point-min)) 70 | (end-of-line) 71 | (skip-chars-backward " ")))) 72 | ;; src blocks, export blocks and keywords should have one space at 73 | ;; the end of the first line. 74 | (should (cl-every (apply-partially 'eq 1) 75 | (mapcar (lambda (s) 76 | (org-test-with-temp-text (format "<%s" s) 77 | (org-tempo-setup) 78 | (tempo-complete-tag) 79 | (goto-char (point-min)) 80 | (end-of-line) 81 | (abs (skip-chars-backward " ")))) 82 | '("s" "E" "L"))))) 83 | 84 | (ert-deftest test-org-tempo/cursor-placement () 85 | "Test the placement of the cursor after tempo expand" 86 | ;; Normal blocks place point "inside" block. 87 | (should 88 | (eq (org-test-with-temp-text "" 89 | (org-tempo-setup) 90 | (tempo-complete-tag) 91 | (point)) 92 | (length "#\\+begin_export latex\n"))) 93 | ;; Special block stop at end of #+begin line. 94 | (should 95 | (eq (org-test-with-temp-text "" 96 | (org-tempo-setup) 97 | (tempo-complete-tag) 98 | (point)) 99 | (length "#\\+begin_src ")))) 100 | 101 | (ert-deftest test-org-tempo/add-new-templates () 102 | "Test that new structures and keywords are added correctly." 103 | ;; New blocks should be added. 104 | (should 105 | (let ((org-structure-template-alist '(("n" . "new_block")))) 106 | (org-tempo-add-templates) 107 | (assoc " 6 | 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | 22 | ;; Tests checking validity of Org ASCII export output. 23 | 24 | ;;; Code: 25 | 26 | (require 'ox-ascii nil t) 27 | (unless (featurep 'ox-ascii) 28 | (signal 'missing-test-dependency '("org-export-ascii"))) 29 | 30 | 31 | 32 | (ert-deftest test-ox-ascii/list () 33 | "Test lists." 34 | ;; Number counter. 35 | (org-test-with-exported-text 36 | 'ascii 37 | "1. [@3] foo" 38 | (goto-char (point-min)) 39 | (should 40 | (search-forward 41 | "3. foo"))) 42 | ;; Number counter. Start from 1. 43 | (org-test-with-exported-text 44 | 'ascii 45 | "3. foo" 46 | (goto-char (point-min)) 47 | (should 48 | (search-forward 49 | "1. foo"))) 50 | ;; Alphanumeric counter. 51 | (let ((org-list-allow-alphabetical t)) 52 | (org-test-with-exported-text 53 | 'ascii 54 | "m. [@k] baz" 55 | (goto-char (point-min)) 56 | (should 57 | (search-forward 58 | "11. baz")))) 59 | ;; Start from 1. 60 | (let ((org-list-allow-alphabetical t)) 61 | (org-test-with-exported-text 62 | 'ascii 63 | "m. bar" 64 | (goto-char (point-min)) 65 | (should 66 | (search-forward 67 | "1. bar"))))) 68 | 69 | (ert-deftest test-ox-ascii/justify () 70 | "Test justification." 71 | ;; Right justify. 72 | (org-test-with-exported-text 73 | 'ascii 74 | "#+OPTIONS: author:nil *:t 75 | #+BEGIN_JUSTIFYRIGHT 76 | left or right 77 | #+END_JUSTIFYRIGHT 78 | " 79 | (goto-char (point-min)) 80 | (search-forward 81 | "left or right") 82 | (should 83 | (equal org-ascii-text-width (org-current-text-column))))) 84 | 85 | (provide 'test-ox-ascii) 86 | ;;; test-ox-ascii.el ends here 87 | -------------------------------------------------------------------------------- /testing/lisp/test-ox-beamer.el: -------------------------------------------------------------------------------- 1 | ;;; test-ox-beamer.el --- tests for ox-beamer.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2024 Leo Butler 4 | 5 | ;; Author: Leo Butler 6 | 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | 22 | ;; Tests checking validity of Org Beamer export output. 23 | 24 | ;;; Code: 25 | 26 | (require 'ox-beamer nil t) 27 | (unless (featurep 'ox-beamer) 28 | (signal 'missing-test-dependency '("org-export-beamer"))) 29 | 30 | 31 | 32 | (ert-deftest ox-beamer/orgframe () 33 | "Test that `org-beamer-frame-environment' is defined and used." 34 | (org-test-with-exported-text 35 | 'beamer 36 | "#+OPTIONS: toc:nil 37 | * A frame 38 | Here is an example: 39 | #+begin_example 40 | \\begin{frame} 41 | ... 42 | \\end{frame} 43 | #+end_example 44 | " 45 | (goto-char (point-min)) 46 | (should (search-forward (concat "\\newenvironment<>{" org-beamer-frame-environment "}") nil t)) 47 | (should (search-forward (concat "\\begin{" org-beamer-frame-environment "}") nil t)) 48 | (should (search-forward (concat "\\end{" org-beamer-frame-environment "}") nil t)))) 49 | 50 | (ert-deftest ox-beamer/orgframe-in-example () 51 | "Test that `org-beamer-frame-environment' is not defined." 52 | (org-test-with-exported-text 53 | 'beamer 54 | (concat "#+OPTIONS: toc:nil 55 | * A frame 56 | Here is an example: 57 | #+begin_example 58 | \\begin{" org-beamer-frame-environment "} 59 | ... 60 | \\end{" org-beamer-frame-environment "} 61 | #+end_example 62 | ") 63 | (goto-char (point-min)) 64 | (should-not (search-forward 65 | (concat "\\newenvironment<>{" org-beamer-frame-environment "}") nil t)) 66 | (forward-line) 67 | (should (search-forward (concat "\\begin{frame}") nil t)) 68 | (should (search-forward (concat "\\begin{" org-beamer-frame-environment "}"))) 69 | (should (search-forward (concat "\\end{" org-beamer-frame-environment "}"))) 70 | (should (search-forward (concat "\\end{frame}") nil t)))) 71 | 72 | (ert-deftest ox-beamer/orgframe-in-one-example () 73 | "Test that `org-beamer-frame-environment' is defined. 74 | First frame should use \"frame\" environment, the second uses 75 | `org-beamer-frame-environment'." 76 | (org-test-with-exported-text 77 | 'beamer 78 | (concat "#+OPTIONS: toc:nil 79 | * A frame 80 | Here is an example: 81 | #+begin_example 82 | \\begin{" org-beamer-frame-environment "} 83 | ... 84 | \\end{" org-beamer-frame-environment "} 85 | #+end_example 86 | 87 | * A second frame 88 | Here is a second example: 89 | #+begin_example 90 | \\begin{frame} 91 | ... 92 | \\end{frame} 93 | #+end_example 94 | ") 95 | (goto-char (point-min)) 96 | (should (search-forward 97 | (concat "\\newenvironment<>{" org-beamer-frame-environment "}") nil t)) 98 | (forward-line) 99 | (org-test-ignore-duplicate 100 | (should (search-forward (concat "\\begin{frame}") nil t)) 101 | (should (search-forward (concat "\\begin{" org-beamer-frame-environment "}"))) 102 | (should (search-forward (concat "\\end{" org-beamer-frame-environment "}"))) 103 | (should (search-forward (concat "\\end{frame}") nil t)) 104 | (should (search-forward (concat "\\begin{" org-beamer-frame-environment "}"))) 105 | (should (search-forward (concat "\\begin{frame}") nil t)) 106 | (should (search-forward (concat "\\end{frame}") nil t)) 107 | (should (search-forward (concat "\\end{" org-beamer-frame-environment "}")))))) 108 | 109 | (provide 'test-ox-beamer) 110 | ;;; test-ox-beamer.el ends here 111 | -------------------------------------------------------------------------------- /testing/lisp/test-ox-man.el: -------------------------------------------------------------------------------- 1 | ;;; test-ox-man.el --- Tests from ox-man.el -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2025 Ilya Chernyshov 4 | 5 | ;; Author: Ilya Chernyshov 6 | 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Code: 21 | 22 | (require 'ox-man) 23 | 24 | (defvar ox-man/groff-executable (executable-find "groff") 25 | "Contain path to groff executable of nil when there is no such path.") 26 | 27 | (defmacro ox-man/test-with-exported-test (source &rest body) 28 | "Run BODY in export buffer for SOURCE string exported to man. 29 | Throw an error when exported text does not pass groff linter (if groff 30 | executable is available)." 31 | (declare (indent 1)) 32 | `(org-test-with-exported-text 'man ,source 33 | (when ox-man/groff-executable 34 | (let ((output (generate-new-buffer " *groff-linter-output*"))) 35 | (unwind-protect 36 | (progn 37 | (call-process-region 38 | (point-min) (point-max) ox-man/groff-executable 39 | nil (list output t) nil 40 | "-zww" "-rCHECKSTYLE=3" "-man" "-") 41 | (with-current-buffer output 42 | (should 43 | (string-empty-p 44 | (thread-last 45 | (buffer-string) 46 | ;; FIXME: ox-man does not yet support passing a 47 | ;; project name. 48 | (replace-regexp-in-string 49 | (rx bol (0+ any) 50 | "style: .TH missing fourth argument; " 51 | "suggest package/project name and version" 52 | (0+ any) eol) 53 | "") 54 | ;; We do support date via #+DATE keyword, but it 55 | ;; is not enabled by default for historical 56 | ;; reasons. 57 | (replace-regexp-in-string 58 | (rx bol (0+ any) 59 | "style: .TH missing third argument;" 60 | " suggest document modification" 61 | " date in ISO 8601 format (YYYY-MM-DD)" 62 | (0+ any) eol) 63 | "") 64 | (replace-regexp-in-string "\n+" "")))))) 65 | (kill-buffer output)))) 66 | ,@body)) 67 | 68 | (ert-deftest ox-man/bold () 69 | "Test bold text." 70 | (ox-man/test-with-exported-test "*bold* text" 71 | (should (search-forward "\\fBbold\\fP text")))) 72 | 73 | (ert-deftest ox-man/code () 74 | "Test text formatted as code." 75 | (ox-man/test-with-exported-test "~code~" 76 | (should (search-forward "\\fCcode\\fP")))) 77 | 78 | (ert-deftest ox-man/italic-underlined-verbatim () 79 | "Test italic, underlined and verbatim text." 80 | (ox-man/test-with-exported-test "/italic/, _underlined_, =verbatim=" 81 | (should (search-forward "\\fIitalic\\fP")) 82 | (should (search-forward "\\fIunderlined\\fP")) 83 | (should (search-forward "\\fIverbatim\\fP")))) 84 | 85 | (provide 'test-ox-man) 86 | ;;; test-ox-man.el ends here 87 | -------------------------------------------------------------------------------- /testing/lisp/test-property-inheritance.el: -------------------------------------------------------------------------------- 1 | ;;; test-property-inheritance.el --- tests of property inheritance -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (c) 2011-2014, 2019 Eric Schulte 4 | ;; Authors: Eric Schulte 5 | 6 | ;; This file is not part of GNU Emacs. 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | (defmacro test-org-in-property-buffer (&rest body) 23 | `(with-temp-buffer 24 | (insert-file-contents (expand-file-name "property-inheritance.org" 25 | org-test-example-dir)) 26 | (org-mode) 27 | ,@body)) 28 | (def-edebug-spec test-org-in-property-buffer (body)) 29 | 30 | (ert-deftest test-org-property-accumulation-top-use () 31 | (test-org-in-property-buffer 32 | (goto-char (point-min)) 33 | (org-babel-next-src-block 1) 34 | (should (equal 3 (org-babel-execute-src-block))))) 35 | 36 | (ert-deftest test-org-property-accumulation-overwrite-use () 37 | (test-org-in-property-buffer 38 | (goto-char (point-min)) 39 | (org-babel-next-src-block 2) 40 | (should (= 7 (org-babel-execute-src-block))))) 41 | 42 | (ert-deftest test-org-property-accumulation-append-use () 43 | (test-org-in-property-buffer 44 | (goto-char (point-min)) 45 | (org-babel-next-src-block 3) 46 | (should (= 6 (org-babel-execute-src-block))))) 47 | 48 | (provide 'test-property-inheritance) 49 | ;;; test-property-inheritance.el ends here 50 | -------------------------------------------------------------------------------- /testing/org-batch-test-init.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t; -*- 2 | ;; Remove Org remnants built into Emacs 3 | ;; 4 | 5 | ;; clean load-path 6 | (setq load-path 7 | (delq nil (mapcar 8 | (lambda (p) 9 | (unless (string-match "lisp\\(/packages\\)?/org$" p) 10 | p)) 11 | load-path))) 12 | ;; remove property list to defeat cus-load and remove autoloads 13 | (mapatoms (lambda (s) 14 | (let ((sn (symbol-name s))) 15 | (when (string-match "\\`\\(org\\|ob\\|ox\\)\\(-.*\\)?\\'" sn) 16 | (setplist s nil))))) 17 | 18 | ;; we should now start from a clean slate 19 | --------------------------------------------------------------------------------