For those who haven't used DrScheme, window is split in two parts: one part is a file you're editing, and the other is interactive shell. When I run a file, it is loaded into interactive environment, so I can invoke functions I've defined etc. Interactive environment still has all the features of text editor (syntax highlighting, auto completion, etc...)
So is there an IDE for Ruby that doesn't just execute script I'm making, but loads it into irb instead, with all text editor goodies?
This exact request (even up to the fact that Dr Scheme motivated it) is what finally pushed me to learn Emacs.
Here's what i did to install it under Windows Vista:
Download Emacs from http://ftp.gnu.org/gnu/windows/emacs/emacs-22.3-bin-i386.zip
Unzip it to the directory of your choice
After unzipping it create an includes directory anywhere you wish and copy there both ruby-mode.el and ruby-inf.el (these come with the ruby distribution under the misc directory and can also be downloaded from Ruby's source
Modify your .emacs to tell it where to find your includes and and to use them
; directory to put various el files into
(add-to-list 'load-path "C:/emacs-22.3/includes")
;(1)modify .emacs to use ruby-mode
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))
;(2)set to load inf-ruby and set inf-ruby key definition in ruby-mode.
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)
))
(optional) I also installed mode-compile.el from http://perso.tls.cena.fr/boubaker/distrib/mode-compile.el and made the corresponding edits in .emacs
; Install mode-compile
(autoload 'mode-compile "mode-compile"
"Compile current buffer based on the major mode" t)
(global-set-key "C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Kill compilation launched by `mode-compile'" t)
(global-set-key "C-ck" 'mode-compile-kill)
With those changes Emacs will automatically identify a .rb file as ruby and do syntax highlighting. Then with the chord \C-c\C-s (Control-c, release and then Control-s) irb will start in the box below your file, and you can use all the keys defined by inf-ruby: (\M is the Meta Key which for Windows means Alt)
"\C-c\C-b" 'ruby-send-block
"\C-c\M-b" 'ruby-send-block-and-go
"\C-c\C-x" 'ruby-send-definition
"\C-c\M-x" 'ruby-send-definition-and-go
"\C-c\C-r" 'ruby-send-region
"\C-c\M-r" 'ruby-send-region-and-go
"\C-c\C-z" 'switch-to-ruby
"\C-c\C-l" 'ruby-load-file
"\C-c\C-s" 'run-ruby
If you did the optional step and installed mode-compile, you can also use \C-cc to send the current file to ruby instead of irb
I haven't worked with DrScheme yet, but Netbeans 6.5 includes a full-featured IRB. Have you given it a try?
Related
I am a newbies in Singular. I just downloaded Singular4-0-2_64.dmg, mounted the image, right-ckick, show the package contents, then moved the contents folder to the Applications directory. double-clicking Contents/MacOS/Singular (or Esingular) I have Singular running in a terminal (or via emacs in a terminal). But when I try M-x singular in a running emacs, it says "cannot open load file : no such file or directory, singular".
Then I copied .emacs-general and .emacs-singular to the home directory. Adding the following lines to .emacs
(setq load-path (cons "" load-path))
(autoload 'singular "singular"
"Start Singular using default values." t)
(autoload 'singular-other "singular"
"Ask for arguments and start Singular." t)
changing singular-emacs-home-directory into /Applications/Singular.app/Contents/share/singular/emacs/ it still doesn't work.
Also when I replace .emacs with .emacs-singular, replacing the above directory, it gives the error:
Warning (initialization): An error occurred while loading `/Users/Me/.emacs':
Symbol's value as variable is void: /Applications/Singular.app/Contents/share/singular/emacs
Am I not finding the right singular-emacs-home-directroty or is there any other problem?
I appreciate your help.
Also I must mention that I am a user of emacs for Macaulay2. For that I have changed .emacs and .emacs-Macaulay2 in order to teach emacs where to look for M2. Is there anything similar to be done for Singular? Shall I have a file .emacs-singular somewhere?
Thanks for your help.
Here are some basic settings that assume the Singular.app has been installed to the /Applications folder. I chose to set the absolute path to the executable, instead of setting the PATH in Emacs. The PATH in Emacs on OSX is (by default) not the same as what one would generally except to see in let's say Terminal.app. [But, setting the PATH is beyond the scope of this basic answer.]
My personal preference is to have all of the lisp and configuration files in a custom directory for purposes of editing and backup up. This limited example just leaves everything where they are.
In the Emacs master branch (February 7, 2016), there is no built-in variable named current-menubar -- the configuration files are looking for the existence of that variable. I did not spend the time to debug the built-in configuration files to find out what version of Emacs they were designed for, and I did not spend the time to make the Singular elisp libraries compatible with the latest Emacs master branch.
Add the following lines of code to the .emacs file in the home directory, save the file, and restart Emacs. Then type M-x singular RET
(add-to-list 'load-path "/Applications/Singular.app/Contents/share/singular/emacs/")
(require 'singular)
(setq singular-emacs-home-directory "/Applications/Singular.app/Contents/share/singular/emacs/")
(defvar current-menubar nil)
(setq singular-executable-default "/Applications/Singular.app/Contents/MacOS/Singular")
(load-file "/Applications/Singular.app/Contents/share/singular/emacs/.emacs-general")
(load-file "/Applications/Singular.app/Contents/share/singular/emacs/.emacs-singular")
I am not able to use Spell-Check in the Emacs on my Mac. I copied the .emacs file I had on my previous Fedora to my home folder in my Macbook. The ".emacs" has a line saying:
(global-set-key "\C-k" 'ispell)
When I type "control+k" in an open emacs terminal, I get the following error message in the minibuffer:
Searching for program: permission denied,/Applications/Emacs.app/Contents/Resources/list/textmodes/ispell.elc
When I looked for this address, I found that there is no "list" folder inside the "/Applications/Emacs.app/Contents/Resources/" folder.
When I do "locate ispell.elc", I get the following results:
/Applications/Emacs.app/Contents/Resources/lisp/textmodes/ispell.elc
/usr/local/share/emacs/24.2/lisp/textmodes/ispell.elc
/usr/share/emacs/22.1/lisp/textmodes/ispell.elc
How do I fix it?
I have the following in my emacs config:
(defmacro WhenOSX (&rest body)
`(if (eq system-type 'darwin)
(progn ,#body)
nil
)
)
(WhenOSX
(setq ispell-program-name "/usr/local/bin/aspell")
)
I install aspell via homebrew. The above macro lets me share my config across Linux, OSX, and others.
https://github.com/shaleh/dot-files/tree/master/emacs.d has my Emacs config containing bits I have gathered from around the web over the years. Enjoy.
so i am trying to add the google go module to my .emacs file so that when I use emacs to edit my .go file it will have the appropriate indentations and highlight of the words. Ive looked online and it seems that I need to add the following code snippets to my .emacs file (which i cannot find!)
;; go mode
(setq load-path (cons "/usr/local/go/misc/emacs" load-path))
(require 'go-mode-load)
I have put go-mode-load.el and go-mode.el in my .emacs.d/ directory I believe i still need to find the .emacs file to add the code listed above I am running OS X if this helps. Can someone help me get this working thank you!
Eval this with M-: (find-file user-init-file)
Emacs will then open what it considers your user initialization file.
I have
(global-set-key (kbd "<f12>") (lambda () (interactive) (find-file-other-window user-init-file)))
in my .emacs so that i can easily edit this.
The Emacs manual tells you:
This file, if it exists, specifies how to initialize Emacs for you.
Emacs looks for your init file using the filenames `~/.emacs', `~/.emacs.el',
or `~/.emacs.d/init.el'; you can choose to use any one of these three
names. Here, `~/' stands for your home directory.
Most people use ~/.emacs, I think. Just do C-x C-f ~/.emacs to create it if you do not yet have one.
Windows 7. Emacs 24.3.1. Git 1.8.1.msysgit.1. I have the following in my equivalent .emacs file:
(if (equal system-type 'windows-nt)
(progn (setq explicit-shell-file-name
"C:/Program Files (x86)/Git/bin/sh.exe")
(setq shell-file-name "bash")
(setq explicit-sh.exe-args '("--login" "-i"))
(setenv "SHELL" shell-file-name)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))
This works great when I want to do M-x shell: I can pop open a shell and type "ls".
However, M-x shell-command is failing. When I try to run "ls" via shell-command (which should print its output in the *Shell Command Output* buffer, according to C-h f shell-command), I get a single error message:
"Searching for program: permission denied, bash"
There are some very old suggestions on the Google about call-process and many questions on StackOverflow about getting the shell to work in Emacs. Please note that M-x shell works great, and what I'd like to work is shell-command.
(Reason: https://github.com/donkirkby/live-py-plugin#installing-the-emacs-mode)
Try setting both variables to point to the same executable and make sure the path is in exec-path:
(setq explicit-shell-file-name
"C:/Program Files (x86)/Git/bin/bash.exe")
(setq shell-file-name explicit-shell-file-name)
(add-to-list 'exec-path "C:/Program Files (x86)/Git/bin")
I know this is an older question, but I found it while I was searching for help on the same issue, so here's the solution I use for my particular use case, in case it helps someone in the future.
I sync up my .emacs.d between all computers I use emacs on, which includes both Linux & Windows machines. I inserted this into my init.el file to automatically deal with this issue appropriately in a Windows environment:
;; Set Windows-specific preferences if running in a Windows environment.
(defun udf-windows-setup () (interactive)
;; The variable `git-shell-path' contains the path to the `Git\bin'
;; file on my system. I install this in
;; `%USERPROFILE%\LocalAppInfo\apps\Git\bin'.
(setq git-shell-path
(concat (getenv "USERPROFILE") "\\LocalAppInfo\\apps\\Git\\bin"))
(setq git-shell-executable
(concat git-shell-path "\\bash.exe"))
(add-to-list 'exec-path git-shell-path)
(setenv "PATH"
(concat git-shell-path ";"
(getenv "PATH")))
(message "Windows preferences set."))
(if (eq system-type 'windows-nt)
(udf-windows-setup))
Please note that the variable git-shell-path will need to be defined based on where you have git installed on your system. I install it in %USERPROFILE%\LocalAppInfo\apps\Git on the one Windows machine where I use it.
Using GitBash you can use the lein script instead of the lein.bat script. Put the lein script into a directory called bin in your user account on windows. GitBash should have that bin directory on its executable PATH, so you can run lein anywhere.
With this approach you do not need any configuration in Emacs Lisp.
See my full answer
I'm using Emacs 24 on OS X 10.6.8. Doing magit-status says
Searching for program: no such file or directory, git
However, the Emacs shell is able to find git, so this does not seem to be a $PATH issue. What else could it be?
Try checking the value of exec-path variable. This controls the directories which are looked by Emacs for external executables (including git).
This is a customizable variable, and you can add the path to git to the list of existing directories.
I have the elisp snippet in my .emacs.d/init.el file for my Emacs install under OSX, which sets both the PATH and exec-path correctly.
;;; Set localized PATH for OS X
(defun my-add-path (path-element)
"Add the specified PATH-ELEMENT to the Emacs PATH."
(interactive "DEnter directory to be added to path: ")
(if (file-directory-p path-element)
(progn
(setenv "PATH" (concat (expand-file-name path-element) path-separator (getenv "PATH")))
(add-to-list 'exec-path (expand-file-name path-element)))))
(if (fboundp 'my-add-path)
(let ((my-paths (list "/opt/local/bin" "/usr/local/bin" "/usr/local/git/bin")))
(dolist (path-to-add my-paths (getenv "PATH"))
(my-add-path path-to-add))))
Emacs on OS X uses the system-wide environment variables, which can be overridden by creating a magic environment.plist XML file in the right directory. A better solution, though, is to have Emacs copy the value of $PATH from your shell, so that it matches what you see in Terminal.app.
#Anupam's answer is based on a snippet of code which I originally wrote for this purpose, but I've now improved that code and published it as a little elisp library called exec-path-from-shell which you can install from Marmalade or Melpa.