pashinin / workgroups2

Workgroups2 - Emacs session manager
http://workgroups2.rtfd.org/
GNU General Public License v3.0
297 stars 43 forks source link

The ability for workgroups2 to save programming language interpeters #8

Closed codekingplusplus closed 11 years ago

codekingplusplus commented 11 years ago

Inspired by my super user post: http://superuser.com/questions/635013/emacs-workgroups-and-interpreters

We are looking for the capability for workgroups2 to save programming language interpreters inside emacs as shown in the post. In the post I have a python interpreter and an R interpreter. More generally, it would be great for ANY programming language interpreter (the builtin elisp interpreter (ielm) does work!)

The commands are M-x R which starts ESS (emacs speaks statistics) which is the R interpreter and M-x run-python

What I have noticed is that most programming language interpreters are started by M-x run-NAME. This seems to be built-in to emacs, try Mx-run-[TAB] to see the auto-complete list. However, they will not work unless you have installed the associated interpreter and elisp code for the associated mode. For example to run the prolog interpreter I have the following in my .emacs file:

;;;PROLOG
(setq auto-mode-alist (cons (cons ".pl" 'prolog-mode) auto-mode-alist)) (autoload 'run-prolog "prolog" "Start a Prolog sub-process." t) (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t) (autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t) (setq prolog-system 'swi) (setq auto-mode-alist (append '((".pl$" . prolog-mode) (".m$" . mercury-mode)) auto-mode-alist))

I believe I installed SWI-Prolog (the implementation) via Linux's apt-get utility and I believe I installed prolog-mode.el from the emacs package manager MELPA.

Thanks, and let me know if you need more information.

pashinin commented 11 years ago

Thanks for the report. I'll look carefully at it later.
For now - I've writen an article for you (and maybe others) - https://github.com/pashinin/workgroups2/wiki/How-to-restore-a-specific-type-of-buffer It may help to implement this support faster.

pashinin commented 11 years ago

I was able to restore these shells (with last commit): R, Prolog, Python. With basic support they are just started with current directory they had.

pashinin commented 11 years ago

Have you tried an updated version?

codekingplusplus commented 11 years ago

I will either this weekend or next weekend. Unfortunately, (well I guess fortunately too) I have a decent amount of responsibilities or else I might seriously play with emacs all day. It is so much fun but can be very distracting. I am also new to emacs in the sense that I cannot allocate 10 minutes here and say I'll get it done then. It would take me some googling and such.

pashinin commented 11 years ago

No problems! Take your time

codekingplusplus commented 11 years ago

I updated my emacs packages a little later than expected, but it works very well! Thank you very much. One of these days I may get around to modifying a few pieces of the package myself.

For example, it would be nice to keep a list where we could add which interpreters/programs to keep in buffers besides the few I mentioned.

The only thing that seems odd to me is the following which is best explained by example:

I have two workgroups, wg1 and wg2. I load the default workgroup (wg1) on starting emacs (which is a config file named emacs_def.wg), wg2 is also maintained in the active workgroups list when loading emacs_def.wg. So after loading, I switch to wg2 and then open the scratch buffer which is in Fundamental mode. I want the scratch buffer to be in lisp-interaction-mode so I do that. Then I save with C-c w C-s and emacs says: 'Saved emacs_def'. I proceed to close and reopen emacs, switch to wg2 and see that the scratch buffer is still in fundamental mode; even after I saved. -- What went wrong here?

pashinin commented 11 years ago

Nice question but nothing is wrong here. If a buffer exists - WG just opens it. I don't know why your *scratch* buffer is Fundamental, mine is lisp (even for emacs -Q)

WG doesn't save modes. Instead it relies on your settings. So WG opens a file - Emacs chooses a mode for it.

Modes are just hints to use a correct way to save/restore a buffer.

codekingplusplus commented 11 years ago

Can we add support for more interpreters/programs? For example mathematical softare such as SAGE: http://en.wikipedia.org/wiki/Sage_%28mathematics_software%29 and other programming languages such as scheme and common-lisp?

Perhaps we can make this more general. I think you need an ID and a PATH? for each program. Let me know what you need and then we can get started.

codekingplusplus commented 11 years ago

Here is an implementation detail I think would be useful:

How about we provide something along the lines of a configuration file? I'm not too experienced with emacs but I remember when I was debugging something through the help pages I was interlinked to something like a config file for the package I was debugging. Perhaps this was called custom-set-variables?

A good reason for this is customization and flexibility, e.g. I just switched to the IPython interpreter so now I have to get that opening when emacs loads.

pashinin commented 11 years ago

Do you want to make support of new additional buffers == part of WG configuration? If so - it's a great idea! And maybe... some day... Also note - it's better to open a new issue for each problem and request (even small).

codekingplusplus commented 11 years ago

Yes, if you mean users can set these special buffers as part of a configuration then yes. If that is too big of an undertaking, perhaps we can just work on adding support to a few more programs/interpreters.

For example, I think a quick fix for me would be changing the python interpreter to IPython. I am currently looking in: workgroups-specialbufs.el at functions wg-serialize-python-shell-buffer and wg-deserialize-python-shell-buffer

What is the quick fix to change this to the IPython interpreter instead of the default one? **

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 3:45 PM, Sergey Pashinin notifications@github.comwrote:

Do you want to make support of new additional buffers == part of WG configuration? If so - it's a great idea! And maybe... some day...

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-26680843 .

codekingplusplus commented 11 years ago

Wait, nvm I was not thinking and the IPython thing works!

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:13 PM, Steve Styer srs5328@psu.edu wrote:

Yes, if you mean users can set these special buffers as part of a configuration then yes. If that is too big of an undertaking, perhaps we can just work on adding support to a few more programs/interpreters.

For example, I think a quick fix for me would be changing the python interpreter to IPython. I am currently looking in: workgroups-specialbufs.el at functions wg-serialize-python-shell-buffer and wg-deserialize-python-shell-buffer

What is the quick fix to change this to the IPython interpreter instead of the default one? **

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 3:45 PM, Sergey Pashinin <notifications@github.com

wrote:

Do you want to make support of new additional buffers == part of WG configuration? If so - it's a great idea! And maybe... some day...

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-26680843 .

codekingplusplus commented 11 years ago

But the other most helpful interpreter would be common-lisp which I run by using SLIME mode (M-x slime)

Sorry for exploding your inbox!

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:19 PM, Steve Styer srs5328@psu.edu wrote:

Wait, nvm I was not thinking and the IPython thing works!

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:13 PM, Steve Styer srs5328@psu.edu wrote:

Yes, if you mean users can set these special buffers as part of a configuration then yes. If that is too big of an undertaking, perhaps we can just work on adding support to a few more programs/interpreters.

For example, I think a quick fix for me would be changing the python interpreter to IPython. I am currently looking in: workgroups-specialbufs.el at functions wg-serialize-python-shell-buffer and wg-deserialize-python-shell-buffer

What is the quick fix to change this to the IPython interpreter instead of the default one? **

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 3:45 PM, Sergey Pashinin < notifications@github.com> wrote:

Do you want to make support of new additional buffers == part of WG configuration? If so - it's a great idea! And maybe... some day...

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-26680843 .

codekingplusplus commented 11 years ago

Also, how did you learn so much about emacs systems programming? I would like to take the time and become more proficient (just the little things I do know and the enjoyment of the environment makes my programming and life easier/happier/efficient). with emacs; however this probably wouldn't happen till a holiday or my summer vacation.

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:22 PM, Steve Styer srs5328@psu.edu wrote:

But the other most helpful interpreter would be common-lisp which I run by using SLIME mode (M-x slime)

Sorry for exploding your inbox!

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:19 PM, Steve Styer srs5328@psu.edu wrote:

Wait, nvm I was not thinking and the IPython thing works!

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 4:13 PM, Steve Styer srs5328@psu.edu wrote:

Yes, if you mean users can set these special buffers as part of a configuration then yes. If that is too big of an undertaking, perhaps we can just work on adding support to a few more programs/interpreters.

For example, I think a quick fix for me would be changing the python interpreter to IPython. I am currently looking in: workgroups-specialbufs.el at functions wg-serialize-python-shell-buffer and wg-deserialize-python-shell-buffer

What is the quick fix to change this to the IPython interpreter instead of the default one? **

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Sun, Oct 20, 2013 at 3:45 PM, Sergey Pashinin < notifications@github.com> wrote:

Do you want to make support of new additional buffers == part of WG configuration? If so - it's a great idea! And maybe... some day...

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-26680843 .

pashinin commented 11 years ago

That's the question now: http://stackoverflow.com/questions/19561073/how-to-detect-what-shell-is-running-in-emacs-comint-mode

Also, how did you learn so much about emacs systems programming?

I've used Emacs each day for about an year now.

pashinin commented 11 years ago

Check it when Melpa updates. slime was started for me. About restoring any shells... each shell can execute the code specific to it (like hooks or other code) and (I think) we can't automatically determine it. So for now I will just add support for each mode you ask. Please open a new issue each time.

codekingplusplus commented 11 years ago

Thanks! All I need for now is:

SAGE slime (common-lisp)

or did you already do this?

pashinin commented 11 years ago

Only slime

pashinin commented 11 years ago

Although I had some errors starting sage-mode - https://bitbucket.org/gvol/sage-mode/issue/29/symbols-value-as-variable-is-void-comint - I hope restoring it's buffer will work now

codekingplusplus commented 11 years ago

Sergey,

I can see that Sage would like to work, but I am having problems with it too. It hangs on "Sent python-eldoc-setup-code" When it freezes there it stops emacs from loading anything else. I guess there is nothing we can do about that...

Other than that it seems to work good, my only issue is that the CL-REPL chooses a random window to open in each time (this does not happen with the python interpreter -- as the python interpreter always opens in the same window in which I save my session). Recall that I split my emacs screen into 4 windows.

One request: Is it possible to specify via command line which workgroup I want to open? Right now I have two workgroups. I use one for work related tasks, and the other for math.

WG1:

Thanks for all the good work :)

