Re: bug#58678: 28.2; :session in org-babel for python unexpected output

2022-10-24 Thread Sergey
I have traced this to org-bable issue with MacOS python readline and native 
completion. Similar issues discussed in 
https://github.com/jorgenschaefer/elpy/issues/887
and 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25753

The solution proposed in those threads, i.e., installing python from homebrew, 
which has gnureadline, helps for emacs 27 but causes freezing in emacs 28 after 
displaying following message:
```
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support 
readline, yet ‘python-shell-completion-native-enable’ was t and "python3" is 
not part of the ‘python-shell-completion-native-disabled-interpreters’ list. 
Native completions have been disabled locally.
```

Setting ~python-shell-completion-native-enable~ to nil removes the warning but 
doesn't prevent freezing. This behaviour persists with minimal org setup as 
well (although, I believe my emacs comes with org pre-packaged).

Cheers,
Sergey.


--- Original Message ---
On Saturday, October 22nd, 2022 at 12:58 AM, Ihor Radchenko 
 wrote:


> [Redirecting from Emacs bugs]
> [See the quote below for the original report]
> 
> > #+RESULTS:
> > : >>> __PYTHON_EL_eval("try:\nwith 
> > open('/var/folders/dk/3btmprj123b_31jsp30thzrmgq/T/babel-9tY6uv/python-92ZLVe')
> >  as 
> > __org_babel_python_tmpfile:\nexec(compile(__org_babel_python_tmpfile.read(),
> >  __org_babel_python_tmpfile.name, 
> > 'exec'))\nexcept:\nraise\nfinally:\nprint('
> > ```
> 
> 
> I am unable to reproduce with the latest main on Linux.
> Sergey, could you please try to reproduce with the latest Org version
> from Git? See https://orgmode.org/manual/Feedback.html#Feedback
> 
> Best,
> Ihor
> 
> Sergey via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" bug-gnu-em...@gnu.org writes:
> 
> > Running the following org file in 'emacs -Q' leads to an unexpected
> > output as demonstrated below:
> > ```
> > #+begin_src elisp
> > (setq org-babel-python-command "python3")
> > (setq python-shell-interpreter "/usr/bin/python3")
> > (org-babel-do-load-languages
> > 'org-babel-load-languages
> > '(
> > (python . t)))
> > #+end_src
> > 
> > #+begin_src python :results output
> > print(2)
> > #+end_src
> > 
> > #+RESULTS:
> > : 2
> > 
> > #+begin_src python :results output :session python-test
> > print(2)
> > #+end_src
> > 
> > #+RESULTS:
> > : >>> __PYTHON_EL_eval("try:\nwith 
> > open('/var/folders/dk/3btmprj123b_31jsp30thzrmgq/T/babel-9tY6uv/python-92ZLVe')
> >  as 
> > __org_babel_python_tmpfile:\nexec(compile(__org_babel_python_tmpfile.read(),
> >  __org_babel_python_tmpfile.name, 
> > 'exec'))\nexcept:\nraise\nfinally:\nprint('
> > ```
> > 
> > In GNU Emacs 28.2 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 
> > Version 12.6 (Build 21G115))
> > of 2022-10-12 built on MAC-140754
> > Windowing system distributor 'Apple', version 10.3.2113
> > System Description:macOS 12.6
> > 
> > Configured using:
> > 'configure --disable-dependency-tracking --disable-silent-rules
> > --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
> > --infodir=/opt/homebrew/Cellar/emacs-plus@28/28.2/share/info/emacs
> > --prefix=/opt/homebrew/Cellar/emacs-plus@28/28.2 --with-xml2
> > --with-gnutls --without-dbus --without-imagemagick --with-modules
> > --with-rsvg --with-ns --disable-ns-self-contained 'CFLAGS=-Os -w -pipe
> > -mmacosx-version-min=12
> > -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
> > -DFD_SETSIZE=1 -DDARWIN_UNLIMITED_SELECT'
> > 'CPPFLAGS=-I/opt/homebrew/opt/icu4c/include
> > -I/opt/homebrew/opt/openssl@1.1/include
> > -I/opt/homebrew/opt/readline/include -isystem/opt/homebrew/include
> > -F/opt/homebrew/Frameworks
> > -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
> > 'LDFLAGS=-L/opt/homebrew/opt/icu4c/lib
> > -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/readline/lib
> > -L/opt/homebrew/lib -F/opt/homebrew/Frameworks
> > -Wl,-headerpad_max_install_names
> > -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk''
> > 
> > Configured features:
> > ACL GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
> > PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB
> > 
> > Important settings:
> > value of $LANG: en_US.UTF-8
> > locale-coding-system: utf-8-unix
> > 
> > Major mode: Info
> > 
> > Minor modes in effect:
> > shell-dirtrack-mode: t
> > tooltip-mode: t
>

Re: Bug: Code block :results raw replace issue [9.3.7 (9.3.7-22-gbd9785-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200824/)]

2020-10-06 Thread Sergey
Thank you, Nicolas. I suspected as much.
I think it would be nice to update the manual to clearly state this behavior.


Cheers,
Sergey.

Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐

On Tuesday, October 6th, 2020 at 4:59 AM, Nicolas Goaziou 
 wrote:

> Hello,
>
> Sergey srg.koshe...@protonmail.com writes:
>
> > Code block header argument ~replace~ seems to not to work in conjunction
> >
> > with ~raw~. This leads to output being pre-pended instead of being
> >
> > replaced to the results block.
> >
> > Below is a working example:
> >
> > #+begin_src python :session python-test :results output raw replace
> >
> > print('This line will be added every time this code runs')
> >
> > #+end_src
> >
> > #+RESULTS:
> >
> > This line will be added every time this code runs
>
> This is expected. With "raw", Org has no way to determine where the
>
> output starts, ends, or even if there is one already. You may want to
>
> use another option if you want to replace results.
>
> Regards,
> --
>
> Nicolas Goaziou



Bug: Code block :results raw replace issue [9.3.7 (9.3.7-22-gbd9785-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200824/)]

2020-10-06 Thread Sergey
Code block header argument ~replace~ seems to not to work in conjunction
with ~raw~. This leads to output being pre-pended instead of being
replaced to the results block.

Below is a working example:

#+begin_src python :session *python-test* :results output raw replace
print('This line will be added every time this code runs')
#+end_src

#+RESULTS:
This line will be added every time this code runs

Best regards,
Sergey Koshelev.

Setup info:

Emacs : GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 
Version 10.14.3 (Build 18D109))
of 2019-04-12
Package: Org mode version 9.3.7 (9.3.7-22-gbd9785-elpaplus @ 
/Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200824/)

current state:
==
(setq
org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
org-latex-listings 'minted
org-capture-prepare-finalize-hook '(org-roam-capture--install-finalize)
org-link-shell-confirm-function 'yes-or-no-p
org-babel-after-execute-hook '(spacemacs/ob-fix-inline-images)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-roam-title-to-slug-function 'org-roam--title-to-slug
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-refile-targets '((org-agenda-files :maxlevel . 3))
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
org-enforce-todo-dependencies t
org-src-tab-acts-natively t
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode 
-output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")
org-imenu-depth 8
org-download-annotate-function 'org-download-annotate-default
org-agenda-files '("~/org/gcal.org" "~/org/Projects.org" "~/org/brain/Brain.org"
"~/org/todo list.org")
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-latex-to-mathml-convert-command "latexmlmath \"%i\" --presentationmathml=%o"
org-reveal-start-hook '(org-decrypt-entry)
org-modules '(org-habit ol-w3m ol-bbdb ol-bibtex ol-docview ol-gnus ol-info 
ol-irc ol-mhe ol-rmail
ol-eww)
org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
org-roam-buffer-prepare-hook '(org-roam-buffer--insert-title 
org-roam-buffer--insert-backlinks
org-roam-buffer--insert-ref-links)
org-archive-location "~/org/Archived projects.org::"
org-mode-hook '(org-tempo-setup flyspell-mode spacemacs/org-setup-evil-surround
spacemacs/load-yasnippet toc-org-enable org-superstar-mode
#[0 "\301\211\207" [imenu-create-index-function org-imenu-get-tree] 2]
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-show-all append local] 5]
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
org-babel-result-hide-spec org-babel-hide-all-hashes org-download-enable
dotspacemacs//prettify-spacemacs-docs spacemacs//org-babel-do-load-languages
spacemacs//evil-org-mode org-eldoc-load spacemacs//init-company-org-mode
company-mode)
org-roam-mode t
org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-outline-path-complete-in-steps nil
org-archive-hook '(org-attach-archive-delete-maybe)
org-agenda-restore-windows-after-quit t
org-confirm-elisp-link-function 'yes-or-no-p
org-startup-indented t
org-gcal-fetch-file-alist '(("srg.koshe...@gmail.com" . "~/org/gcal.org")
("lifg1dsiqjkpd3ms7sq3sct...@group.calendar.google.com" .
"~/org/work.org")
)
org-roam-title-change-hook '(org-roam--update-file-name-on-title-change
org-roam--update-links-on-title-change)
org-brain-visualize-sort-function 'org-brain-title<
org-download-file-format-function 'org-download-file-format-default
org-roam-db-gc-threshold 402653184
org-roam-capture-function 'org-capture
org-journal-mode-hook '(#[0 "\301\302\303\304$\207"
[org-journal-encrypt-on add-hook org-journal-encryption-hook nil t] 5]
(lambda nil
(add-hook org-journal-encrypt-on (quote org-journal-encryption-hook) nil t)
)
)
org-projectile-per-project-filepath "TODOs.org"
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-metaup-hook '(org-babel-load-in-session-maybe)
org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
org-babel-pre-tangle-hook '(save-buffer)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
org-babel-load-languages '((python . t) (calc . t) (shell . t) (gnuplot . t) 
(ditaa . t))
org-log-done 'time
org-journal-date-format "%A, %B %d %Y"
org-brain-visualize-mode-hook '((lambda nil
(define-key org-brain-visualize-mode-map (kbd "o")
(quote brain-open-narrow))

Bug: :results raw replace header args for a code block don't replace [9.3.7 (9.3.7-18-g093b47-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)]

2020-08-20 Thread Sergey Koshelev
Hi all!


When a source block (I have tested with python, see below) has `raw`
header arg it ignores `replace` argument. The result instead is prepended.

Example:

#+begin_src python :results output raw replace
  print('This line will be added every time this code runs')
#+end_src

#+RESULTS:
This line will be added every time this code runs
This line will be added every time this code runs
This line will be added every time this code runs
This line will be added every time this code runs

Below is the spacemacs config.

Thank you,
Sergey.

Emacs  : GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 
Version 10.14.3 (Build 18D109))
of 2019-04-12
Package: Org mode version 9.3.7 (9.3.7-18-g093b47-elpaplus @ 
/Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)

current state:
==
(setq
org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
org-latex-listings 'minted
org-link-shell-confirm-function 'yes-or-no-p
org-babel-after-execute-hook '(spacemacs/ob-fix-inline-images)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-refile-targets '((org-agenda-files :maxlevel . 3))
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
org-enforce-todo-dependencies t
org-src-tab-acts-natively t
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode 
-output-directory %o %f"
 "pdflatex -shell-escape -interaction nonstopmode 
-output-directory %o %f")
org-imenu-depth 8
org-download-annotate-function 'org-download-annotate-default
org-agenda-files '("~/org/gcal.org" "~/org/Projects.org" "~/org/brain/Brain.org"
"~/org/todo list.org")
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-latex-to-mathml-convert-command "latexmlmath \"%i\" --presentationmathml=%o"
org-reveal-start-hook '(org-decrypt-entry)
org-modules '(org-habit ol-w3m ol-bbdb ol-bibtex ol-docview ol-gnus ol-info 
ol-irc ol-mhe ol-rmail
   ol-eww)
org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent 
org-edna-blocker-function)
org-archive-location "Archived projects.org::"
org-mode-hook '(org-tempo-setup flyspell-mode spacemacs/org-setup-evil-surround
 spacemacs/load-yasnippet toc-org-enable org-superstar-mode
 #[0 "\301\211\207" [imenu-create-index-function 
org-imenu-get-tree] 2]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-all append local] 
5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all 
append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
org-download-enable
 dotspacemacs//prettify-spacemacs-docs 
spacemacs//org-babel-do-load-languages
 spacemacs//evil-org-mode org-eldoc-load 
spacemacs//init-company-org-mode
 company-mode)
org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-outline-path-complete-in-steps nil
org-archive-hook '(org-attach-archive-delete-maybe)
org-agenda-restore-windows-after-quit t
org-confirm-elisp-link-function 'yes-or-no-p
org-startup-indented t
org-gcal-fetch-file-alist 
'(("srg.koshe...@gmail.com<mailto:srg.koshe...@gmail.com>" . "~/org/gcal.org")
 
("lifg1dsiqjkpd3ms7sq3sct...@group.calendar.google.com<mailto:lifg1dsiqjkpd3ms7sq3sct...@group.calendar.google.com>"
 .
  "~/org/work.org")
 )
org-brain-visualize-sort-function 'org-brain-title<
org-download-file-format-function 'org-download-file-format-default
org-journal-mode-hook '(#[0 "\301\302\303\304$\207"
   [org-journal-encrypt-on add-hook 
org-journal-encryption-hook nil t] 5]
 (lambda nil
  (add-hook org-journal-encrypt-on (quote 
org-journal-encryption-hook) nil t))
 )
org-projectile-per-project-filepath "TODOs.org"
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-metaup-hook '(org-babel-load-in-session-maybe)
org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
org-babel-pre-tangle-hook '(save-buffer)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
org-babel-load-languages '((python . t) (calc . t) (shell . t) (gnuplo

Bug: JS code in code block isn't executed, it throws an error [9.3.6 (9.3.6-25-g685b2c-elpaplus @ /Users/serg/.spacemacs-emacs/elpa/28.0/develop/org-plus-contrib-20200316/)]

2020-03-22 Thread Sergey



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


# The code block

```
#+BEGIN_SRC js
console.log('test')
#+END_SRC
```

# The error itself

```
/private/var/folders/1t/d2tthcgx6pqd831qg5nbc5vmgn/T/babel-pRbyYA/js-script-RJxHlE:1
require('sys').print(require('sys').inspect(function(){
   ^

TypeError: require(...).print is not a function
at Object. 
(/private/var/folders/1t/d2tthcgx6pqd831qg5nbc5vmgn/T/babel-pRbyYA/js-script-RJxHlE:1:16)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] 
(internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

```


Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.3.0, NS 
appkit-1894.30 Version 10.15.3 (Build 19D76))
of 2020-03-21
Package: Org mode version 9.3.6 (9.3.6-25-g685b2c-elpaplus @ 
/Users/serg/.spacemacs-emacs/elpa/28.0/develop/org-plus-contrib-20200316/)

current state:
==
(setq
org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
org-link-shell-confirm-function 'yes-or-no-p
org-babel-after-execute-hook '(spacemacs/ob-fix-inline-images)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
org-src-tab-acts-natively t
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-imenu-depth 8
org-download-annotate-function 'org-download-annotate-default
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-mode-hook '(#[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-all append local] 
5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all 
append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes
 #[0 "\301\211\207" [imenu-create-index-function 
org-imenu-get-tree] 2]
 spacemacs/org-setup-evil-surround spacemacs/load-yasnippet 
toc-org-enable
 org-download-enable org-bullets-mode 
dotspacemacs//prettify-spacemacs-docs
 spacemacs//org-babel-do-load-languages 
spacemacs//evil-org-mode org-eldoc-load
 spacemacs//init-company-org-mode company-mode)
org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-archive-hook '(org-attach-archive-delete-maybe)
org-agenda-restore-windows-after-quit t
org-confirm-elisp-link-function 'yes-or-no-p
org-startup-with-inline-images t
org-download-file-format-function 'org-download-file-format-default
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-metaup-hook '(org-babel-load-in-session-maybe)
org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
org-babel-pre-tangle-hook '(save-buffer)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
org-babel-load-languages '((js . t) (shell . t) (emacs-lisp . t))
org-log-done 'time
org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php) ("C" 
. c) ("C++" . c++)
  ("asymptote" . asy) ("bash" . sh) ("beamer" . latex) 
("calc" . fundamental)
  ("cpp" . c++) ("ditaa" . artist) ("dot" . fundamental) 
("elisp" . emacs-lisp)
  ("ocaml" . tuareg) ("screen" . shell-script) ("shell" . 
sh) ("sqlite" . sql))
org-occur-hook '(org-first-headline-recenter)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
org-speed-command-hook '(org-speed-command-activate 
org-babel-speed-command-activate)
org-clock-persist-file "/Users/serg/.spacemacs-emacs/.cache/org-clock-save.el"
org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function
org-latex-prefer-user-labels t
org-publish-timestamp-directory 
"/Users/serg/.spacemacs-emacs/.cache/.org-timestamps/"
org-export-async-init-file 
"/Users/serg/.spacemacs-emacs/layers/+emacs/org/local/org-async-init.el"
org-id-locations-file "/Users/serg/.spacemacs-emacs/.cache/.org-id-locations"
org-confirm-shell-link-function 'yes-or-no-p
org-link-parameters '(("attachment" :follow 

Re: [O] Commit ceae5d651b80295f35c01ecfc53661c7e8eceba7 Breaks syncing with Android

2015-09-24 Thread Sergey Gordienko
On Sat, Sep 12, 2015 at 3:11 AM, Charles Philip Chan <cpc...@bell.net> wrote:
> On 11 Aug 2015, cpc...@bell.net wrote:
> On 11 Aug 2015, m...@nicolasgoaziou.fr wrote:
>
>>> Do you have any other information to share? E.g., what happens when
>>> syncing breaks?
>
>> Yes. The sync fails with a "Syntax error in regexp pattern near index
>> 383" error on the Android (version 5.1.1) side.
>
> I just upgraded to the latest git version of org-mode and this problem
> still persists. I have to use an older version of org-mobile for syncing
> to work.
>
> Charles
>
> --
> "Are [Linux users] lemmings collectively jumping off of the cliff of
> reliable, well-engineered commercial software?"
> (By Matt Welsh)
>
>
> --
> Linux!  Guerrilla UNIX Development Venimus, Vidimus, Dolavimus.
> (By m...@ka4ybr.com, Mark A. Horton KA4YBR)

Could you send to me index.org, agendas.org and checksums.dat files
which break the sync  (unless they don't contain a sensitive data)?
-- 
Sergey Gordienko



[O] [PATCH] org-mobile: Tiny fix in creating index.org file

2015-06-26 Thread Sergey Gordienko
* lisp/org-mobile.el (org-mobile-create-index-file):
Eliminate cloning of `#+READONLY' property in the `index.org' file.
A sublists of `org-todo-keywords' don't need to contain the `|'.

TINYCHANGE
---
 lisp/org-mobile.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 2c13802..293de79 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -439,14 +439,14 @@ agenda view showing the flagged items.
(if org-mobile-use-encryption
org-mobile-encryption-tempfile
  target-file)
+  (insert #+READONLY\n)
   (while (setq entry (pop def-todo))
-   (insert #+READONLY\n)
(setq kwds (mapcar (lambda (x) (if (string-match ( x)
   (substring x 0 (match-beginning 0))
 x))
   (cdr entry)))
(insert #+TODO:  (mapconcat 'identity kwds  ) \n)
-   (setq dwds (member | kwds)
+   (setq dwds (or (member | kwds) (last kwds))
  twds (org-delete-all dwds kwds)
  todo-kwds (org-delete-all twds todo-kwds)
  done-kwds (org-delete-all dwds done-kwds)))
-- 
1.9.5 (Apple Git-50.3)




[O] [PATCH] org-mobile: Tiny fix in creating index.org file lisp/org-mobile.el (org-mobile-create-index-file): - eliminate cloning of #+READONLY property in the index.org file; - org-todo-keywords d

2015-06-25 Thread Sergey Gordienko
---
 lisp/org-mobile.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 2c13802..293de79 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -439,14 +439,14 @@ agenda view showing the flagged items.
(if org-mobile-use-encryption
org-mobile-encryption-tempfile
  target-file)
+  (insert #+READONLY\n)
   (while (setq entry (pop def-todo))
-   (insert #+READONLY\n)
(setq kwds (mapcar (lambda (x) (if (string-match ( x)
   (substring x 0 (match-beginning 0))
 x))
   (cdr entry)))
(insert #+TODO:  (mapconcat 'identity kwds  ) \n)
-   (setq dwds (member | kwds)
+   (setq dwds (or (member | kwds) (last kwds))
  twds (org-delete-all dwds kwds)
  todo-kwds (org-delete-all twds todo-kwds)
  done-kwds (org-delete-all dwds done-kwds)))
-- 
1.9.5 (Apple Git-50.3)




[O] [PATCH] ob-fortran.el, add matrix as input

2013-06-01 Thread Litvinov Sergey
I would like to propose a tiny patch which adds matrix as an input for
ob-fortran.el. See changes in testing/examples/ob-fortran-test.org for
the examples.

From 4115610e692e5056fa4c0f9d498c12912d374646 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Sat, 1 Jun 2013 19:20:06 +0200
Subject: [PATCH] Add a matrix input to ob-fortran.el

* lisp/ob-fortran.el: add a branch which handles nested lists
* testing/examples/ob-fortran-test.org: add a test for matrix input
* testing/lisp/test-ob-fortran.el: add a test for matrix input
---
 lisp/ob-fortran.el   |  6 ++
 testing/examples/ob-fortran-test.org | 22 ++
 testing/lisp/test-ob-fortran.el  | 12 
 3 files changed, 40 insertions(+)

diff --git a/lisp/ob-fortran.el b/lisp/ob-fortran.el
index 1eab03e..a379273 100644
--- a/lisp/ob-fortran.el
+++ b/lisp/ob-fortran.el
@@ -143,6 +143,12 @@ of the same value.
  ((stringp val)
   (format character(len=%d), parameter ::  %S = '%s'\n
   (length val) var val))
+ ;; val is a matrix
+ ((and (listp val) (listp (car val)))
+  (format real, parameter :: %S(%d,%d) = transpose( reshape( %s , (/ %d, %d /) ) )\n
+	  var (length val) (length (car val)) 
+	  (org-babel-fortran-transform-list val)
+	  (length (car val)) (length val)))
  ((listp val)
   (format real, parameter :: %S(%d) = %s\n
 	  var (length val) (org-babel-fortran-transform-list val)))
diff --git a/testing/examples/ob-fortran-test.org b/testing/examples/ob-fortran-test.org
index 47931bf..530d15e 100644
--- a/testing/examples/ob-fortran-test.org
+++ b/testing/examples/ob-fortran-test.org
@@ -50,6 +50,28 @@ write (*, '(3f5.2)'), s
 write (*, '(2f5.2)'), s
 #+end_src
 
+* matrix
+  :PROPERTIES:
+  :ID:   3f73ab19-d25a-428d-8c26-e8c6aa933976
+  :END:
+Real matrix as input
+#+name: fortran-input-matrix1
+| 0.0 | 42.0 |
+| 0.0 |  0.0 |
+| 0.0 |  0.0 |
+
+#+name: fortran-input-matrix2
+| 0.0 | 0.0 | 0.0 |
+| 0.0 | 0.0 | 42.0 |
+
+#+begin_src fortran :var s=fortran-input-matrix1 :results silent
+write (*, '(i2)'), nint(s(1,2))
+#+end_src
+
+#+begin_src fortran :var s=fortran-input-matrix2 :results silent
+write (*, '(i2)'), nint(s(2,3))
+#+end_src
+
 * failing
   :PROPERTIES:
   :ID:   891ead4a-f87a-473c-9ae0-1cf348bcd04f
diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el
index c355996..7754c64 100644
--- a/testing/lisp/test-ob-fortran.el
+++ b/testing/lisp/test-ob-fortran.el
@@ -68,6 +68,18 @@
 (org-babel-next-src-block 2)
 (should (equal 1.00 2.00 (org-babel-execute-src-block)
 
+(ert-deftest ob-fortran/list-matrix-from-table1 ()
+  Test real matrix from a table
+  (org-test-at-id 3f73ab19-d25a-428d-8c26-e8c6aa933976
+(org-babel-next-src-block 1)
+(should (= 42 (org-babel-execute-src-block)
+
+(ert-deftest ob-fortran/list-matrix-from-table2 ()
+  Test real matrix from a table
+  (org-test-at-id 3f73ab19-d25a-428d-8c26-e8c6aa933976
+(org-babel-next-src-block 2)
+(should (= 42 (org-babel-execute-src-block)
+
 (ert-deftest ob-fortran/no-variables-with-main ()
   Test :var with explicit 'program'
   (org-test-at-id 891ead4a-f87a-473c-9ae0-1cf348bcd04f
-- 
1.8.1.5



[O] How to save the state of Agenda buffer in Emacs?

2013-04-27 Thread Sergey Pashinin

Hello org-mode guys,

Each of us has his own commands set
in org-agenda-custom-commands variable.  But how can I detect
what commands were used to create the current state of Agenda
buffer (looking only at this buffer, maybe any local varibales?).

I want to save it and recreate later without dependence on
current .emacs configuration



[O] org-agenda is not working after org-mode update

2013-04-21 Thread Sergey Pashinin

I updated org-mode yesterday through Melpa.
After that org-agenda stopped working for me.

It says:

Invalid function: org-with-silent-modifications

In my script I had this:

(org-agenda nil n)

Trying to execute it now gives:

Debugger entered--Lisp error: (invalid-function 
org-with-silent-modifications)

  org-with-silent-modifications(nil)
  org-refresh-category-properties()
  byte-code(\306!\203\.
  org-agenda-prepare-buffers((/data/org/work.org ...))
  org-agenda-prepare(Agenda and all TODO's)
  (let nil (org-agenda-prepare name))
  eval((let nil (org-agenda-prepare name)))
  org-let(nil (org-agenda-prepare name))
  org-agenda-run-series(Agenda and all TODO's (((agenda ) (alltodo 


  org-agenda(nil n)
  eval((org-agenda nil n) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

-

Also have to add:

I had only (require 'org) in my file and it started to complain: I 
don't know org-agenda-buffer-name variable


So I had to add:

(require 'org)
(require 'org-agenda)
;;(require 'org-compat)

But still got an error I described above.
Looks like a bug



Re: [O] [PATCH] narrowing in agenda file

2012-02-01 Thread Litvinov Sergey
Bernt Hansen be...@norang.ca writes:
   - org agenda clock reports are correct
   - You don't have the LOGBOOK drawer aligned with tags when clocking in
 from the agenda (this was with emacs -q (no org-indent-mode)
   - Column view in the agenda shows correct clocking amounts for each
 task
   - Visiting a task with RET or SPC goes to the task when outside the
 narrowed region
   - Remote editing of a task outside the narrowed region changes the
 target task and not something in your narrowed region instead

 I tried this patch today and clock reports in the agenda no longer
 display for me.  Could you take a look at it please?

Hi Bernt, 

thank you for the recommendations and for testing the patch. I am working
on ERT tests for the items you listed above. Also I found that
=org-agenda-add-note= does not work with narrowed agenda file.

Meanwhile I can share another patch to fix the problem with clock
reports (please see the second code block in
testing/examples/org-agenda-test.org )

From 8824692191990c7ec4294b20c0c966bfc3e89de6 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Wed, 1 Feb 2012 16:04:12 +0100
Subject: [PATCH 3/3] Fix clock reports in the agenda, add a test example for agenda

---
 lisp/org.el  |4 +++-
 testing/examples/org-agenda-test.org |   19 +++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 9e23c18..e1abbda 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16498,6 +16498,8 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 	(inhibit-read-only t)
 	(rea (concat : org-archive-tag :))
 	 bmp file re)
+(save-excursion
+  (save-restriction
 	(while (setq file (pop files))
 	  (catch 'nextfile
 	(if (bufferp file)
@@ -16532,7 +16534,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 		  (while (re-search-forward re nil t)
 		(add-text-properties
 		 (match-beginning 0) (org-end-of-subtree t) pc)))
-		(set-buffer-modified-p bmp)
+		(set-buffer-modified-p bmp)))
 	(setq org-todo-keywords-for-agenda
 	  (org-uniquify org-todo-keywords-for-agenda))
 	(setq org-todo-keyword-alist-for-agenda
diff --git a/testing/examples/org-agenda-test.org b/testing/examples/org-agenda-test.org
index ecd00e5..b16badb 100644
--- a/testing/examples/org-agenda-test.org
+++ b/testing/examples/org-agenda-test.org
@@ -1,10 +1,21 @@
 #+Title: a collection of examples for org-agenda tests
 * TODO should be visible
+  CLOCK: [2010-01-01 Fri 10:00]--[2010-01-01 Fri 10:05] =  0:05
 ob-agenda-test.org buffer should be narrowed after execution of this block
 #+BEGIN_SRC elisp :results silent
-  (let ((org-agenda-files (list buffer-file-name)))
-(narrow-to-region 1 (- (buffer-size) 23))
-(org-agenda nil t)
-(org-agenda-redo))
+(let ((org-agenda-files (list buffer-file-name)))
+  (org-narrow-to-subtree)
+  (org-agenda nil t)
+  (org-agenda-redo))
+#+END_SRC
+
+#+BEGIN_SRC elisp :results silent
+(let ((org-agenda-files (list buffer-file-name)))
+  (org-agenda nil a)
+  (org-agenda-clockreport-mode 1)
+  (org-agenda-change-time-span 'year 2010)
+  (org-agenda-day-view 1)
+)
 #+END_SRC
 * TODO should be hidden
+  CLOCK: [2010-02-01 Mon 10:00]--[2010-02-01 Mon 10:05] =  0:05
-- 
1.7.3.4



Re: [O] [PATCH] narrowing in agenda file

2012-02-01 Thread Litvinov Sergey
This must be a cumulative patch against master.
From f95e9e89b47b35d5198ecaff7ee20ffb3e63b066 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Thu, 2 Feb 2012 08:15:56 +0100
Subject: [PATCH] Make narrowing of the agenda file survive (org-agenda-redo)

* lisp/org.el (org-prepare-agenda-buffers): move '(save-excursion
  (save-restriction' construction
* testing/examples/org-agenda-test.org: add examples
---
 lisp/org.el  |   65 +
 testing/examples/org-agenda-test.org |   21 +++
 2 files changed, 54 insertions(+), 32 deletions(-)
 create mode 100644 testing/examples/org-agenda-test.org

diff --git a/lisp/org.el b/lisp/org.el
index dc9e653..2f08579 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16575,39 +16575,40 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 		(set-buffer file)
 	  (org-check-agenda-file file)
 	  (set-buffer (org-get-agenda-file-buffer file)))
-	(widen)
-	(setq bmp (buffer-modified-p))
-	(org-refresh-category-properties)
-	(setq org-todo-keywords-for-agenda
-		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
-	(setq org-done-keywords-for-agenda
-		  (append org-done-keywords-for-agenda org-done-keywords))
-	(setq org-todo-keyword-alist-for-agenda
-		  (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
-	(setq org-drawers-for-agenda
-		  (append org-drawers-for-agenda org-drawers))
-	(setq org-tag-alist-for-agenda
-		  (append org-tag-alist-for-agenda org-tag-alist))
-
 	(save-excursion
-	  (remove-text-properties (point-min) (point-max) pall)
-	  (when org-agenda-skip-archived-trees
-		(goto-char (point-min))
-		(while (re-search-forward rea nil t)
-		  (if (org-at-heading-p t)
-		  (add-text-properties (point-at-bol) (org-end-of-subtree t) pa
-	  (goto-char (point-min))
-	  (setq re (format org-heading-keyword-regexp-format
-			   org-comment-string))
-	  (while (re-search-forward re nil t)
-		(add-text-properties
-		 (match-beginning 0) (org-end-of-subtree t) pc)))
-	(set-buffer-modified-p bmp)
-(setq org-todo-keywords-for-agenda
-  (org-uniquify org-todo-keywords-for-agenda))
-(setq org-todo-keyword-alist-for-agenda
-	  (org-uniquify org-todo-keyword-alist-for-agenda)
-	  org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda
+	  (save-restriction
+		(widen)
+		(setq bmp (buffer-modified-p))
+		(org-refresh-category-properties)
+		(setq org-todo-keywords-for-agenda
+		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
+		(setq org-done-keywords-for-agenda
+		  (append org-done-keywords-for-agenda org-done-keywords))
+		(setq org-todo-keyword-alist-for-agenda
+		  (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
+		(setq org-drawers-for-agenda
+		  (append org-drawers-for-agenda org-drawers))
+		(setq org-tag-alist-for-agenda
+		  (append org-tag-alist-for-agenda org-tag-alist))
+		(save-excursion
+		  (remove-text-properties (point-min) (point-max) pall)
+		  (when org-agenda-skip-archived-trees
+		(goto-char (point-min))
+		(while (re-search-forward rea nil t)
+		  (if (org-at-heading-p t)
+			  (add-text-properties (point-at-bol) (org-end-of-subtree t) pa
+		  (goto-char (point-min))
+		  (setq re (format org-heading-keyword-regexp-format
+   org-comment-string))
+		  (while (re-search-forward re nil t)
+		(add-text-properties
+		 (match-beginning 0) (org-end-of-subtree t) pc)))
+		(set-buffer-modified-p bmp)))
+	(setq org-todo-keywords-for-agenda
+	  (org-uniquify org-todo-keywords-for-agenda))
+	(setq org-todo-keyword-alist-for-agenda
+	  (org-uniquify org-todo-keyword-alist-for-agenda)
+	  org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda
 
  Embedded LaTeX
 
diff --git a/testing/examples/org-agenda-test.org b/testing/examples/org-agenda-test.org
new file mode 100644
index 000..b16badb
--- /dev/null
+++ b/testing/examples/org-agenda-test.org
@@ -0,0 +1,21 @@
+#+Title: a collection of examples for org-agenda tests
+* TODO should be visible
+  CLOCK: [2010-01-01 Fri 10:00]--[2010-01-01 Fri 10:05] =  0:05
+ob-agenda-test.org buffer should be narrowed after execution of this block
+#+BEGIN_SRC elisp :results silent
+(let ((org-agenda-files (list buffer-file-name)))
+  (org-narrow-to-subtree)
+  (org-agenda nil t)
+  (org-agenda-redo))
+#+END_SRC
+
+#+BEGIN_SRC elisp :results silent
+(let ((org-agenda-files (list buffer-file-name)))
+  (org-agenda nil a)
+  (org-agenda-clockreport-mode 1)
+  (org-agenda-change-time-span 'year 2010)
+  (org-agenda-day-view 1)
+)
+#+END_SRC
+* TODO should be hidden
+  CLOCK: [2010-02-01 Mon 10:00]--[2010-02-01 Mon 10:05] =  0:05
-- 
1.7.3.4



[O] [PATCH] narrowing in agenda file

2012-01-23 Thread Litvinov Sergey
Narrowing in the agenda file does not survive agenda redo. Please
see an example in the first patch. I think the second patch fixes this
problem.
From 60ef46625131391c6a49fccd26861f933a984515 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Mon, 23 Jan 2012 14:22:53 +0100
Subject: [PATCH 1/2] Add a test narrowed agenda file

---
 testing/examples/org-agenda-test.org |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)
 create mode 100644 testing/examples/org-agenda-test.org

diff --git a/testing/examples/org-agenda-test.org b/testing/examples/org-agenda-test.org
new file mode 100644
index 000..ecd00e5
--- /dev/null
+++ b/testing/examples/org-agenda-test.org
@@ -0,0 +1,10 @@
+#+Title: a collection of examples for org-agenda tests
+* TODO should be visible
+ob-agenda-test.org buffer should be narrowed after execution of this block
+#+BEGIN_SRC elisp :results silent
+  (let ((org-agenda-files (list buffer-file-name)))
+(narrow-to-region 1 (- (buffer-size) 23))
+(org-agenda nil t)
+(org-agenda-redo))
+#+END_SRC
+* TODO should be hidden
-- 
1.7.3.4

From 188d95624fec5d53403fd705679167ed7d7345a2 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Mon, 23 Jan 2012 14:26:14 +0100
Subject: [PATCH 2/2] Make narrowing of the agenda file survive (org-agenda-redo)

* lisp/org.el (org-prepare-agenda-buffers): move '(save-excursion
  (save-restriction' construction
---
 lisp/org.el |   67 +--
 1 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index f6a1160..9e23c18 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16498,47 +16498,46 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 	(inhibit-read-only t)
 	(rea (concat : org-archive-tag :))
 	 bmp file re)
-(save-excursion
-  (save-restriction
 	(while (setq file (pop files))
 	  (catch 'nextfile
 	(if (bufferp file)
 		(set-buffer file)
 	  (org-check-agenda-file file)
 	  (set-buffer (org-get-agenda-file-buffer file)))
-	(widen)
-	(setq bmp (buffer-modified-p))
-	(org-refresh-category-properties)
-	(setq org-todo-keywords-for-agenda
-		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
-	(setq org-done-keywords-for-agenda
-		  (append org-done-keywords-for-agenda org-done-keywords))
-	(setq org-todo-keyword-alist-for-agenda
-		  (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
-	(setq org-drawers-for-agenda
-		  (append org-drawers-for-agenda org-drawers))
-	(setq org-tag-alist-for-agenda
-		  (append org-tag-alist-for-agenda org-tag-alist))
-
 	(save-excursion
-	  (remove-text-properties (point-min) (point-max) pall)
-	  (when org-agenda-skip-archived-trees
-		(goto-char (point-min))
-		(while (re-search-forward rea nil t)
-		  (if (org-at-heading-p t)
-		  (add-text-properties (point-at-bol) (org-end-of-subtree t) pa
-	  (goto-char (point-min))
-	  (setq re (format org-heading-keyword-regexp-format
-			   org-comment-string))
-	  (while (re-search-forward re nil t)
-		(add-text-properties
-		 (match-beginning 0) (org-end-of-subtree t) pc)))
-	(set-buffer-modified-p bmp)
-(setq org-todo-keywords-for-agenda
-  (org-uniquify org-todo-keywords-for-agenda))
-(setq org-todo-keyword-alist-for-agenda
-	  (org-uniquify org-todo-keyword-alist-for-agenda)
-	  org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda
+	  (save-restriction
+		(widen)
+		(setq bmp (buffer-modified-p))
+		(org-refresh-category-properties)
+		(setq org-todo-keywords-for-agenda
+		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
+		(setq org-done-keywords-for-agenda
+		  (append org-done-keywords-for-agenda org-done-keywords))
+		(setq org-todo-keyword-alist-for-agenda
+		  (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
+		(setq org-drawers-for-agenda
+		  (append org-drawers-for-agenda org-drawers))
+		(setq org-tag-alist-for-agenda
+		  (append org-tag-alist-for-agenda org-tag-alist))
+		(save-excursion
+		  (remove-text-properties (point-min) (point-max) pall)
+		  (when org-agenda-skip-archived-trees
+		(goto-char (point-min))
+		(while (re-search-forward rea nil t)
+		  (if (org-at-heading-p t)
+			  (add-text-properties (point-at-bol) (org-end-of-subtree t) pa
+		  (goto-char (point-min))
+		  (setq re (format org-heading-keyword-regexp-format
+   org-comment-string))
+		  (while (re-search-forward re nil t)
+		(add-text-properties
+		 (match-beginning 0) (org-end-of-subtree t) pc)))
+		(set-buffer-modified-p bmp)
+	(setq org-todo-keywords-for-agenda
+	  (org-uniquify org-todo-keywords-for-agenda))
+	(setq org-todo-keyword-alist-for-agenda
+	  (org-uniquify org-todo-keyword-alist-for-agenda)
+	  org-tag-alist-for-agenda (org-uniquify org-tag-alist

[O] [BABEL,PATCH] Map screen language to shell-script-mode

2012-01-20 Thread Litvinov Sergey
A patch maps screen language to shell-script-mode.
From 8b802edb789eb50ddffcc9f040afcb7870db0181 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Fri, 20 Jan 2012 18:26:59 +0100
Subject: [PATCH] Map screen to shell-script-mode

---
 lisp/org-src.el |3 ++-
 testing/examples/ob-screen-test.org |5 +
 2 files changed, 7 insertions(+), 1 deletions(-)
 create mode 100644 testing/examples/ob-screen-test.org

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 11ce461..5357dd8 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -153,7 +153,8 @@ but which mess up the display of a snippet in Org exported files.)
 (defcustom org-src-lang-modes
   '((ocaml . tuareg) (elisp . emacs-lisp) (ditaa . artist)
 (asymptote . asy) (dot . fundamental) (sqlite . sql)
-(calc . fundamental) (C . c) (cpp . c++))
+(calc . fundamental) (C . c) (cpp . c++)
+(screen . shell-script))
   Alist mapping languages to their major mode.
 The key is the language name, the value is the string that should
 be inserted as the name of the major mode.  For many languages this is
diff --git a/testing/examples/ob-screen-test.org b/testing/examples/ob-screen-test.org
new file mode 100644
index 000..19ce147
--- /dev/null
+++ b/testing/examples/ob-screen-test.org
@@ -0,0 +1,5 @@
+#+Title: a collection of examples for ob-screen tests
+#+begin_src screen :session create-tmpdir
+  mkdir -p $TMPDIR
+  cd $TMPDIR
+#+end_src
-- 
1.7.3.4



[O] [BABEL,PATCH] Add graphical output to ob-octave

2011-12-17 Thread Litvinov Sergey
I propose a patch to make the following example work in ob-octave.
#+begin_src octave :results graphics :file chart.png
sombrero; % make a figure
#+end_src
From f193df8b1b7d1330a0dde89907a607051f632775 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Fri, 16 Dec 2011 20:12:39 +0100
Subject: [PATCH] ob-octave.el: Add graphical output

* lisp/ob-octave.el: add graphical output to png file

* testing/examples/ob-octave-test.org: add a test for graphical
  output, and a test for session
---
 lisp/ob-octave.el   |   30 +++---
 testing/examples/ob-octave-test.org |   10 ++
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index f840739..796a5c7 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -86,13 +86,24 @@ end)
 	  (org-babel-expand-body:generic
 	   body params (org-babel-variable-assignments:octave params)))
 	 (result (org-babel-octave-evaluate
-		  session full-body result-type matlabp)))
-(org-babel-reassemble-table
- result
- (org-babel-pick-name
-  (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
- (org-babel-pick-name
-  (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))
+		  session
+		  (if (org-babel-octave-graphical-output-file params)
+		  (mapconcat 'identity
+ (list
+  set (0, \defaultfigurevisible\, \off\);
+  full-body
+  (format print -dpng %s (org-babel-octave-graphical-output-file params)))
+ \n)
+		full-body)
+		  result-type matlabp)))
+(if (org-babel-octave-graphical-output-file params)
+	nil
+  (org-babel-reassemble-table
+   result
+   (org-babel-pick-name
+	(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+   (org-babel-pick-name
+	(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))
 
 (defun org-babel-prep-session:matlab (session params)
   Prepare SESSION according to PARAMS.
@@ -259,6 +270,11 @@ This removes initial blank and comment lines and then calls
   (match-string 1 string)
 string))
 
+(defun org-babel-octave-graphical-output-file (params)
+  Name of file to which maxima should send graphical output.
+  (and (member graphics (cdr (assq :result-params params)))
+   (cdr (assq :file params
+
 (provide 'ob-octave)
 
 
diff --git a/testing/examples/ob-octave-test.org b/testing/examples/ob-octave-test.org
index 97d9b00..9839d63 100644
--- a/testing/examples/ob-octave-test.org
+++ b/testing/examples/ob-octave-test.org
@@ -43,3 +43,13 @@ Input elisp nil
 #+begin_src octave :exports results :results silent :var s='nil
 ans = s
 #+end_src
+
+
+* Graphical tests
+#+begin_src octave :results graphics :file chart.png
+sombrero;
+#+end_src
+
+#+begin_src octave :session
+sombrero;
+#+end_src
-- 
1.7.4.1



Re: [O] [BABEL][PATCH] construct a table from the output of maxima code block

2011-10-04 Thread Sergey Litvinov
 In any case, can you please post a patch against the standard
 version?  Or, maybe easier, simply post ob-maxima.el as the other
 changes are not necessary for me to test your patch.

I though my previous patch was applied. It is still under review due to
copyright papers.  I am attaching a patch against master branch and
ob-maxima.el file.

The commit message is
ob-maxima.el: add input variables, png graphic
output, table as an output
From d9cfa76e83c10e86ffacca3da7cbc83702268cc2 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Tue, 4 Oct 2011 19:48:14 +0200
Subject: [PATCH] ob-maxima.el: add input variables, graphic output to png file, table as an output

---
 lisp/ob-maxima.el |   97 -
 1 files changed, 73 insertions(+), 24 deletions(-)

diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
index 085609c..9c39a5f 100644
--- a/lisp/ob-maxima.el
+++ b/lisp/ob-maxima.el
@@ -30,47 +30,96 @@
 ;;
 ;; 1) there is no such thing as a session in maxima
 ;;
-;; 2) we are generally only going to return output from maxima
-;;
-;; 3) we are adding the cmdline header argument
-;;
-;; 4) there are no variables
+;; 2) we are adding the cmdline header argument
 
 ;;; Code:
 (require 'ob)
 
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '(maxima . max))
+
 (defvar org-babel-default-header-args:maxima '())
 
 (defun org-babel-maxima-expand (body params)
   Expand a block of Maxima code according to its header arguments.
-  body)
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var
+ (mapconcat 'identity
+		(list
+		 ;; graphic output
+		 (let ((graphic-file (org-babel-maxima-graphical-output-file params)))
+		   (if graphic-file  
+		   (format 
+			set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]); 
+			graphic-file)
+		 ))
+		 ;; variables
+		 (mapconcat 'org-babel-maxima-var-to-maxima vars \n)
+		 ;; body
+		 body
+		 gnuplot_close ()$)
+		\n)))
 
 (defun org-babel-execute:maxima (body params)
   Execute a block of Maxima entries with org-babel.  This function is
 called by `org-babel-execute-src-block'.
   (message executing Maxima source code block)
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) )))
-	 (cmdline (cdr (assoc :cmdline params)))
-	 (in-file (org-babel-temp-file maxima-))
-	 (cmd (format maxima --very-quiet -r 'batchload(%S)$' %s
-		  in-file cmdline)))
-(with-temp-file in-file (insert body))
-(message cmd)
-((lambda (raw) ;;  | grep -v batch | grep -v 'replaced' | sed '/^$/d' 
-   (mapconcat
-	#'identity
-	(delq nil
-	  (mapcar (lambda (line)
-			(unless (or (string-match batch line)
-(string-match ^rat: replaced .*$ line)
-(= 0 (length line)))
-			  line))
-		  (split-string raw [\r\n]))) \n))
- (org-babel-eval cmd 
+  (let ((result
+	 (let* ((result-params (split-string (or (cdr (assoc :results params)) )))
+		(cmdline (cdr (assoc :cmdline params)))
+		(in-file (org-babel-temp-file maxima- .max))
+		(cmd (format maxima --very-quiet -r 'batchload(%S)$' %s
+			 in-file cmdline)))
+	   (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
+	   (message cmd)
+	   ((lambda (raw) ;;  | grep -v batch | grep -v 'replaced' | sed '/^$/d' 
+	  (mapconcat
+	   #'identity
+	   (delq nil
+		 (mapcar (lambda (line)
+			   (unless (or (string-match batch line)
+	   (string-match ^rat: replaced .*$ line)
+	   (= 0 (length line)))
+ line))
+			 (split-string raw [\r\n]))) \n))
+	(org-babel-eval cmd ) 
+(if (org-babel-maxima-graphical-output-file params) 
+	nil
+  (if (or (member scalar result-params)
+	  (member verbatim result-params)
+	  (member output result-params))
+	  result
+	(let ((tmp-file (org-babel-temp-file maxima-res-)))
+	  (with-temp-file tmp-file (insert result))
+	  (org-babel-import-elisp-from-file tmp-file))
+
 
 (defun org-babel-prep-session:maxima (session params)
   (error Maxima does not support sessions))
 
+(defun org-babel-maxima-var-to-maxima (pair)
+  Convert an elisp val into a string of maxima code specifying a var
+of the same value.
+  (let ((var (car pair))
+(val (cdr pair)))
+(when (symbolp val)
+  (setq val (symbol-name val))
+  (when (= (length val) 1)
+(setq val (string-to-char val
+  (format %S: %s$ var 
+	  (org-babel-maxima-elisp-to-maxima val
+
+(defun org-babel-maxima-graphical-output-file (params)
+  Name of file to which maxima should send graphical output.
+  (and (member graphics (cdr (assq :result-params params)))
+   (cdr (assq :file params
+
+(defun org-babel-maxima-elisp-to-maxima (val)
+  Return a string of maxima code which evaluates to VAL.
+  (if (listp val)
+  (concat [ (mapconcat #'org-babel-maxima-elisp-to-maxima val , ) ])
+(format %s val)))
+
+
 (provide 'ob-maxima)
 
 
-- 
1.7.4.1

Re: [O] [PATCH][babel] add a string input to ob-octave

2011-10-01 Thread Litvinov Sergey
 In other words, replacing (or var nil) with var would be enough

Thanks. Fixed in the patch below. The patch also adds an ert test.
From b4b679abdc7bec9f3033b50f81d567a0bb48b147 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Sat, 1 Oct 2011 13:37:56 +0200
Subject: [PATCH 2/2] Remove redundant condition check in ob-octave.el. Add a test.

---
 lisp/ob-octave.el   |4 ++--
 testing/examples/ob-octave-test.org |6 --
 testing/lisp/test-ob-octave.el  |6 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index cfc1f1d..f840739 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -119,9 +119,9 @@ specifying a variable of the same value.
 			 (if (listp (car var)) ;  ,)) ])
 (cond
  ((stringp var)
-  (format \'%s\' (or var nil)))
+  (format \'%s\' var))
  (t
-  (format %s (or var nil))
+  (format %s var)
 
 (defun org-babel-prep-session:octave (session params optional matlabp)
   Prepare SESSION according to the header arguments specified in PARAMS.
diff --git a/testing/examples/ob-octave-test.org b/testing/examples/ob-octave-test.org
index 37cf3f9..97d9b00 100644
--- a/testing/examples/ob-octave-test.org
+++ b/testing/examples/ob-octave-test.org
@@ -24,7 +24,6 @@ Input an integer variable
 ans = s
 #+end_src
 
-
 Input an array
 #+begin_src octave :exports results :results silent :var s='(1.0 2.0 3.0)
 ans = s
@@ -40,4 +39,7 @@ Input a string
 ans = s(1:2)
 #+end_src
 
-
+Input elisp nil
+#+begin_src octave :exports results :results silent :var s='nil
+ans = s
+#+end_src
diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el
index f3972ec..145266d 100644
--- a/testing/lisp/test-ob-octave.el
+++ b/testing/lisp/test-ob-octave.el
@@ -53,3 +53,9 @@
 (org-babel-next-src-block 4)
 (should (equal te (org-babel-execute-src-block)
 
+(ert-deftest ob-octave/input-nil ()
+  Input elisp nil
+  (org-test-at-id cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+(org-babel-next-src-block 5)
+(should (equal nil (org-babel-execute-src-block)
+
-- 
1.7.4.1



Re: [O] looking for examples using babel/calc

2011-10-01 Thread Litvinov Sergey
 is there some documentation and are there some examples of using babel
 with calc?

There are examples in
https://github.com/eschulte/babel-dev.git

Search for 'begin_src calc'.
https://raw.github.com/eschulte/babel-dev/master/scraps.org




[O] [PATCH][babel] add a string input to ob-octave

2011-09-30 Thread Litvinov Sergey
Please consider a tiny patch to add a string input variable to
ob-octave. I also add tests for ob-octave.
From 4848960cefc1b1486705f7aed022ba199189b6e1 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Sat, 1 Oct 2011 02:04:49 +0200
Subject: [PATCH] Add string input variables to ob-octave.el. Add tests for ob-octave.el

---
 lisp/ob-octave.el   |6 +++-
 testing/README.org  |1 +
 testing/examples/ob-octave-test.org |   43 +++
 testing/lisp/test-ob-octave.el  |   55 +++
 4 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 testing/examples/ob-octave-test.org
 create mode 100644 testing/lisp/test-ob-octave.el

diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index 3d90954..cfc1f1d 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -117,7 +117,11 @@ specifying a variable of the same value.
   (if (listp var)
   (concat [ (mapconcat #'org-babel-octave-var-to-octave var
 			 (if (listp (car var)) ;  ,)) ])
-(format %s (or var nil
+(cond
+ ((stringp var)
+  (format \'%s\' (or var nil)))
+ (t
+  (format %s (or var nil))
 
 (defun org-babel-prep-session:octave (session params optional matlabp)
   Prepare SESSION according to the header arguments specified in PARAMS.
diff --git a/testing/README.org b/testing/README.org
index 2f16a55..221a33c 100644
--- a/testing/README.org
+++ b/testing/README.org
@@ -79,6 +79,7 @@ First tangle this file out to your desktop.
(list (concat org-dir /testing/examples/babel.org)
  (concat org-dir /testing/examples/normal.org)
  (concat org-dir /testing/examples/ob-awk-test.org)
+ (concat org-dir /testing/examples/ob-octave.org)
  (concat org-dir /testing/examples/ob-fortran-test.org)
  (concat org-dir /testing/examples/link-in-heading.org)
  (concat org-dir /testing/examples/links.org)))
diff --git a/testing/examples/ob-octave-test.org b/testing/examples/ob-octave-test.org
new file mode 100644
index 000..37cf3f9
--- /dev/null
+++ b/testing/examples/ob-octave-test.org
@@ -0,0 +1,43 @@
+#+Title: a collection of examples for ob-octave tests
+#+OPTIONS: ^:nil
+
+* Simple tests
+  :PROPERTIES:
+  :ID:   54dcd61d-cf6c-4d7a-b9e5-854953c8a753
+  :END:
+Number output
+#+begin_src octave :exports results :results silent
+ans = 10
+#+end_src
+
+Array output
+#+begin_src octave :exports results :results silent
+ans = 1:4'
+#+end_src
+
+* Input tests
+  :PROPERTIES:
+  :ID:   cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+  :END:
+Input an integer variable
+#+begin_src octave :exports results :results silent :var s=42
+ans = s
+#+end_src
+
+
+Input an array
+#+begin_src octave :exports results :results silent :var s='(1.0 2.0 3.0)
+ans = s
+#+end_src
+
+Input a matrix
+#+begin_src octave :exports results :results silent :var s='((1 2) (3 4))
+ans = s
+#+end_src
+
+Input a string
+#+begin_src octave :exports results :results silent :var s=test
+ans = s(1:2)
+#+end_src
+
+
diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el
new file mode 100644
index 000..f3972ec
--- /dev/null
+++ b/testing/lisp/test-ob-octave.el
@@ -0,0 +1,55 @@
+;;; test-ob-octave.el --- tests for ob-octave.el
+
+;; Copyright (c) 2010 Sergey Litvinov
+;; Authors: Sergey Litvinov
+
+;; Released under the GNU General Public License version 3
+;; see: http://www.gnu.org/licenses/gpl-3.0.html
+
+(org-test-for-executable octave)
+
+(let ((load-path (cons (expand-file-name
+			.. (file-name-directory
+			  (or load-file-name buffer-file-name)))
+		   load-path)))
+  (require 'org-test)
+  (require 'org-test-ob-consts))
+
+(require 'ob-octave)
+
+(ert-deftest ob-octave/input-none ()
+  Number output
+  (org-test-at-id 54dcd61d-cf6c-4d7a-b9e5-854953c8a753
+(org-babel-next-src-block)
+(should (= 10 (org-babel-execute-src-block)
+
+(ert-deftest ob-octave/output-vector ()
+  Vector output
+  (org-test-at-id 54dcd61d-cf6c-4d7a-b9e5-854953c8a753
+(org-babel-next-src-block 2)
+(should (equal '((1 2 3 4)) (org-babel-execute-src-block)
+
+(ert-deftest ob-octave/input-variable ()
+  Input variable
+  (org-test-at-id cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+(org-babel-next-src-block)
+(should (= 42 (org-babel-execute-src-block)
+
+(ert-deftest ob-octave/input-array ()
+  Input an array
+  (org-test-at-id cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+(org-babel-next-src-block 2)
+(should (equal '((1 2 3)) (org-babel-execute-src-block)
+
+(ert-deftest ob-octave/input-matrix ()
+  Input a matrix
+  (org-test-at-id cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+(org-babel-next-src-block 3)
+(should (equal '((1 2) (3 4)) (org-babel-execute-src-block)
+
+(ert-deftest ob-octave/input-string ()
+  Input a string
+  (org-test-at-id cc2d82bb-2ac0-45be-a0c8-d1463b86a3ba
+(org-babel-next-src-block 4)
+(should (equal te (org-babel-execute

[O] [PATCH] testing/ort-test.el, regexp to find files

2011-08-03 Thread Litvinov Sergey
org-test picks up temporary and backup files. Please consider a patch
the attachments to get rid of them.
From 9b616baf0f3df63ea13ffde37c9c5aff903fac4e Mon Sep 17 00:00:00 2001
From: Sergey Litvinov slitvi...@gmail.com
Date: Mon, 1 Aug 2011 00:47:32 +0200
Subject: [PATCH] Get rid of tmp and backup file in test load

---
 testing/org-test.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index 96e693f..4e2f8e6 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -204,7 +204,7 @@ files.
 		 (lambda (path)
 		   (if (file-directory-p path) (rload path) (load-file path)))
 		 (directory-files base 'full
-  ^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el
+  ^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$
 (rload (expand-file-name lisp org-test-dir))
 (rload (expand-file-name lisp
 			 (expand-file-name contrib org-test-dir)
-- 
1.7.1



[O] [BABEL,PATCH] cpp-c++-mode, ob-C mode tests

2011-08-03 Thread Litvinov Sergey
The first patch maps cpp language code to c++-mode. The second patch
adds tests for ob-C.
From d0bc3554ec70138245289f1fabf78e2e86436c78 Mon Sep 17 00:00:00 2001
From: Sergey Litvinov slitvi...@gmail.com
Date: Wed, 3 Aug 2011 22:02:43 +0200
Subject: [PATCH 1/2] Map cpp to c++-mode

---
 lisp/org-src.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 30ffc34..094ec09 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -155,7 +155,7 @@ but which mess up the display of a snippet in Org exported files.)
 (defcustom org-src-lang-modes
   '((ocaml . tuareg) (elisp . emacs-lisp) (ditaa . artist)
 (asymptote . asy) (dot . fundamental) (sqlite . sql)
-(calc . fundamental) (C . c))
+(calc . fundamental) (C . c) (cpp . c++))
   Alist mapping languages to their major mode.
 The key is the language name, the value is the string that should
 be inserted as the name of the major mode.  For many languages this is
-- 
1.7.1

From fba6eef6944766e675e4abe1d11d347b9a728031 Mon Sep 17 00:00:00 2001
From: Sergey Litvinov slitvi...@gmail.com
Date: Wed, 3 Aug 2011 22:03:19 +0200
Subject: [PATCH 2/2] Add tests for ob-C.el

---
 testing/README.org |1 +
 testing/examples/ob-C-test.org |   44 
 testing/lisp/test-ob-C.el  |   43 +++
 3 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 testing/examples/ob-C-test.org
 create mode 100644 testing/lisp/test-ob-C.el

diff --git a/testing/README.org b/testing/README.org
index 2f16a55..cb408db 100644
--- a/testing/README.org
+++ b/testing/README.org
@@ -77,6 +77,7 @@ First tangle this file out to your desktop.
   (require 'org-id)
   (org-id-update-id-locations
(list (concat org-dir /testing/examples/babel.org)
+ (concat org-dir /testing/examples/ob-C-test.org)
  (concat org-dir /testing/examples/normal.org)
  (concat org-dir /testing/examples/ob-awk-test.org)
  (concat org-dir /testing/examples/ob-fortran-test.org)
diff --git a/testing/examples/ob-C-test.org b/testing/examples/ob-C-test.org
new file mode 100644
index 000..4721c96
--- /dev/null
+++ b/testing/examples/ob-C-test.org
@@ -0,0 +1,44 @@
+#+Title: a collection of examples for ob-C tests
+#+OPTIONS: ^:nil
+* Simple tests
+  :PROPERTIES:
+  :ID:   fa6db330-e960-4ea2-ac67-94bb845b8577
+  :END:
+#+source: simple
+#+begin_src cpp :includes iostream :results silent
+  std::cout  42;
+  return 0;
+#+end_src 
+
+#+source: integer_var
+#+begin_src cpp :var q=12 :includes iostream :results silent
+  std::cout  q;
+  return 0;
+#+end_src
+
+#+source: two_var
+#+begin_src cpp :var q=12 :var p=10 :includes iostream :results silent
+  std::cout  p+q;
+  return 0;
+#+end_src
+
+#+source: string_var
+#+begin_src cpp :var q=word :includes '(iostream cstring) :results silent
+  std::cout  q  ' '  strlen(q);
+  return 0;
+#+end_src
+
+#+source: define
+#+begin_src cpp :defines N 42  :includes iostream :results silent
+  std::cout  N;
+  return 0;
+#+end_src
+
+* Array
+#+source: array
+#+begin_src cpp :includes iostream :results vector :results silent
+  for (int i=1; i3; i++) {
+std::cout  i  '\n';
+  }
+  return 0;
+#+end_src
diff --git a/testing/lisp/test-ob-C.el b/testing/lisp/test-ob-C.el
new file mode 100644
index 000..5ee7bec
--- /dev/null
+++ b/testing/lisp/test-ob-C.el
@@ -0,0 +1,43 @@
+(require 'ob-C)
+ 
+(ert-deftest ob-C/assert ()
+  (should t))
+
+(ert-deftest ob-C/simple-program ()
+  Hello world program.
+  (org-test-at-id fa6db330-e960-4ea2-ac67-94bb845b8577
+(org-babel-next-src-block)
+(should (= 42 (org-babel-execute-src-block)
+
+(ert-deftest ob-C/integer-var ()
+  Test of an integer variable.
+  (org-test-at-id fa6db330-e960-4ea2-ac67-94bb845b8577
+(org-babel-next-src-block 2)
+(should (= 12 (org-babel-execute-src-block)
+
+(ert-deftest ob-C/two-integer-var ()
+  Test of two input variables
+  (org-test-at-id fa6db330-e960-4ea2-ac67-94bb845b8577
+(org-babel-next-src-block 3)
+(should (= 22 (org-babel-execute-src-block)
+
+(ert-deftest ob-C/string-var ()
+  Test of a string input variable
+  (org-test-at-id fa6db330-e960-4ea2-ac67-94bb845b8577
+(org-babel-next-src-block 4)
+(should (equal word 4 (org-babel-execute-src-block)
+
+(ert-deftest ob-C/preprocessor ()
+  Test of a string variable
+  (org-test-at-id fa6db330-e960-4ea2-ac67-94bb845b8577
+(org-babel-next-src-block 5)
+(should (= 42 (org-babel-execute-src-block)
+
+(ert-deftest ob-C/table ()
+  Test of a table output
+  (org-test-at-id 2df1ab83-3fa3-462a-a1f3-3aef6044a874
+(org-babel-next-src-block)
+(should (equal '((1) (2)) (org-babel-execute-src-block)
+
+;;; test-ob-C.el ends here
+ 
-- 
1.7.1



[O] [BABEL,PATCH] call awk with no input

2011-07-24 Thread Litvinov Sergey
Please consider this tiny fix to execute awk program with no input.
Example with gawk:
gawk --posix 'BEGIN {print 42}'

I also added some tests for ob-awk.
From 868fa910254c48752801cdc7849c3eb4db63f811 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Sun, 24 Jul 2011 12:28:35 +0200
Subject: [PATCH] Awk can be called with no in-file: and no :stdin

---
 lisp/ob-awk.el   |6 +---
 testing/README.org   |1 +
 testing/examples/ob-awk-test.in  |2 +
 testing/examples/ob-awk-test.org |   39 ++
 testing/lisp/test-ob-awk.el  |   19 ++
 5 files changed, 63 insertions(+), 4 deletions(-)
 create mode 100644 testing/examples/ob-awk-test.in
 create mode 100644 testing/examples/ob-awk-test.org
 create mode 100644 testing/lisp/test-ob-awk.el

diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el
index d5098bc..cfed04a 100644
--- a/lisp/ob-awk.el
+++ b/lisp/ob-awk.el
@@ -26,8 +26,7 @@
 
 ;;; Commentary:
 
-;; Babel's awk support relies on two special header argument one of
-;; which is required to pass data to the awk process.
+;; Babel's awk can use special header argument:
 ;; 
 ;; - :in-file takes a path to a file of data to be processed by awk
 ;;   
@@ -89,11 +88,10 @@ called by `org-babel-execute-src-block'
 	  (with-temp-file tmp (insert results))
 	  (org-babel-import-elisp-from-file tmp)
   (cond
-   (in-file (org-babel-eval cmd ))
(stdin (with-temp-buffer
 		(call-process-shell-command cmd stdin (current-buffer))
 		(buffer-string)))
-   (t (error ob-awk: must specify either :in-file or :stdin
+   (t (org-babel-eval cmd 
  (org-babel-pick-name
   (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
  (org-babel-pick-name
diff --git a/testing/README.org b/testing/README.org
index 3cc0487..2f16a55 100644
--- a/testing/README.org
+++ b/testing/README.org
@@ -78,6 +78,7 @@ First tangle this file out to your desktop.
   (org-id-update-id-locations
(list (concat org-dir /testing/examples/babel.org)
  (concat org-dir /testing/examples/normal.org)
+ (concat org-dir /testing/examples/ob-awk-test.org)
  (concat org-dir /testing/examples/ob-fortran-test.org)
  (concat org-dir /testing/examples/link-in-heading.org)
  (concat org-dir /testing/examples/links.org)))
diff --git a/testing/examples/ob-awk-test.in b/testing/examples/ob-awk-test.in
new file mode 100644
index 000..c38382d
--- /dev/null
+++ b/testing/examples/ob-awk-test.in
@@ -0,0 +1,2 @@
+ # an input file for awk test
+15
\ No newline at end of file
diff --git a/testing/examples/ob-awk-test.org b/testing/examples/ob-awk-test.org
new file mode 100644
index 000..7f51772
--- /dev/null
+++ b/testing/examples/ob-awk-test.org
@@ -0,0 +1,39 @@
+#+Title: a collection of examples for ob-awk tests
+#+OPTIONS: ^:nil
+
+* Simple tests
+  :PROPERTIES:
+  :ID:   9e998b2a-3581-43fe-b26d-07d3c507b86a
+  :END:
+Run without input stream
+#+begin_src awk :ouput silent :results silent
+  BEGIN {
+  print 42
+  }
+#+end_src
+
+Use a code block ouput as an input
+#+begin_src awk  :stdin genseq :results silent
+  {
+  print 42+$1
+  }
+#+end_src
+
+Use input file
+#+srcname: genfile
+#+begin_src awk  :in-file ob-awk-test.in :results silent
+$0~/[\t]*#/{
+# skip comments 
+next
+}
+{ 
+print $1*10
+}
+#+end_src
+
+* Input data generators
+A code block to generate input stream
+#+srcname: genseq
+#+begin_src emacs-lisp :results silent
+(print 1)
+#+end_src
diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el
new file mode 100644
index 000..018dec4
--- /dev/null
+++ b/testing/lisp/test-ob-awk.el
@@ -0,0 +1,19 @@
+(require 'ob-awk)
+
+(ert-deftest ob-awk/input-none ()
+  Test with no input file
+  (org-test-at-id 9e998b2a-3581-43fe-b26d-07d3c507b86a
+(org-babel-next-src-block)
+(should (= 42 (org-babel-execute-src-block)
+
+(ert-deftest ob-awk/input-src-block ()
+  Test a code block as an input
+  (org-test-at-id 9e998b2a-3581-43fe-b26d-07d3c507b86a
+(org-babel-next-src-block 2)
+(should (= 43 (org-babel-execute-src-block)
+
+(ert-deftest ob-awk/input-src-block ()
+  Test a code block as an input
+  (org-test-at-id 9e998b2a-3581-43fe-b26d-07d3c507b86a
+(org-babel-next-src-block 3)
+(should (= 150 (org-babel-execute-src-block)
-- 
1.7.4.1



[O] [BABEL,PATCH] ob-fortran, ert tests

2011-07-20 Thread Litvinov Sergey
ob-fortran.el: fix a bug with string input, add ob-fortran tests with
ert.
From ed4e14fd509cad8d9ccc66bef570f2d8796213ca Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Thu, 21 Jul 2011 00:44:50 +0200
Subject: [PATCH] ob-fortran.el: fix bug with string input, add ob-fortran tests with ert

---
 contrib/babel/langs/ob-fortran.el|4 +-
 testing/README.org   |1 +
 testing/examples/ob-fortran-test.org |   86 +++---
 testing/lisp/test-ob-fortran.el  |   80 +++
 4 files changed, 131 insertions(+), 40 deletions(-)
 create mode 100644 testing/lisp/test-ob-fortran.el

diff --git a/contrib/babel/langs/ob-fortran.el b/contrib/babel/langs/ob-fortran.el
index f2f5cb2..6b0b144 100644
--- a/contrib/babel/langs/ob-fortran.el
+++ b/contrib/babel/langs/ob-fortran.el
@@ -142,8 +142,8 @@ of the same value.
  ((or (characterp val))
   (format character, parameter :: %S = '%S'\n var val))
  ((stringp val)
-  (format character, parameter ::  %S(%d) = '%s'\n
-  var (length val) val))
+  (format character(len=%d), parameter ::  %S = '%s'\n
+  (length val) var val))
  ((listp val)
   (format real, parameter :: %S(%d) = %s\n
 	  var (length val) (ob-fortran-transform-list val)))
diff --git a/testing/README.org b/testing/README.org
index 648a30d..3cc0487 100644
--- a/testing/README.org
+++ b/testing/README.org
@@ -78,6 +78,7 @@ First tangle this file out to your desktop.
   (org-id-update-id-locations
(list (concat org-dir /testing/examples/babel.org)
  (concat org-dir /testing/examples/normal.org)
+ (concat org-dir /testing/examples/ob-fortran-test.org)
  (concat org-dir /testing/examples/link-in-heading.org)
  (concat org-dir /testing/examples/links.org)))
   
diff --git a/testing/examples/ob-fortran-test.org b/testing/examples/ob-fortran-test.org
index ade9f43..d48ae4e 100644
--- a/testing/examples/ob-fortran-test.org
+++ b/testing/examples/ob-fortran-test.org
@@ -1,76 +1,86 @@
-* Test org fortran file
-#+begin_src fortran
+#+Title: a collection of examples for ob-fortran tests
+#+OPTIONS: ^:nil
+
+* simple programs
+  :PROPERTIES:
+  :ID:   459384e8-1797-4f11-867e-dde0473ea7cc
+  :END:
+#+source: hello
+#+begin_src fortran :results silent
 print *, 'Hello world'
 #+end_src
 
-#+begin_src fortran
+#+source: fortran_parameter
+#+begin_src fortran :results silent
 integer, parameter :: i = 10
-print *, 'i = ', i
+write (*, '(i2)') i
 #+end_src
 
-#+begin_src fortran :var N = 10
-print *, 'N = ', N
+* 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
+#+begin_src fortran :defines N 42 :results silent
 implicit none
-print *, 'N = ', N
+write (*, '(i2)') N
 #+end_src
 
-#+begin_src fortran :var s=word
-print *, 's = ', s
-print *, 'size(s) = ', size(s)
+#+begin_src fortran :var s=word :results silent
+write (*, '(a4)') s
 #+end_src
-
-#+begin_src fortran :var s=42.0
-print *, 's = ', s
-print *, 'kind(s) = ', kind(s)
+* 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
 
-#+begin_src fortran
-program ex
-print *, output of ex program
-end program ex
+#+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
+#+begin_src fortran :var s=word :results silent
 program ex
 print *, output of ex program
 end program ex
 #+end_src
 
-Real array as input
-#+begin_src fortran :var s='(1.0 2.0 3.0)
-print *, s
-#+end_src
-
-#+tblname: test_tbl
-| 1.0 |
-| 2.0 |
-
-Real array as input
-#+begin_src fortran :var s=test_tbl
-print *, s
-#+end_src
-
 Fails to compile (TODO: error check in ob-fortran.el)
-#+begin_src fortran :var s='(1 ())
+#+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
+#+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
+#+begin_src fortran :cmdline 23 :results silent
 character(len=255) :: cmd
-call get_command(cmd)
+call get_command_argument(1, cmd)
 write (*,*) trim(cmd)
 #+end_src
diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob

[O] [org-babel] a patch with fortran support

2011-07-19 Thread Sergey Litvinov
Please consider an implementation of fortran support for
org-babel. The patch adds contrib/babel/langs/ob-fortran.el
(modification of lisp/ob-C.el) and
testing/examples/ob-fortran-test.org with tests.
From a18cbc80770d985d6ca6bdada07120f7daf65c02 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Sun, 17 Jul 2011 15:31:03 +0200
Subject: [PATCH] Add fortran support to babel

---
 contrib/babel/langs/ob-fortran.el|  191 ++
 testing/examples/ob-fortran-test.org |   67 
 2 files changed, 258 insertions(+), 0 deletions(-)
 create mode 100644 contrib/babel/langs/ob-fortran.el
 create mode 100644 testing/examples/ob-fortran-test.org

diff --git a/contrib/babel/langs/ob-fortran.el b/contrib/babel/langs/ob-fortran.el
new file mode 100644
index 000..bb6948f
--- /dev/null
+++ b/contrib/babel/langs/ob-fortran.el
@@ -0,0 +1,191 @@
+;;; ob-fortran.el --- org-babel functions for fortran
+;; Copyright (C) 2010  Free Software Foundation, Inc.
+
+;; Author: Sergey Litvinov (based on ob-C.el by Eric Schulte)
+;; Keywords: literate programming, reproducible research, fortran
+;; Homepage: http://orgmode.org
+;; Version: 7.6
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating fortran code.
+;;
+
+;;; Code:
+
+;; Org-Babel support for evaluating fortran code.
+;;
+
+(require 'ob)
+(require 'ob-eval)
+(require 'cc-mode)
+
+(declare-function org-entry-get org
+		  (pom property optional inherit literal-nil))
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '(fortran . F90))
+
+(defvar org-babel-default-header-args:fortran '())
+
+(defvar org-babel-fortran-compiler gfortran
+  fortran command used to compile a fortran source code file into an
+  executable.)
+
+(defun org-babel-execute:fortran (body params)
+  Execute BODY according to PARAMS.  This function calls
+`org-babel-execute:fortran'.
+  (org-babel-execute:fortran body params))
+
+(defun org-babel-execute:fortran (body params)
+Execute a block of fortran code with org-babel.  This function is
+called by `org-babel-execute-src-block'.
+  (org-babel-fortran-execute body params))
+
+(defun org-babel-expand-body:fortran (body params)
+  Expand a block of fortran code with org-babel according to it's
+header arguments (calls `org-babel-fortran-expand').
+  (org-babel-fortran-expand body params))
+
+(defun org-babel-execute:fortran (body params)
+  Execute a block of fortran code with org-babel.  This function is
+called by `org-babel-execute-src-block'.
+  (org-babel-fortran-execute body params))
+
+(defun org-babel-expand-body:fortran (body params)
+  Expand a block of fortran code with org-babel according to it's
+header arguments (calls `org-babel-fortran-expand').
+  (org-babel-fortran-expand body params))
+
+(defun org-babel-fortran-execute (body params)
+  This function should only be called by `org-babel-execute:fortran'
+  (let* ((tmp-src-file (org-babel-temp-file
+			fortran-src-
+			.F90))
+ (tmp-bin-file (org-babel-temp-file fortran-bin-))
+ (cmdline (cdr (assoc :cmdline params)))
+ (flags (cdr (assoc :flags params)))
+ (full-body (org-babel-fortran-expand body params))
+ (compile
+	  (progn
+	(with-temp-file tmp-src-file (insert full-body))
+	(org-babel-eval
+	 (format %s -o %s %s %s
+		 org-babel-fortran-compiler
+		 (org-babel-process-file-name tmp-bin-file)
+		 (mapconcat 'identity
+(if (listp flags) flags (list flags))  )
+		 (org-babel-process-file-name tmp-src-file)) 
+((lambda (results)
+   (org-babel-reassemble-table
+	(if (member vector (cdr (assoc :result-params params)))
+	(let ((tmp-file (org-babel-temp-file f-)))
+	  (with-temp-file tmp-file (insert results))
+	  (org-babel-import-elisp-from-file tmp-file))
+	  (org-babel-read results))
+	(org-babel-pick-name
+	 (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+	(org-babel-pick-name
+	 (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)
+ (org-babel-trim
+   (org-babel-eval
+	(concat tmp-bin-file (if cmdline (concat   cmdline) )) )
+
+(defun org-babel-fortran-expand (body params)
+  Expand a block of fortran or fortran code with org-babel according to
+it's header arguments

[O] [BABEL, PATCH] ob-maxima.el add variables and graphical output

2011-07-19 Thread Litvinov Sergey
I would like to contribute an extension of babel maxima support.
The patch adds variables and graphical output (currently limited to png
files). There is a file with examples (tests). It is not ERTed yet.
org-mode/testing/examples/ob-maxima-test.org
From e383e0aa6e0a996033f86b8346205b1a38a124da Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Tue, 19 Jul 2011 00:33:52 +0200
Subject: [PATCH] Extend ob-maxima: add input variables and graphic output

---
 lisp/ob-maxima.el   |   91 +-
 testing/examples/ob-maxima-test.org |   63 
 2 files changed, 130 insertions(+), 24 deletions(-)
 create mode 100644 testing/examples/ob-maxima-test.org

diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
index 6bd5d39..1344384 100644
--- a/lisp/ob-maxima.el
+++ b/lisp/ob-maxima.el
@@ -32,47 +32,90 @@
 ;;
 ;; 1) there is no such thing as a session in maxima
 ;;
-;; 2) we are generally only going to return output from maxima
-;;
-;; 3) we are adding the cmdline header argument
-;;
-;; 4) there are no variables
+;; 2) we are adding the cmdline header argument
 
 ;;; Code:
 (require 'ob)
 
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '(maxima . max))
+
 (defvar org-babel-default-header-args:maxima '())
 
 (defun org-babel-maxima-expand (body params)
   Expand a block of Maxima code according to its header arguments.
-  body)
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var
+ (mapconcat 'identity
+		(list
+		 ;; graphic output
+		 (let ((graphic-file (org-babel-maxima-graphical-output-file params)))
+		   (if graphic-file  
+		   (format 
+			set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]); 
+			graphic-file)
+		 ))
+		 ;; variables
+		 (mapconcat 'org-babel-maxima-var-to-maxima vars \n)
+		 ;; body
+		 body
+		 gnuplot_close ()$)
+		\n)))
 
 (defun org-babel-execute:maxima (body params)
   Execute a block of Maxima entries with org-babel.  This function is
 called by `org-babel-execute-src-block'.
   (message executing Maxima source code block)
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) )))
-	 (cmdline (cdr (assoc :cmdline params)))
-	 (in-file (org-babel-temp-file maxima-))
-	 (cmd (format maxima --very-quiet -r 'batchload(%S)$' %s
-		  in-file cmdline)))
-(with-temp-file in-file (insert body))
-(message cmd)
-((lambda (raw) ;;  | grep -v batch | grep -v 'replaced' | sed '/^$/d' 
-   (mapconcat
-	#'identity
-	(delq nil
-	  (mapcar (lambda (line)
-			(unless (or (string-match batch line)
-(string-match ^rat: replaced .*$ line)
-(= 0 (length line)))
-			  line))
-		  (split-string raw [\r\n]))) \n))
- (org-babel-eval cmd 
+  (let ((result
+	 (let* ((result-params (split-string (or (cdr (assoc :results params)) )))
+		(cmdline (cdr (assoc :cmdline params)))
+		(in-file (org-babel-temp-file maxima- .max))
+		(cmd (format maxima --very-quiet -r 'batchload(%S)$' %s
+			 in-file cmdline)))
+	   (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
+	   (message cmd)
+	   ((lambda (raw) ;;  | grep -v batch | grep -v 'replaced' | sed '/^$/d' 
+	  (mapconcat
+	   #'identity
+	   (delq nil
+		 (mapcar (lambda (line)
+			   (unless (or (string-match batch line)
+	   (string-match ^rat: replaced .*$ line)
+	   (= 0 (length line)))
+ line))
+			 (split-string raw [\r\n]))) \n))
+	(org-babel-eval cmd ) 
+(if (org-babel-maxima-graphical-output-file params) 
+	nil
+  result)))
+
 
 (defun org-babel-prep-session:maxima (session params)
   (error Maxima does not support sessions))
 
+(defun org-babel-maxima-var-to-maxima (pair)
+  Convert an elisp val into a string of maxima code specifying a var
+of the same value.
+  (let ((var (car pair))
+(val (cdr pair)))
+(when (symbolp val)
+  (setq val (symbol-name val))
+  (when (= (length val) 1)
+(setq val (string-to-char val
+  (format %S: %s$ var 
+	  (org-babel-maxima-elisp-to-maxima val
+
+(defun org-babel-maxima-graphical-output-file (params)
+  Name of file to which maxima should send graphical output.
+  (and (member graphics (cdr (assq :result-params params)))
+   (cdr (assq :file params
+
+(defun org-babel-maxima-elisp-to-maxima (val)
+  Return a string of maxima code which evaluates to VAL.
+  (if (listp val)
+  (concat [ (mapconcat #'org-babel-maxima-elisp-to-maxima val , ) ])
+(format %s val)))
+
+
 (provide 'ob-maxima)
 
 ;; arch-tag: d86c97ac-7eab-4349-8d8b-302dd09779a8
diff --git a/testing/examples/ob-maxima-test.org b/testing/examples/ob-maxima-test.org
new file mode 100644
index 000..23c76e7
--- /dev/null
+++ b/testing/examples/ob-maxima-test.org
@@ -0,0 +1,63 @@
+* Test org maxima file
+#+begin_src maxima :var s=4 :results silent
+print(s);
+#+end_src
+
+Pass a string
+#+begin_src

[O] [BABEL,PATCH] ob-fortran

2011-07-18 Thread Litvinov Sergey
Please consider an implementation of fortran support for
org-babel. The patch adds contrib/babel/langs/ob-fortran.el
(modification of lisp/ob-C.el) and
testing/examples/ob-fortran-test.org with tests.

From 2ac9b86a6387cae1472e3ed288a3a133be72318c Mon Sep 17 00:00:00 2001
From: Litvinov Sergey slitvi...@gmail.com
Date: Mon, 18 Jul 2011 09:44:07 +0200
Subject: [PATCH] Add fortran to babel

---
 contrib/babel/langs/ob-fortran.el|  191 ++
 testing/examples/ob-fortran-test.org |   76 ++
 2 files changed, 267 insertions(+), 0 deletions(-)
 create mode 100644 contrib/babel/langs/ob-fortran.el
 create mode 100644 testing/examples/ob-fortran-test.org

diff --git a/contrib/babel/langs/ob-fortran.el b/contrib/babel/langs/ob-fortran.el
new file mode 100644
index 000..6fdf416
--- /dev/null
+++ b/contrib/babel/langs/ob-fortran.el
@@ -0,0 +1,191 @@
+;;; ob-fortran.el --- org-babel functions for fortran
+;; Copyright (C) 2010  Free Software Foundation, Inc.
+
+;; Author: Sergey Litvinov (based on ob-C.el by Eric Schulte)
+;; Keywords: literate programming, reproducible research, fortran
+;; Homepage: http://orgmode.org
+;; Version: 7.6
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating fortran code.
+;;
+
+;;; Code:
+
+;; Org-Babel support for evaluating fortran code.
+;;
+
+(require 'ob)
+(require 'ob-eval)
+(require 'cc-mode)
+
+(declare-function org-entry-get org
+		  (pom property optional inherit literal-nil))
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '(fortran . F90))
+
+(defvar org-babel-default-header-args:fortran '())
+
+(defvar org-babel-fortran-compiler gfortran
+  fortran command used to compile a fortran source code file into an
+  executable.)
+
+(defun org-babel-execute:fortran (body params)
+  Execute BODY according to PARAMS.  This function calls
+`org-babel-execute:fortran'.
+  (org-babel-execute:fortran body params))
+
+(defun org-babel-execute:fortran (body params)
+Execute a block of fortran code with org-babel.  This function is
+called by `org-babel-execute-src-block'.
+  (org-babel-fortran-execute body params))
+
+(defun org-babel-expand-body:fortran (body params)
+  Expand a block of fortran code with org-babel according to it's
+header arguments (calls `org-babel-fortran-expand').
+  (org-babel-fortran-expand body params))
+
+(defun org-babel-execute:fortran (body params)
+  Execute a block of fortran code with org-babel.  This function is
+called by `org-babel-execute-src-block'.
+  (org-babel-fortran-execute body params))
+
+(defun org-babel-expand-body:fortran (body params)
+  Expand a block of fortran code with org-babel according to it's
+header arguments (calls `org-babel-fortran-expand').
+  (org-babel-fortran-expand body params))
+
+(defun org-babel-fortran-execute (body params)
+  This function should only be called by `org-babel-execute:fortran'
+  (let* ((tmp-src-file (org-babel-temp-file
+			fortran-src-
+			.F90))
+ (tmp-bin-file (org-babel-temp-file fortran-bin-))
+ (cmdline (cdr (assoc :cmdline params)))
+ (flags (cdr (assoc :flags params)))
+ (full-body (org-babel-fortran-expand body params))
+ (compile
+	  (progn
+	(with-temp-file tmp-src-file (insert full-body))
+	(org-babel-eval
+	 (format %s -o %s %s %s
+		 org-babel-fortran-compiler
+		 (org-babel-process-file-name tmp-bin-file)
+		 (mapconcat 'identity
+(if (listp flags) flags (list flags))  )
+		 (org-babel-process-file-name tmp-src-file)) 
+((lambda (results)
+   (org-babel-reassemble-table
+	(if (member vector (cdr (assoc :result-params params)))
+	(let ((tmp-file (org-babel-temp-file f-)))
+	  (with-temp-file tmp-file (insert results))
+	  (org-babel-import-elisp-from-file tmp-file))
+	  (org-babel-read results))
+	(org-babel-pick-name
+	 (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+	(org-babel-pick-name
+	 (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)
+ (org-babel-trim
+   (org-babel-eval
+	(concat tmp-bin-file (if cmdline (concat   cmdline) )) )
+
+(defun org-babel-fortran-expand (body params)
+  Expand a block of fortran or fortran code with org-babel according to
+it's header arguments

[Orgmode] Re: [babel] maxima support?

2011-02-25 Thread Litvinov Sergey
Thanks.
Works like a charm.


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] [babel] maxima support?

2011-02-23 Thread Litvinov Sergey
I have not found (i)maxima on this page.
http://orgmode.org/worg/org-contrib/babel/languages.html
(Babel: Languages)

Has someone implemented it?


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] 2 active dates on the same day

2010-11-18 Thread Sergey Konoplev
Hello,

I have the task containing 2 active dates on the same day.

** TODO Some task
   2010-11-18 Thu 10:00
   2010-11-18 Thu 11:00

I expect it to be mentioned 2 times in the agenda but it is not. I see
only the first one, does not meter if it is later or earlier date.

Day-agenda (W46):
Thursday   18 November 2010
   8:00.. 
  10:00.. TODO Some task
  10:00.. 
  12:00.. 
  14:00.. 
  16:00.. 
  18:00.. 
  20:00.. 

What should I do to make the second date appear?
If I have wrong understanding of the tool I would be grateful if
somebody explain it to me.

-- 
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: gray...@gmail.com / Skype: gray-hemp

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Average payment rate with org-mode

2010-09-01 Thread Sergey Dimchenko
Hi!

I'd like to assign every TODO item in a file some payment amount
value, so after item is DONE I can get my average payment
(PAYMENT/TIME).
And I'd like clocktable to have additional payment amount and
average payment columns.

Can you suggest any way to accomplish this?

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] org-mode + pomodoro

2010-08-30 Thread Sergey Konoplev
On 27 August 2010 21:15, A. Ryan Reynolds a.ryan.reyno...@gmail.com wrote:
 I do this using Org-Mode and a kitchen timer. I clock in when I wind
 the timer, and clock out when it dings, instead of just marking with
 X's. To record distractions I keep a scratch buffer in org-mode open,
 although there may be a better way to capture distractions on the
 urgent and unplanned list using remember mode to file them away into a
 more organized system. I just haven't had time to read about it. I
 like the fact that the urgent  unplanned items don't go anywhere
 unless I decide to file them though, because it keeps my to-do list
 cleaner that way. During my most distracted periods I tend to capture
 a lot of stray to-do items of only marginal utility.

 I'm not sure my personal workflow will work exactly right for anyone
 but myself (and it's still a work in progress for me too!), but I'm
 happy to answer any other questions you might have about it.

Thank you. I will try it with http://tomatoi.st timer.

 --
 A. Ryan Reynolds




-- 
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: gray...@gmail.com / Skype: gray-hemp / ICQ: 29353802

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Strange behavior of C-RET and C-S-RET

2008-11-03 Thread Sergey A.
Hello.

I verified. The latest org-mode from git doesn't contain this bug. Thanks a lot!

2008/11/2 Carsten Dominik [EMAIL PROTECTED]:
 I believe this is fixed now, please verify.

 - Carsten

 On Nov 1, 2008, at 2:22 AM, Sergey A. wrote:

 Hello.

 I didn't think that the bug will be so difficult to reproduce.

 In my case, the bug always happens with the following file:

 *** foo
 * bar

 Below is the steps to reproduce that 100% works to me:

 1) File is opened, headline is folded, cursor is on the second asterisk:

 *[*]* foo...

 2) After pressing C-RET, I see the following:

 *** foo
 ...
 ***

 If instead of * bar there is bar, then the bug doesn't happen.

 I've deleted some tweaks to orgmode, so my config now is:

 (add-to-list 'auto-mode-alist '(\\.org\\' . org-mode))
 (global-set-key \C-cl 'org-store-link)
 (global-set-key \C-ca 'org-agenda)
 (global-set-key \C-cb 'org-iswitchb)

 (add-hook 'org-mode-hook 'turn-on-font-lock)

 I've rebuild my emacs from CVS before testing.

 P.S. I use Archlinux.

 --
 Sergey.


 ___
 Emacs-orgmode mailing list
 Remember: use `Reply All' to send replies to the list.
 Emacs-orgmode@gnu.org
 http://lists.gnu.org/mailman/listinfo/emacs-orgmode




___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] An another small bug with C-RET

2008-11-03 Thread Sergey A.
Hello.

This bug isn't so significant, but maybe the following steps to
reproduce will help to identify more complex bugs (if those exist)
based on this.

Suppose we have the following file opened in your emacs:

*** foo
* bar

1. Move the cursor to the end of the last line (here [] represents the cursor):

*** foo
* bar[]

and type some C-k to delete all the possible spaces and newline
symbols. Don't save file after this.

2. Then type C-RET. Here is what you'll see:

*** foo
* bar* []

Here is what I expected to see:

*** foo
* bar
* []

I use the latest emacs from CVS and the latest org-mode from git.

Thanks.

--
Sergey


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Strange behavior of C-RET and C-S-RET

2008-10-31 Thread Sergey A.
Hello.

I didn't think that the bug will be so difficult to reproduce.

In my case, the bug always happens with the following file:

*** foo
* bar

Below is the steps to reproduce that 100% works to me:

1) File is opened, headline is folded, cursor is on the second asterisk:

*[*]* foo...

2) After pressing C-RET, I see the following:

*** foo
...
***

If instead of * bar there is bar, then the bug doesn't happen.

I've deleted some tweaks to orgmode, so my config now is:

(add-to-list 'auto-mode-alist '(\\.org\\' . org-mode))
(global-set-key \C-cl 'org-store-link)
(global-set-key \C-ca 'org-agenda)
(global-set-key \C-cb 'org-iswitchb)

(add-hook 'org-mode-hook 'turn-on-font-lock)

I've rebuild my emacs from CVS before testing.

P.S. I use Archlinux.

--
Sergey.


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode