Cygwin's Emacs crashes on "//" - emacs

What I'm using
I am using Cygwin 64-Bit. In the shell, If I type:
uname -srv
I get:
CYGWIN_NT-6.1 1.7.34(0.285/5/3) 2015-02-04 12:14
If I right-click on cygwin1.dll, "Properties" under "File version" I get:
1007.34.0.0
In the shell, if I type
emacs --version
I get:
GNU Emacs 24.4.1
The problem
If I run emacs and create a c-file, such as:
#include <stdio.h>
int main()
{
return 0;
}
That works fine.
If I then want to do something like:
#include <stdio.h>
//add a comment here
int main()
{
return 0;
}
...as soon as I enter the slashes, Emacs crashes. On entering the first slash, it provides auto-complete options, if I choose one, things are still good. However if I don't, as soon as I just enter the 2nd slash Emacs crashes.
Is this a known bug?
P.S.: I know I can install Emacs outside Cygwin and even get an Emacs version that somehow includes Cygwin. But I'd rather stay with what I have. So please don't suggest this as a workaround. I'm already aware of it.

Related

VS code doesn't recognize cygwin compiler

When I tried to run the program
#include <stdio.h>
int main() {
return 0;
}
But VScode said "#include errors detected. Please update your includePath"
The problem was that I didn't have a compiler installed, so I installed cygwin and added it to Path (via this link). But, even after reopening VScode, it could not detect cygwin. I checked the versions of g++, gdb, and make in cmd, but just said they're not recognized as a internal or external command, operable program, or batch file. I believe I had this problem months ago and that time I installed mingw, having no success.

Emacs Mode Line Click Change Buffer

In some installation of Emacs for the terminal, I had that if you click (text mouse cursor) on the buffer name in the mode line it jumped to the next buffer.
I search for a while but I couldn't find it.
Do someone remembers how to achieve this.
OS : OS X Terminal
Emacs: GNU Emacs 26.3
(Now I have Catalina, but I should have been in previous versions)
Try turning on mouse mode in your terminal emacs: M-x xterm-mouse-mode RET. This seems to work with emacs -nw in either an xterm or a gnome-terminal on linux. Whether it works on OS X and whatever terminal emulator it provides, I have no idea.
This Unix & Linux SE question contains much more information and some useful links.

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.

Coding in Emacs shell?

I am using shell in my emacs version 22.2.1 (debian stable repos) and it has some kind of broken coding. For example, if I run `ls' command, output is
[0m[01;34margouml-0.30.2[0m
not "argouml-0.30.2" as normal. I have tried commands C-x RET p utf-8 and so others but without any effect. I have properly generated utf-8 locales and everywhere else in emacs coding works perfect. Does anybody knows what may be wrong with it?
Your terminal type in the shell is set incorrectly; those escapes are for colors, but the emacs shell doesn't support them. Try M-x term instead for better support.
You can also try M-x ansi-term, or even download Multi term and try that too.
Links:
Ansi Term
Multi Term

Eclipse CDT using MinGW does not output in console

I have a Windows 7 64-bit PC and I am trying to install a free C++ IDE, so I chose to install Eclipse Helios with CDT.
For g++, make and gdb I installed msys and mingw according to this tutorial:
http://wiki.wxwidgets.org/HowTo:_Install_MSYS_and_MinGW_for_use_with_Eclipse_CDT
The versions are:
make: GNU make 3.81
g++: 4.5.0
gdb: 7.1
So it should be compatible with my 64-bit CPU.
However when I try to run a very simple program with eclipse, I see nothing on the console. The source code is:
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Enter an integer: " << endl;
cin >> i;
cout << endl << "i is " << i << endl;
return 0;
}
The build is fine and when I launch the .exe with command (windows console) the behavior is as expected.
But with the Eclipse console I see nothing with run and with debug the output is just:
"Enter an integer: ", then when I type in a number and hit enter it does nothing.
Does anyone know how to fix this please?
Thanks,
Guillaume
PS: I use the toolchain "Linux GCC", with "MinGW GCC" I have nothing at all in the console.
This worked for me on 64-bit install of Eclipse on Windows 7 using MinGW:
Right-click on your project. Select "Properties".
Select the "Run/Debug Settings" Property on the left of the new window.
In the right window, click on your executable to highlight (ie - Test.exe) and click "Edit".
In the Environment tab, hit "New"
Name: PATH
Value: Path to your MinGW bin directory. (For me this was: C:\devcore\MinGW\bin)
Click "OK" on all windows to close down.
Try running again, it should print output to the screen.
You need to set up linker
I am using MinGW.
Follow below steps.
Goto Project > Properties > C/C++ Build > Settings > Tool Settings (Tab) > MinGW C++ Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++) (default command is only g++)
purlogic's solution works.
Instead to set that for every project, I found it can be set globally:
In Window -> Preferences-> C/C++ -> Build -> Environment
Add a variable for your compiler. e.g, I added:
MINGW, with value "C:\MinGW\bin"
This console bug has been noticed in 64-bit versions of eclipse:
http://www.eclipse.org/forums/index.php?t=msg&th=197552&start=0&S=2a2b64e1f1404705c0214976bd477428
A workaround is to install the 32-bit eclipse
I ran into the same problem, because of multiple gcc installations on one PC. But Greg's solution only worked partly for me.
In my case the flush was not done in the application explicitly. While C++ programs often use std::cout << ... << std::endl where the endl does a flush, my program used actual C-output such as the usual printf. The printf could be seen directly when starting the program in the cmd-window. However in eclipse console they were missing. Hence a
fflush(stdout);
after the printf did the thing for me. That could be an issue within the eclipse console implementation. I guess that's why fixing the Path did not work for some people here.
An alternative solution instead of setting the PATH within the "Run" settings is to start the whole eclipse using a batch file, which looks essentially like this:
set PATH=<mymingwlocation>\bin;%PATH%
start <myeclipselocation>\eclipse.exe
Then any run configuration would use the correct MingW location by default. That might also fix other problems that could arise from using the wrong gcc.
Have you tried to execute the eclipse.exe with administrator privileges ?? it worked for me !
Had this issue on 64-/32-bit eclipse Kepler CDT to work on a openCV/wxWidgets tool, Win7, using MinGW to build.
If anyone comes across this while having this issue and are working with openCV you will already know that there are many outdated openCV building/installing instructions all over the internet.
One I had was to go to Build Settings -> Linker -> Miscellaneous and inside of the Linker Flags text entry box, type in
-Wl,--subsystem,windows -mwindows
However, this disables cout from outputting to a command line terminal in windows.
Doing some more digging this looks intentional, apparently the -mwindows involves directing STDOUT away from a command line specifically to a GUI-like application.
Also, removing -mwindows and just leaving in -Wl,--subsystem,windows accomplishes the task of redirecting STDOUT anyway away from the command line all the same.
Now mind you, I haven't built up anything yet outside of a hello world program involving wxWidgets and openCV, so I am not at the point of doing a cout into a part of a GUI so I don't know if that functionality would now be broken or if it would print out to the GUI object, as well as a command line terminal.
Or set the linker option -static.
Works for me at least.
Add PATH variable (PATH="your MinGW/bin directory path") into your C++ project by Run -> Run Configurations ->in Environment Tab