Emacs + Cygwin setup under windows ! - emacs

I just downloaded Emacs and Cygwin for Windows(Vista in my case). Have no idea how to set them up.
Any help would be appreciated !
Thanks !

I use these libraries, in this order:
(require 'cygwin-mount)
(require 'setup-cygwin)
They are both available on EmacsWiki:
http://www.emacswiki.org/emacs/cygwin-mount.el
http://www.emacswiki.org/emacs/setup-cygwin.el

Step 1: Install libraries
http://www.emacswiki.org/emacs/cygwin-mount.el
http://www.emacswiki.org/emacs/setup-cygwin.el
Step 2: Install cygwin to C:\cygwin (This requirement is hardcoded in setup-cygwin.el, so just do it unless you are willing to modify setup-cygwin.el).
Step 3: Add following code into your .emacs or .emacs.d/init.el. Please note the variable cygwin-mount-cygwin-bin-directory is not set by default in cygwin-mount.el, I suggest using hard coded path (I mean "c:/cygwin/bin" actually) since the cygwin install path is already hardcoded by setup-cygwin.el.
(setq *win32* (eq system-type 'windows-nt) )
;; win32 auto configuration, assuming that cygwin is installed at "c:/cygwin"
(if *win32*
(progn
(setq cygwin-mount-cygwin-bin-directory "c:/cygwin/bin")
(require 'setup-cygwin)
;(setenv "HOME" "c:/cygwin/home/someuser") ;; better to set HOME env in GUI
))

Maybe try posting your question on http://superuser.com
But:
Installing Emacs on Windows 95/98/2K/NT/ME/XP/Vista/Windows 7
Quick Start Guide for those more experienced with Windows

Use cygwin-mount.el to integrate Cygwin with Emacs:
http://www.khngai.com/emacs/cygwin.php
You might also want to replace the DOS Shell with the Cygwin bash, that's also covered.

You can find instructions here.

There're several way to integrate emacs with cygwin as follows:
emacs-nox under cygwin. Not attractive!
emacs-X11 under cygwin. An X server is needed like XMing or Cygwin/X. A bit slow and heavy.
emacs-w32 under cygwin.
emacs under windows. You need some configuration to make emacs recognize the cygwin environment. Difficult for beginners.
I'd recommend using emacs-w32 with cygwin, which uses native Windows GUI so that you don't have to start an xserver just to run emacs and you don't need to write/download any tricky code to make emacs aware of cygwin env as other answers do.
Just install emacs-w32 and run it from mintty and here you go. FYI, if you want to start emacs "independently", write a .bat file with D:\cygwin\bin\run.exe /usr/bin/bash.exe --login -i -c /usr/bin/emacs-w32.exe inside or, as I do, write a .ahk script to start emacs with hotkey F12.

Related

Emacs: where is better have the executable file?

After many changes on my Debian Jessie, when I launch the command emacs I receive an error libgnutls.so.26 : cannot open shared object file: No such file or directory.
If I launch instead the command emacs24 everything is allright.
I have emacs in /usr/local/bin
I have emacs24 in /usr/bin.
So, for now I created an alias to launch emacs24 as emacs, but i don't like and, for example, i have to change the git setting to open the default ide cause emacs is not availlable yet.
The question is where is the correct position of the command ? I have to change my PATH ?
Consider that libgnutls.so.26 is not installable from apt.
Thanks for any suggest or advice.
This is very strange, because a simple sudo dnf install emacs should suffice (I use fedora, so you probably use apt-get instead of dnf). Maybe it is best to just reinstall emacs (backup your .emacs to be safe) using apt-get? Anyhow, in fedora the emacs executable is located at /usr/bin/emacs (which is also the one used in the terminal when you use the emacs command).

Emacs can't find gofmt in go-mode

I'm trying to use Emacs for golang programming. I downloaded the go-mode package and installed it. My .emacs is:
(require 'go-mode)
When I'm opening *.go files, go-mode enables correctly. But I can't save any *.go files because when I'm trying to save *.go files I'm getting an error in the minibuffer that says
gofmtprogram not found.
Golang installed (version 1.3), gofmt works from terminal.
How can I solve this problem?
Thank you.
On OSX I'm usingthe following in .emacs/init.el
(use-package exec-path-from-shell
:ensure t
:init (exec-path-from-shell-initialize))
to insure that Emacs are using the correct path.
Make sure you have gofmt in your PATH. (echo $PATH) to check, if you can't run gofmt in your shell, it is likely that emacs won't as well.
gofmt on my setup is in $GOBIN/gofmt, but I think it can be as well be in one of the $GOPATH/bin.
If you have it in your path, chances are that you have an emacs configuration that sets the path. Change as needed.
If you installed via a packet manager, chances are that gofmt will be somewhere else. (I think brew puts it in /usr/local/bin)
Small tip when this happen and you really need to save: switch back to text-mode (M-x text-mode).

Emacs shell behavior

I am using cygwin on windows 7. I have a question regarding the Emacs shell.
Whenever I use the shell inside of the Emacs(M-x shell)
It echo pwd directory after prints out the result.
I found it very annoying since it distracts me.
e.g.
$ ls
workspace
^[]0;~/cs61bl^G
myname#pc ~/cs61bl
Is there any way to remove these lines?
^[]0;~/cs61bl^G
myname#pc ~/cs61bl
When using Emacs, try using the eshell: M-x eshell. The eshell does not suffer from this problem.
You might be looking for "shell-dirtrack-mode". You can either do an M-x shell-dirtrack-toggle or (shell-dirtrack-mode 1) in your init file. Recent emacs versions seem to disable it by default.
There is this file http://www.emacswiki.org/emacs/setup-cygwin.el that simplifies setup of various packages in Emacs (including shell) to use cygwin. Also try not to use ANSI sequences in your PS1 prompt because Emacs shell mode wouldn't interpret them, something like
export PS1="\h \W\$ "
should do.

Emacs on Windows for C++ development configuration?

Has anyone set up cygwin and some emacs to work well under a 64-bit Windows 7?
I tried downloading cygwin recently, and by default not even dired works reliably, there are odd shell prompt characters, I get a lot of warnings, in one case C-c was read as C-g and caused various errors. (Neither xemacs nor emacs worked for me, where by "work" I mean that dired and shell work, and without warnings).
I just want the usual emacs development tools: gdb-mode, shell-mode, compiling, tag-search to work as normal.
I was hoping someone who has done this recently with cygwin could share whatever relevant shell files, emacs files, environment variables, and so on to make this all work. Should all these things just work out of the box?
You should check out ntemacs, with this code in your .emacs everything is working great with cygwin:
;; -- sets up cygwin
(let* ((cygwin-root "c:/cygwin")
(cygwin-bin (concat cygwin-root "/bin")))
(when (and (eq 'windows-nt system-type)
(file-readable-p cygwin-root))
(setq exec-path (cons cygwin-bin exec-path))
(setenv "PATH" (concat cygwin-bin ";" (getenv "PATH")))
(setq shell-file-name "bash")
(setenv "SHELL" shell-file-name)
(setq explicit-shell-file-name shell-file-name)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))
I use a hideous Frankenstein mix of "native" Win32 emacs (http://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-23.1.97-bin-i386.zip is the latest, but I'm using an older version) and Cygwin -- for bash, find, etc. It's taken me years to tweak things to my liking, and it's still a pretty bumpy experience.
Anyway it's worth trying.
I use a straight clean install of Emacs, gcc, gdb, make, etc from Cygwin (currently 1.7.15, but I've been doing this for years) and my standard dotfiles (.emacs, .bashrc/.bash_profile) that have been tweaked (but not really heavily) to be portable across Linux and Cygwin, and everything works fine for me. Occasionally I run into problems (like with processing2-mode where Processing doesn't have a Cygwin package yet, so it wants native Windows paths, but that's easily enough fixed and out of the ordinary. It almost sounds to me like something is fundamentally broken on your setup; could you give more details? Otherwise all I can recommend is wipe and do a clean reinstall.

gdb within emacs on Windows

I'm running Emacs 22.3 in Windows. Earlier today I had gdb working within Emacs just fine. I was installing QT4 and during the installation it asked me to uninstall MSYS which I quickly clicked through not thinking about things. I think I had gdb installed with the MSYS package and Emacs was using that, but I'm not completely sure. Now when I run the following I get an error in the mini-buffer.
M-x gdb
"Searching for program: no such file or directory, gdb"
I tried to add the path "C:\cygwin\bin" to the Emacs load-path with this code but I still get the same error.
(message "Adding cygwin/bin to load path.")
(add-to-list 'load-path "c:/cygwin/bin")
Could someone tell me what I'm doing wrong?
Thanks.
probably adjust your system path to point it where you have gdb installed.
Try using /cygdrv/c/cygwin/bin