forked from mirrors/org-mode
Nick Dokos <nicholas.dokos@hp.com> writes: > Eric Schulte <schulte.eric@gmail.com> wrote: > >> The attached updated patch fixes a bug in the original. >> > > Minor problem in applying: > > ,---- > | $ git apply ~/Mail/inbox/724 > | /home/nick/Mail/inbox/724:671: trailing whitespace. > | #+name: > | /home/nick/Mail/inbox/724:599: new blank line at EOF. > | + > | warning: 2 lines add whitespace errors. > `---- The attached version fixes these issues, Thanks -- Eric >From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001 From: Eric Schulte <schulte.eric@gmail.com> Date: Fri, 28 Oct 2011 10:44:21 -0600 Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE Following a round of on-list discussion many code block synonyms have been removed, moving forward the following syntax is valid. - call lines are specified with #+call: - code blocks are named with #+name: - results are named with #+name:, however results generated by a code block may still be labeled with #+results:, and tables named with #+tblname: will be considered to be named results The following function may be used to update an existing Org-mode buffer to the new syntax. (defun update-org-buffer () "Update an Org-mode buffer to the new data, code block and call line syntax." (interactive) (save-excursion (flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t) "\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*")) (update (re new) (goto-char (point-min)) (while (re-search-forward re nil t) (replace-match new nil nil nil 1)))) (let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE"))) (lob-re (to-re '("LOB"))) (case-fold-search t)) (update old-re "name") (update lob-re "call"))))) Note: If an old version of Org-mode (e.g., the one shipped with Emacs) is installed on your system many of the important variables will be pre-defined with a defvar and *will not* have their values automatically updated, these include the following. - org-babel-data-names - org-babel-result-regexp - org-babel-src-block-regexp - org-babel-src-name-regexp - org-babel-src-name-w-name-regexp It may be necessary to either remove the source code of older versions of Org-mode, or to explicitly evaluate the ob.el file. * lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated Documentation. * lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated regular expression. (org-babel-inline-lob-one-liner-regexp): Updated regular expression. * lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that looks like a data results may actually be a code block. * lisp/ob-table.el: Updated documentation. * lisp/ob.el (org-babel-src-name-regexp): Simplified regexp. (org-babel-get-src-block-info): Updated match strings. (org-babel-data-names): Simplified acceptable names. (org-babel-find-named-block): Indentation. (org-babel-find-named-result): Updated to not return a code block as a result. * lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing references to old syntactic elements. (org-additional-option-like-keywords): Removing references to old syntactic elements. * contrib/babel/library-of-babel.org: Updated to make use of the new syntax. * testing/examples/babel-dangerous.org: Updated to make use of the new syntax. * testing/examples/babel.org: Updated to make use of the new syntax. * testing/examples/ob-awk-test.org: Updated to make use of the new syntax. * testing/examples/ob-fortran-test.org: Updated to make use of the new syntax. * testing/lisp/test-ob.el: Removed two bad tests which tested the literal values of old regular expressions rather than their behavior.
87 lines
1.9 KiB
Org Mode
87 lines
1.9 KiB
Org Mode
#+Title: a collection of examples for ob-fortran tests
|
|
#+OPTIONS: ^:nil
|
|
|
|
* simple programs
|
|
:PROPERTIES:
|
|
:ID: 459384e8-1797-4f11-867e-dde0473ea7cc
|
|
:END:
|
|
#+name: hello
|
|
#+begin_src fortran :results silent
|
|
print *, 'Hello world'
|
|
#+end_src
|
|
|
|
#+name: fortran_parameter
|
|
#+begin_src fortran :results silent
|
|
integer, parameter :: i = 10
|
|
write (*, '(i2)') i
|
|
#+end_src
|
|
|
|
* variable resolution
|
|
:PROPERTIES:
|
|
:ID: d8d1dfd3-5f0c-48fe-b55d-777997e02242
|
|
:END:
|
|
#+begin_src fortran :var N = 15 :results silent
|
|
write (*, '(i2)') N
|
|
#+end_src
|
|
|
|
Define for preprocessed fortran
|
|
#+begin_src fortran :defines N 42 :results silent
|
|
implicit none
|
|
write (*, '(i2)') N
|
|
#+end_src
|
|
|
|
#+begin_src fortran :var s="word" :results silent
|
|
write (*, '(a4)') s
|
|
#+end_src
|
|
* arrays
|
|
:PROPERTIES:
|
|
:ID: c28569d9-04ce-4cad-ab81-1ea29f691465
|
|
:END:
|
|
Real array as input
|
|
#+begin_src fortran :var s='(1.0 2.0 3.0) :results silent
|
|
write (*, '(3f5.2)'), s
|
|
#+end_src
|
|
|
|
#+tblname: test_tbl
|
|
| 1.0 |
|
|
| 2.0 |
|
|
|
|
#+begin_src fortran :var s=test_tbl :results silent
|
|
write (*, '(2f5.2)'), s
|
|
#+end_src
|
|
|
|
* failing
|
|
:PROPERTIES:
|
|
:ID: 891ead4a-f87a-473c-9ae0-1cf348bcd04f
|
|
:END:
|
|
Should fail (TODO: add input variables for the case with explicit
|
|
program statement)
|
|
#+begin_src fortran :var s="word" :results silent
|
|
program ex
|
|
print *, "output of ex program"
|
|
end program ex
|
|
#+end_src
|
|
|
|
Fails to compile (TODO: error check in ob-fortran.el)
|
|
#+begin_src fortran :var s='(1 ()) :results silent
|
|
print *, s
|
|
#+end_src
|
|
|
|
Should fail to compile with gfortran
|
|
#+begin_src fortran :flags --std=f95 --pedantic-error :results silent
|
|
program ex
|
|
integer*8 :: i
|
|
end program ex
|
|
#+end_src
|
|
|
|
* programs input parameters
|
|
:PROPERTIES:
|
|
:ID: 2d5330ea-9934-4737-9ed6-e1d3dae2dfa4
|
|
:END:
|
|
Pass parameters to the program
|
|
#+begin_src fortran :cmdline "23" :results silent
|
|
character(len=255) :: cmd
|
|
call get_command_argument(1, cmd)
|
|
write (*,*) trim(cmd)
|
|
#+end_src
|