On Fri, Oct 25, 2013 at 6:21 PM, Sergey Pashinin notifications@github.comwrote:

Although I had some errors starting sage-mode - https://bitbucket.org/gvol/sage-mode/issue/29/symbols-value-as-variable-is-void-comint- I hope restoring it's buffer will work now

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-27130448 .

codekingplusplus commented 11 years ago

I didn't finish sending the message; here is my ideal workgroup settings in case you happen to think of better ways to implement these things rather than blindly going about it.

WG1: window1: TODO list with org-mode window2: ielm REPL/eshell window3: python code window4: python interpreter

WG2: window1: TODO list with org-mode window2: eventually SAGE but oh well for right now. window3: lisp code window4: CL-REPL

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Mon, Oct 28, 2013 at 5:50 PM, Steve Styer srs5328@psu.edu wrote:

Sergey,

I can see that Sage would like to work, but I am having problems with it too. It hangs on "Sent python-eldoc-setup-code" When it freezes there it stops emacs from loading anything else. I guess there is nothing we can do about that...

Other than that it seems to work good, my only issue is that the CL-REPL chooses a random window to open in each time (this does not happen with the python interpreter -- as the python interpreter always opens in the same window in which I save my session). Recall that I split my emacs screen into 4 windows.

One request: Is it possible to specify via command line which workgroup I want to open? Right now I have two workgroups. I use one for work related tasks, and the other for math.

