Foxdot-mode for emacs

Good evening, the doc points to a link to a page offering an emacs-mode for foxdot. Unfortunately the proposed method does not work. I suspect it wouldn’t take much for it to work, but I’m not coding enough to get started. I’m looking for volunteers.

Hello Jean

Ago a time, I wrote a foxdot-mode for Emacs. I did some corrections and uploaded it to a github repository: https://github.com/superguaricho/foxdot-mode

Please, clone the repository, give a try and tell me if it runs for you. Is possible that it has bugs. I have only tested it in linux (debian and Ububtu). I think that is good to begin.

1 Like

Hi,

I am under Debian Linux.
It’s weird.
When I open a .py file I have the information:

Can’t guess python-indent-offset, using defaults:4

Alt+c foxdot

Not found by emacs

If I evaluate the buffer “foxdot-mode.el” or the line in .emacs I can then launch the mode which results in the opening of a buffer with the line:

FoxDot>

The command C-c C-c shows the evaluated line in the mini-buffer without sound, the other commands are not recognized.

Hi Jean

Thanks for test my version of foxdot-mode.el.

I fixed some bugs in foxdot-mode.el. There was problems with “foxdot-start-foxdot” function.

I am under Debian Linux.
It’s weird.

We can then test on other platforms.

I assume that you have installed FoxDot, you have started SuperCollider and you have started FoxDot quark in SuperCollider. Be sure that SuperCollider is working, play some synth in it.

You can also run SuperCollider from Emacs using the Emacs package from SuperColider sources.

I suposse that you have the path to foxdot-mode.el in load-path list. I use:

(add-to-list 'load-path (expand-file-name “site-lisp” user-emacs-directory))

It would be portable.

I forgot to point out that you have to add the following line to ~ / .emacs:

(require 'foxdot-mode)

When I open a .py file I have the information:
Can’t guess python-indent-offset, using defaults:4

That message its a warning. I have it too. It will not appear if you add to ~/.emacs:

(setq python-indent-guess-indent-offset-verbose nil)

See: Emacs 24.3 python: Can't guess python-indent-offset, using defaults 4 - Stack Overflow

Alt+c foxdot
Not found by emacs

If you have loaded the foxdot-emacs.el file using «(require 'foxdot-mode)», type instead «Alt+x foxdot» (press the “Alt” and “x” keys at same time and release them, then type in the mini buffer: «foxdot» ENTER key (without « »). If does not run the FoxDot process with this, then the ‘foxdot-mode’ won’t be loaded in your .py file and nothing will work. If foxdot-mode is loaded you would must see “Python FoxDot” in the window mode line of the buffers with .py extension files.

You can add the following line to your ~/.emacs file:

(add-to-list 'auto-mode-alist ‘("\.py\’" . 'foxdot-mode))

and when you open a file with .py extension foxdot-mode automatically will be loaded.

This will load foxdot-mode in the buffers with .py extension files.

I hope this works.

greetings!

Hi numa,

With this line in .emacs, i have any error :

(add-to-list 'load-path “~/.emacs.d/your/directory/”)

foxdot-mode don’t launch with monfichier.py

Alt+x foxdot

is ok, a buffer is open with: FoxDot>, but “Python FoxDot” don’t appear in window mode line of monfichier.py

I don’t get any sound output when evaluating a line from monfichier.py

C-c s not recognized.

Hi Jean

Thank for tested it.

Take a look to the updated foxdot-mode. Update your local foxdot-mode repository. From the command line, go to local repository and, if you haven’t made any changes locally, you can use ‘git pull’ to bring down any new commits and add them to your local master branch:

$ git pull origin master

Or delete the local repository and clone again the repo.

foxdot-mode don’t launch with monfichier.py

Add this line to your ~/.emacs:

(add-to-list 'auto-mode-alist '("\\.py)?$" . foxdot-mode))

If you want FoxDot buffer launch when you open “monfichier.py”, add the following line to ~/.emacs:

(add-hook 'foxdot-mode-hook 'foxdot-start-foxdot)

If you do this you don’t need use Alt+x foxdot. The FoxDot interpreter will launch when you open a .py file.

To avoid collisions with other modes, instead of «(add-to-list 'auto-mode-alist '(“\.py)?$” . foxdot-mode))», add the folowing lines to your ~/.emacs:

(add-to-list 'auto-mode-alist '(“\.foxdot)?$” . foxdot-mode))

And change your .py file to .foxdot file: monfichier.py to monfichier.foxdot. Use instead .foxdot files.

I have cloned the foxdot-mode repository in “~/.emacs/site-lisp” path and added these lines to my ~/.emacs file:

(add-to-list 'load-path (expand-file-name "site-lisp/foxdot-mode" user-emacs-directory))
(require 'foxdot-mode)
(add-to-list 'auto-mode-alist '("\\.foxdot)?$" . foxdot-mode))
(add-hook 'foxdot-mode-hook 'foxdot-start-foxdot)

C-c s not recognized.

I have that problem and really don’t now why this. I changed it to “C-c i”.

I don’t get any sound output when evaluating a line from monfichier.py

Are you sure that you have started SuperCollider before use FoxDot?

Try this in SuperCollider:

{ SinOsc.ar(440, 0, 0.1) * Line.kr(5, 0, 1.5, doneAction:2) }.play

You hear something?

If this works, would’t have problems, I think.

greetings

Hurrah !

Error in
(add-to-list 'load-path (expand-file-name “site-lisp/foxdot-mode” user-emacs-directory))

I have remove “foxdot-mode” end it’s ok

Changing .py by .foxdot start foxdot-mode with monfichier.foxdot

Otherwise you must first do Alt-x foxdot then open monfichier.py and do Alt-x foxdot-mode;

I have sound ! :smiley:

It remains to implement the completion mode :wink:

And the “Ctrl .” for the Clock.clear()

All right, I’m glad that now it works for you.

With a similar process it can be installed on other platforms with SuperCollider and the FoxDot python library.

It remains to implement the completion mode

This need some time. I notify you if I have something. With company-mode you can get some completion. Install company from the package manager and add the following line to ~/.emacs:

(add-hook 'foxdot-mode 'company-mode)

.

And the “Ctrl .” for the Clock.clear()

The foxdot-mode has it: Ctrl-c Ctrl-u; or Alt-x foxdot-hush.

Please, clone again foxdot-mode.el, I have fixed some serious bugs in foxdot-start-foxdot when is added (add-hook 'foxdot-mode-hook 'foxdot-start-foxdot).

Thanks a lot for test it.

greetings

Thank you for the Ctrl-c Ctrl-u,

When i “Run Block”, Ctrl-c ECH, it’s ok but i have a comment :

FoxDot> >>> import codecs, os;__pyfile = codecs.open(‘’‘/tmp/pyh0o5XQ’‘’, encoding=‘’‘utf-8’‘’);__code = __pyfile.read().encode(‘’‘utf-8’‘’);__pyfile.close();os.remove(‘’‘/tmp/pyh0o5XQ’‘’);exec(compile(__code, ‘’‘/home/jargenty/Musique/FoxDot/Mazique/practice_var.foxdot’‘’, ‘exec’));

I discovered that you can have several .foxdot buffers open and play them at the same time.

Cool !

Hack for mode-alist, it’s ok :smiley:

(add-to-list 'auto-mode-alist ‘("\.\(?:py\|foxdot\)\’" . foxdot-mode))

Hi Jean

Nice hack.

I pushed some changes.

I added new functions:

foxdot-execute-block: Ctrl+c e
foxdot-execute-block-and go: Ctrl+c Ctrl+e
foxdot-run-block-by-lines: Ctrl+c Ctrl+n
foxdot-run-block-by-lines-and go: Ctrl+c o

These functions have echo in the FoxDot buffer, don’t show the code that you pointed before and you don’t need select the block where is the cursor.

Use foxdot-send-region (Ctrl+c Ctrl+r) if you want send to python a multiline function or any indented block with blank lines in it. You have to select the block before.

Greetings!

Super,

You should suggest to @Ryan to replace in the documentation with your link the one that points to an obsolete foxdot-mode solution. I thought I would do it myself but it would be better if it was you, if you want!

:wink:

Another trick to improve if possible in the FoxDot buffer. The current result line should remain in the middle of the buffer while there it goes down until it disappears beyond the buffer status bar.

Hi Jean

I want add codes to work with supercollider. The old foxdot-mode had something. So, I prefer to wait a little longer.

Hi, numa,

There seems to be a problem with the indentation. In the original FoxDot interface, you can line up like this for example:

b1 >> sawbass(oct=PRand([4,5],[4,28]),
dur=PWhite(.5,4),rate=linvar([-2,2],16), sus=4,
cutoff=var([500,3000],[4,28]),room=2,
lpf=([0,4000],[4,28]))

In emacs with your mode this generates errors like this

FoxDot> >>> lpf=([0,4000],[4,28]))
Traceback (most recent call last):
File “/home/jargenty/.local/lib/python2.7/site-packages/FoxDot/lib/Code/main_lib.py”, line 155, in call
exec(self._compile(code), self.namespace)
File “/home/jargenty/.local/lib/python2.7/site-packages/FoxDot/lib/Code/main_lib.py”, line 106, in _compile
return compile(str(CodeString(string)), “FoxDot”, “exec”)
File “FoxDot”, line 1
lpf=([0,4000],[4,28]))
^
SyntaxError: invalid syntax

However, the syntax is the same.

Start FoxDot in emacs from nothing.

After installing foxdot-mode properly you open emacs and you launch Supercollider as follows :

M-x term

You replace

run program /bin/bash

by

run program sclang

once supercollider launched in the buffer you ask to start FoxDot

FoxDot.start

Then you open a .py or .foxdot file and FoxDot opens in a new buffer.
A board open a second buffer with the command CTRL-x 3 for two horizontal buffers, CTRL-x2 for 2 vertical buffers.

Enjoy

Nice!

You can add this snippet to ~/.emacs

(defun scterm ()
  "Start sclang in Emacs term."
  (interactive)
  (term "sclang")
  (term-line-mode))

(defun fdsend-str-term (string)
   "Send STRING to terminal."
  (let ((b (get-buffer "*terminal*")))
    (if b (with-current-buffer b
             (goto-char (point-max))
             (insert string)
             (term-send-input)
             (sit-for 0.5)
             (term-send-input))
        (message "There is not *terminal* buffer."))))

(defun fdinstall-quark ()
  "Start sclang in Emacs term."
  (interactive)
  (fdsend-str-term "Quarks(\"FoxDot\").install"))

(defun fdstart ()
  "Start sclang in Emacs term."
  (interactive)
  (fdsend-str-term "FoxDot.start"))

Restart Emacs and do:

Alt-x scterm (start sclang in term)
Alt-x fdinstall-quark (install foxdot quark if you need it)
Alt-x fdstart (start foxdot)

greetings