Using Kawa in Emacs - emacs

Are there any modes or resources for Kawa in Emacs? I've checked, but am not able to find any. Mostly, I'd like to be able to run a Kawa REPL inside of Emacs, but some kind of completion/syntax checking would be great too.

I don't have any prior experience with Kawa, but I have a "universal" way to deal with REPLs: plugin isend + some hacks
Follow the instructions in section 2 and section 3 of this article http://wenshanren.org/?p=351#sec-2 to setup isend (it's a bit tedious, please let me know if you have any problems)
Open a shell in Emacs, assume the buffer name is *shell*
M-x shell
Open Kawa REPl in *shell*
CLASSPATH=/usr/local/lib/kawa.jar && export CLASSPATH && java kawa.repl
Create a new buffer test.kawa and turn on lisp-mode M-x lisp-mode (you can use any mode you want)
Associate *shell* with test.kawa M-x isend-associate *shell*
Now type some sexps in test.kawa, select them and press C-Enter to send them *shell* for execution (the cursor won't move)

Related

How to make speedbar list the C functions + Unable to use sr-speedbar+macro+command history

I am new to Emacs on Windows XP and have multiple queries which I could not find/understand after a lot of search.
I understand that speedbar will support showing of C functions list. As mentioned in http://stackoverflow.com/questions/259364/how-do-i-configure-emacs-speedbar-for-c-sharp-mode, I added the code in .emacs as
(speedbar 1)
(add-to-list 'speedbar-fetch-etags-parse-list
'("\\.c" . speedbar-parse-c-or-c++tag))
I see the speedbar startup but it never shows the functions. Maybe I need to install etags but cannot find it. I also found gtags but could never find a binary
I copied sr-speedbar.el in ~/emacs.d/ directory. I added (require 'sr-speedbar) in .emacs, commented out speedbar related code, reloaded M-x ~/.emacs but did not find any sr-speedbar. If I uncomment speedbar code and comment sr-speedbar, it shows the speedbar on loading. Emacs is able to find sr-speedbar.el in ~/emacs.d/ directory since if I change filename, it shows an error: unable to find sr-speedbar.
I wanted to make a keyboard macro for logging using tramp and ssh. However, when I record a macro, I have to delete multiple characters to provide the path from the beginnig i.e. emacs automatically shows the last path and so I have to delete all the characeters and then start again with ssh://. The keyboard macro records all backspaces and returns error if the backspaces are more than the length of the current path. Is there a way to avoid it
I configured linum package. I want it to start at the beginning of emacs session automatically with typing M-x linum. How can I do that?
Is there way to retrieve command history (not shell commands) and then replay some command
Thanks again for patience on reading until the point :-)
For C, C++, and other languages, supported by CEDET/Semantic, the Speedbar is able to show functions & other objects. But you need to setup Semantic correctly, for example, you can use my article in CEDET.
As I understand, to enable linum-mode globally, you need to put (global-linum-mode 1) into your ~/.emacs
For 3, there are two options:
just type "/ssh:blabla" at the end of the pre-inserted directory (this directory will be ignored as witnessed by it becoming grey).
do C-a C-k to erase the content of the minibuffer.
For 5, there is repeat-complex-command bound to C-x ESC ESC and there is repeat bound to C-x z.

in emacs how to control which windows to show compile result?

I have used emacs for erlang programming. According to http://emacswiki.org/emacs/CompileCommand, I have configure c-c c for recompile.
In the emacs frame, 6 windows are open, top 3 are for erlang source code reading and writing.
In the below windows, one is supposed for the compie window.
But when different windows is active and recompile, the compile window will switch randomly. How to fix it in one perticular window?
If you start reading at C-hf display-buffer RET (or in the manual at M-: (info "(elisp) Choosing Window") RET), you'll find a bunch of ways in which you can modify the behaviour.
It can get a little complex, but something like this might be all you need in your recompile function:
(let ((display-buffer-overriding-action
'(display-buffer-reuse-window)))
(compile))
I always use dedicated windows when I want to keep things in the one place, so you might also find that useful to look into:
M-: (info "(elisp) Dedicated Windows") RET
I use the toggle-window-dedicated function from Pin Emacs buffers to windows (for cscope) (see also How do I make this Emacs frame keep its buffer and not get resized?)

running scheme from emacs

I'm a newbie to LISP.
I am attempting to invoke the scheme interpreter from within emacs (version 23 running on windows). I loaded the xscheme library by telling emacs to M-x load-library and then entering xscheme at the prompt in the minibuffer. The library loaded, and then I issued the M-x run-scheme command. (I realize that all this loading can be done from .emacs at startup, but I am not concerned with that at the moment.)
So far so good - the *scheme* buffer has been created, and now I'm hoping that I'm able to talk to the scheme interpreter.
However, when I try to evaluate something in that *scheme*buffer (e.g. (define shoe-size 14)), I get this Output file descriptor of scheme is closed message in the minibuffer.
Does anybody know how to fix this in emacs?
(Also, how does one set the major-mode as REPL in the *scheme* buffer?)
Thank you.
Try setting the scheme-program-name variable to the path to your Scheme interpreter. The major-mode of the scheme buffer is probably just comint and you cannot do much about it unless you switch to something more capable like Geiser - something that I'd recommend you do.
Add this line to your .emacs file:
(setq scheme-program-name "gsi")
(Replace "gsi" with the name of your Scheme interpreter.)
You can then start the interpreter with M-x run-scheme. You can evaluate pieces of code by using C-x C-e (to evaluate the sexp before the point) or with C-M-x to evaluate the sexp you're in right now. You can also load a file with C-c C-l.
I'll start by saying that I'm very new to programming, scheme and SICP, but I'm trying to work through the course and watch the lectures that are online.
I'm running emacs on Ubuntu 12.10 and I really wanted to get MIT scheme working in emacs instead of relying on Edwin.
The above tips didn't work for me, but here's the step-by-step instructions that did work:
Install emacs 24 from the Ubuntu Software Center (search "emacs" and install it!)
Open a terminal (ALT + CTRL + t)
Go to your home directory (cd ~)
Open the hidden file .emacs in gedit (gedit .emacs)
On the first line of the file, type exactly what's after the colon: (require 'xscheme)
Save the changes to .emacs
That's it!!!
You can now open .scm files in emacs and use commands like C-x C-e.
*directions courtesy of http://alexott.net/en/writings/emacs-devenv/EmacsScheme.html#sec14
My guess is that it's just a known issue I still dunno how to sort that out (it's out of my current skills) but I got a macro that probably helps: just after writing the s-exp you can do Cc-Cz (it calls the geiser REPL) then C-spc, C-M-b, M-w, C-x-o, C-y and RET.
There are a variation (same, placed just after writing the s-exp): C-spc, C-M-b, M-w, C-c Cz, C-y and RET

recipe for building an emacs wrapper mode around a command line program?

I want to play and experiment with a number of software tools, each of which will have a command line interface. Some of these tools include hbase, pig, erlang, and prolog. I want to use emacs as a UI to these tools the same way I can run a python shell with M-x run-python or a Lisp interpreter with ielm mode.
Is there a recipe I can follow to wrap one of these command line tools in an emacs mode? I'm looking for something which will display the tool's prompt, let me search through the history with C-c C-n/C-p, submit the current input to the tool's process which I hit Enter, and display the tool's output.
I know many of these tools probably have emacs modes already, I am interested in how to quickly build one if nothing exists.
I recently built an "inferior gosu mode" for the gosu language. It actually turned out to be pretty simple: I just extended comint which is the mode on which both shell and ielm are based. Here is the important bit of the code:
(require 'comint)
(defun inferior-gosu-mode ()
(interactive)
(comint-mode)
(setq comint-prompt-regex inferior-gosu-prompt)
(setq major-mode 'inferior-gosu-mode)
(setq mode-name "Inferior Gosu")
(setq mode-line-process '(":%s"))
(use-local-map 'inferior-gosu-mode-map))
The use-local-map bit is just where you define special key bindings; I have it as just a copy of the comint bindings:
(defvar inferior-gosu-mode-map nil)
(unless inferior-gosu-mode-map
(setq inferior-gosu-mode-map (copy-keymap comint-mode-map)))
After this I had some simple code that defined a command to launch a process that would pop open the *inferior-gosu* buffer if it existed. I also added a bit of code to the normal gosu mode for opening an inferior-gosu shell.
In short: use comint.
Here's a link to the whole code, but there isn't much more to it: https://github.com/TikhonJelvis/Gosu-Mode/blob/master/inferior-gosu-mode.el
Naturally feel free to use that code however you want; you might also want to look at the normal gosu mode to see how you could integrate you erlang and prolog into the languages' respective editing modes.

How can I more easily switch between buffers in Emacs?

I've recently started using emacs and I'm enjoying using it for the most part. The only thing I'm not enjoying, is switching between buffers. I often have a few buffers open and I've grown tired of using C-x b and C-x C-b, are there any packages that make switching between buffers easier? I've looked into emacs wiki on switching buffers and I'd appreciate insight/feedback on what are are using/enjoying. Thanks.
UPDATE: iswitchb-mode is obsolete in Emacs >= 24.4, replaced by ido.
All of the features of iswitchdb are now provided by ido. Ross provided a link to the documentation in his answer. You can activate with the following in your .emacs (or use the customization interface as Ross suggests):
(require 'ido)
(ido-mode 'buffers) ;; only use this line to turn off ido for file names!
(setq ido-ignore-buffers '("^ " "*Completions*" "*Shell Command Output*"
"*Messages*" "Async Shell Command"))
By default, ido provides completions for buffer names and file names. If you only want to replace the features of iswitchb, the second line turns off this feature for file names. ido will ignore any buffers that match the regexps listed in ido-ignore-buffers.
The behaviour described below for iswitchb-mode applies equally to ido for switching buffers.
iswitchb-mode (Emacs < 24.4)
iswitchb-mode replaces the default C-x b behaviour with a very intuitive buffer-switching-with-completion system. There are more sophisticated options, but I've never needed more than this.
After you hit C-x b, you are presented with a list of all buffers. Start typing the name of the buffer you want (or part of its name), and the list is narrowed until only one buffer matches. You don't need to complete the name, though, as soon as the buffer you want is highlighted hitting enter will move you to it. You can also use C-s and C-r to move through the list in order.
You can turn it on by default with this in your .emacs:
(iswitchb-mode 1)
You can also tell it to ignore certain buffers that you never (or very rarely) need to switch to:
(setq iswitchb-buffer-ignore '("^ " "*Completions*" "*Shell Command Output*"
"*Messages*" "Async Shell Command"))
You can use C-x <right> (next-buffer) and C-x <left> (previous-buffer) to cycle around in the buffer ring. You could bind S-<right> and S-<left> to these functions. (S is the "super-key" or windows-key). This way you can save some keystrokes.
Moreover, note that C-x b has a default entry, i.e. it displays a standard value (most of the time this is the previously viewed buffer), so that you don't always need to enter the buffer name explicitly.
Another nice trick is to open separate windows using C-x 2 and C-x 3. This displays several buffers simultaneously. Then you can bind C-<tab> to other-window and get something similar to tabbed browsing.
M-x customize-group ido then set Ido Mode to Turn on both buffer and file and set Ido Everywhere to on. Then click the Save for future sessions button at the top and enjoy ido magic for both files and buffers. Read the docs to get a sense of how to use ido.
Also, take a look at smex.
ido-mode provides an efficient way to switch buffers.
ibuffer is best for managing all opened buffers.
anything is good for selecting an interested thing from different
sources. (for eg: a single key can be used to switch to another
buffer or to open recently closed file or to open a file residing
in the same directory or ... anything you want ... )
If you've looked at the Emacs Wiki, you probably have all this information already, but here are a few other relevant Q&As:
Emacs: help me understand file/buffer management
Buffer switching in Emacs
How to invoke the buffer list in Emacs
My toolkit consists of ibuffer, windmove+framemove, winner-mode, and a custom binding to make C-xleft/right and C-cleft/right less of a hassle to use.
I have mapped the "ยง"-key to 'buffer-list and I find it to be very efficient.
I've started using anything for a couple of days and I'm really liking it: http://www.emacswiki.org/emacs/Anything .
Emacs-fu has an good intro to anything: http://emacs-fu.blogspot.com/2011/09/finding-just-about-anything.html
My favourite function for this is helm-mini which is part of helm.
As other helm functions, it allows incremental narrowing of the selection. It also searches your recently visited buffers, which is a really nice way to re-open a buffer. Helm can be a little surprising at first and as a new Emacs user, I found it visually overwhelming and I preferred ido or ibuffer which have been suggested in other replies. But now I absolutely love it and use it all the time for countless things.
Something that I realized by accident and that can be useful:
mouse-buffer-menu is by default bound to <C-mouse-1> (Control key + mouse left click) and opens a popup with a list of the current buffers.