WG1:

Thanks for all the good work :)

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Fri, Oct 25, 2013 at 6:21 PM, Sergey Pashinin <notifications@github.com

wrote:

Although I had some errors starting sage-mode - https://bitbucket.org/gvol/sage-mode/issue/29/symbols-value-as-variable-is-void-comint- I hope restoring it's buffer will work now

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-27130448 .

codekingplusplus commented 11 years ago

Take your time :) and sorry for blowing up your inbox...

On Mon, Oct 28, 2013 at 5:54 PM, Steve Styer srs5328@psu.edu wrote:

I didn't finish sending the message; here is my ideal workgroup settings in case you happen to think of better ways to implement these things rather than blindly going about it.

WG1: window1: TODO list with org-mode window2: ielm REPL/eshell window3: python code window4: python interpreter

WG2: window1: TODO list with org-mode window2: eventually SAGE but oh well for right now. window3: lisp code window4: CL-REPL

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Mon, Oct 28, 2013 at 5:50 PM, Steve Styer srs5328@psu.edu wrote:

Sergey,

I can see that Sage would like to work, but I am having problems with it too. It hangs on "Sent python-eldoc-setup-code" When it freezes there it stops emacs from loading anything else. I guess there is nothing we can do about that...

Other than that it seems to work good, my only issue is that the CL-REPL chooses a random window to open in each time (this does not happen with the python interpreter -- as the python interpreter always opens in the same window in which I save my session). Recall that I split my emacs screen into 4 windows.

One request: Is it possible to specify via command line which workgroup I want to open? Right now I have two workgroups. I use one for work related tasks, and the other for math.

WG1:

Thanks for all the good work :)

-Steven Styer

Penn State University -- Class of 2014 BS Mathematics and Computer Science

On Fri, Oct 25, 2013 at 6:21 PM, Sergey Pashinin < notifications@github.com> wrote:

Although I had some errors starting sage-mode - https://bitbucket.org/gvol/sage-mode/issue/29/symbols-value-as-variable-is-void-comint- I hope restoring it's buffer will work now

— Reply to this email directly or view it on GitHubhttps://github.com/pashinin/workgroups2/issues/8#issuecomment-27130448 .

pashinin commented 11 years ago

Is it possible to specify via command line which workgroup I want to open?

I'll try to implement it now. Create new requests - no need to have 1 big page for everything.

pashinin commented 11 years ago

Now you can set wg-open-this-wg variable to a WG name you want to open on start.