When I run a J code block in org mode the java jconsole pops up instead. So must be sending a jconsole command instead of ijconsole... Of course J code block is not evaluated.
How do I fix this so that J code blocks are correctly evaluated in org mode?
A background on my setup:
I got j-mode working once I set j-console-cmd to "ijconsole-9.01".
So j-mode works fine it is just evaluating J code blocks in org mode that I have problems with.
FYI the J portion of my init file is this (as recommended on the j-mode github readme):
(add-to-list 'load-path "~/.emacs.d/elpa/j-mode-20171224.1856/")
(autoload 'j-mode "j-mode.el" "Major mode for editing J files" t)
;; Add for detection of j source files if the auto-load fails
(add-to-list 'auto-mode-alist '("\\.ij[rstp]$" . j-mode))
Here's the babel part of my init.el:
(org-babel-do-load-languages
'org-babel-load-languages
'((J . t)
(python . t)))
The j.org file I am attempting to run is:
This is an example j org mode doc.
#+begin_src J :exports both
'Hello , World!'
#+end_src
#+begin_src J
load 'plot'
plot 1 o. 0.1 * i.200
#+end_src
Thanks.
Okay I solved it!
Variable org-babel-J-command was(incorrectly) set to "jconsole".This opened java instead of evaluating J code in ijconsole...
I added this to init.el:
(setq org-babel-J-command "ijconsole-9.01")
And now J code blocks evaluate correctly.
:)
I'll be honest and say that I have not seen this done before, so it is completely outside of my range of experience. What I was able to do within J console was to wrap your commands in an anonymous verb. This essentially makes the sentences execute as one line and it may be the multi-line issue that is creating this problem.
I would try running
3 : 0 ''
load 'plot'
plot 1 o. 0.1 * i.200
)
within your org mode and see if this 'single line' form gets around your problem.
Related
Working through SICP using Emacs, Geiser, and MIT Scheme, I decided to switch over to Racket in order to properly do the exercises in section 2.2.4 involving the Picture Language.
Configuration
I got a setup together that works for MIT Scheme and Racket using the following ~/.emacs configuration:
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(setq geiser-mit-binary "/usr/bin/scheme")
(setq geiser-racket-binary "/usr/bin/racket")
(setq geiser-active-implementations '(mit racket))
(add-to-list 'auto-mode-alist '("\\.rkt\\'" . geiser-mode))
Workflow with MIT Scheme
Here's my workflow for working with MIT Scheme:
First, I open a file (fib.scm) using emacs fib.scm. I'm asked to pick the Scheme implementation, which I answer with mit.
Second, I write my fib function, press C-c C-z to open a REPL.
Third, I switch back to the code buffer with C-x o and evaluate it using C-c C-b.
Fourth, I switch to the REPL buffer with C-x o and evaluate some expressions.
This it how it looks like:
Workflow with Racket
Here's my (intended) workflow for working with the SICP language of Racket:
First, I open a file (fib.rkt) using emacs fib.rkt. Interestingly, I'm not asked to pick a Scheme implementation.
Second, I write my fib function, but use #lang sicp in the first line. Then I open the REPL using C-c C-z.
Third, I switch back to the code buffer with C-x o and evaluate it using C-c C-b, which gives no error message, but prints => #<void> at the very bottom.
Fourth, I switch back to the REPL buffer with C-x o, where I fail to evaluate an expression like (fib 3):
2 racket#> (fib 3)
3 fib: undefined;
4 cannot reference an identifier before its definition
5 in module: top-level
6 context...:
7 body of top-level
8 /usr/share/racket/collects/racket/repl.rkt:11:26
This it how it looks like:
What am I doing wrong? Is it the configuration, is it the way I use it?
Example with sicp-pict
When I run the following code using the Racket workflow from above, the picture of Einstein is properly displayed:
#lang sicp
(#%require sicp-pict)
(paint einstein)
So my setup is not entirely broken…
Addendum
Having re-installed the geiser-racket package, I'm now able to start a REPL. I'm also able to evaluate the entire buffer using C-c C-b, which prints => #<void> to the bottom of the screen.
However, when I try to actually invoke a function, I get this error:
1 Welcome to Racket v8.6 [cs].
2 racket#> (fib 3)
3 +: contract violation
4 expected: number?
5 given: #<procedure:fib>
6 context...:
7 /usr/share/racket/collects/racket/private/norm-define.rkt:52:83: body of top-level
8 /usr/share/racket/collects/racket/repl.rkt:11:26
Edit: Oh dear, it was a simple syntax error... my bad! Everything is fine now!
To finish things up, I just post the steps I have taken to get everything to run:
Use melpa instaed of melpa-stable (~/emacs):
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
Refresh the packages after re-opening Emacs:
M-x package-refresh-contents
Install racket-mode:
M-x package-install RET racket-mode
Install the package geiser-racket:
M-x package-install RET geiser-racket
Extend your Geiser config (~/emacs):
(setq geiser-mit-binary "/usr/bin/scheme")
(setq geiser-racket-binary "/usr/bin/racket")
(setq geiser-active-implementations '(mit racket))
Start using the picture language:
#lang sicp
(#%require sicp-pict)
(paint einstein)
Open it in Emacs:
emacs ../examples/einstein.rkt
Start a Racket REPL and evaluate the whole buffer:
C-c C-z
C-x o
C-c C-b
An image of Einstein should appear.
I try to use C-c ' to call org-edit-src-exit to edit "dot" source code. How could I make graphviz-mode the default major mode on that source code editing buffer?
I have this in some old files, but I'm not currently using any of it so you'll have to research if it works or if you can fix it to apply here.
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)
(emacs-lisp . t)
(latex . t)
(sh . t)
))
Be sure to use C-h f = M-x describe-function and C-h v = M-x describe variable, if you're not already familiar with them. (With cursor on (or to the right of?) expression Emacs will guess what term you mean.) It may help you discover the solution given clues.
The mode for Graphviz is graphviz-dot-mode, and it can be installed from MELPA or Marmalade. After that you can specify the mode in the source block like usual:
#+BEGIN_SRC graphviz-dot
...
#_END_SRC
When passing arguments to code block that exports results Org-mode fails to export with the error "Wrong type argument: listp". How can I fix this?
Here is an example. When it is exported it gives the error 'Wrong type argument: listp, "bar"'.
#+TITLE: Example
#+SOURCE: example-one
#+BEGIN_SRC emacs-lisp :exports results
(setq foo "bar")
#+END_SRC
#+SOURCE: example-two
#+BEGIN_SRC emacs-lisp :exports results :var x=example-one
(setq foo (concat x x))
#+END_SRC
I am running Org-mode 7.6 in Emacs 23.3.1.
This issue might simply be with the older copy of Org that you're running. Tested it today with a recent git pull and get the results below. As pmr suggested, you might have better luck asking on the mailing list ( emacs-orgmode#gnu.org ) since there might be someone there who would know what caused this issue and what might have been changed to resolve it in later versions.
The features and examples discussed in the manual are based on the current release version (7.8.03 in this case) so they will not always be compatible with older versions. Does the info-node in your version indicate that it should work?
These 2 commands will show you the associated info-nodes for that section of the Org Manual
; The node itself
(Info-goto-node "(org) var")
; Parent node, in case the first node isn't present
(Info-goto-node "(org) Working With Source Code")
Test Results
Org
* Test variable passing
Headlines are created to split the code blocks apart. When trying to eval on export I'm getting a syntax read error which was reported here: http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00993.html
** Ex 1
#+name: example-one
#+BEGIN_SRC emacs-lisp :exports results
(setq foo "bar")
#+END_SRC
** Ex 2
#+name: example-two
#+BEGIN_SRC emacs-lisp :exports results :var x=example-one
(setq foo (concat x x))
#+END_SRC
Latex
\vspace*{1cm}
Headlines are created to split the code blocks apart. When trying to eval on export I'm getting a syntax read error which was reported here: \href{http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00993.html}{http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00993.html}
\section{Ex 1}
\label{sec-1}
\begin{verbatim}
bar
\end{verbatim}
\section{Ex 2}
\label{sec-2}
\begin{verbatim}
barbar
\end{verbatim}
in your .emacs file - make sure you have the following line:
(setq org-babel-load-languages
(quote ((emacs-lisp . t))))
I have switched to using emacs-ess for my R code development and it is working great. I would like to be able to write some small R code I am using for debugging my R script into the scratch buffer, and be able to execute the scratch buffer code in the R process buffer. I've found how I could change the scratch buffer's mode to text by putting the following in the .emacs file:
(setq initial-major-mode 'text-mode)
Is there a similar statement I can put in my .emacs file that would make the scratch buffer have the ess-mode? I tried the following which results in an error about wrong type argument:
(setq initial-major-mode 'ess-mode)
What you want is (setq initial-major-mode 'R-mode). Alternatively, you could just do M-x R-mode when in the scratch buffer to change the major mode.
I'm using Emacs 23.1 with ESS 5.4 to edit an Sweave file. I'd like to turn off the default AUCTeX indentation behavior in the buffer (to avoid annoyances with code chunks contained in itemized lists), so at the top of the file I have % -*- LaTeX-indent-level: 0; LaTeX-item-indent: 0; -*-. When I open the buffer and run C-h v LaTeX-indent-level, I get what I wanted:
LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 0
Local in buffer test.Rnw; global value is 2
This variable is a file local variable.
However, after I edit a code chunk, it returns to the default behavior. C-h v LaTeX-indent-level now yields:
LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 2
I tried the fix suggested in the noweb-mode FAQ, which suggests adding
(add-hook 'noweb-select-mode-hook
'(lambda () (hack-local-variables-prop-line)))
to my .emacs. The behavior described above persisted when I did this.
Is there any way I can get buffer-local variables to work in this situation? I would prefer not to have to change my .emacs to set LaTeX-indent-level to 0 in all Sweave/noweb buffers.
I haven't tested this, but try the following instead:
(add-hook 'noweb-select-mode-hook
'(lambda () (hack-local-variables)))
Perhaps hack-local-variables-prop-line has been changed to merely parse the values, not instate them.