emacs server file empty after starting emacs server - macos

I am on OSX, and I have Emacs 24.5 for Mac.
I setup the server path, and start the server in my init.el:
(setq server-socket-dir "~/.emacs.d/server")
(server-start)
but when I run emacsclient somefile, I have this error:
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR)
I then searched around and non works for me. I then dig into the server file which is ~/.emacs.d/server/server. and I found it is totally empty...
I believe that is the reason thatemacsclient` cannot find the server, any one had similar and knows how to solve it?
thanks

U found the issue, the emacsclient I used is the osx's own copy at usr/bin/emacsclient, not the one with the emacs 24.5
I add the line below to my .profile and works now
alias emacsclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"

Related

emacsclient unable to find emacs server

I have this setup for emacs on my Mac.
1. Downloaded the distro from http://emacsformacosx.com/.
2. Followed the tips here http://emacsformacosx.com/tips to set up emacs and emacsclient appropriately.
However the following sequence of steps does not work for me:
1. emacs filename - opens up the file
2. emacsclient -n filename - gives me an error saying that I have not started up the server. But I do have (server-start) in my .emacs file. So I am not sure why I am getting this error.
Nevertheless, I did C-x restart-server in the emacs window and then tried to use emacsclient to attach to it (to open another file) but I still get the same error.
Other things I have tried:
1. Added (setq server-socket-dir (format "/tmp/emacs%d" (user-uid))) and say that the server was starting up in the /tmp location when I launch emacs.
2. Tried various args for emacsclient (new frame, attach to existing frame etc). All give me the same error.
My guess is that emacsclient is unable to find the server I have started up. But I am not sure how to confirm this and/or how to fix it.
Any ideas?
Thanks.
So turns out that adding the line specifying the socket was a mistake. Removing it worked for me and emacsclient was able to find the emacs server just fine.
Another way I tested it was leaving the socket line in and then using the -s option with emacsclient to connect to that specific location (/tmp/emacs501/server) and that worked too.

Emacs can't start server

I try to start emacs server on a Windows 8 machine. I downloaded vanilla emacs, and run it using runemacs.exe. Then I run M-x server-start and the execution of this command takes about 3 minutes, after that there's a ~/.emacs.d/server/server file with the following contents:
127.0.0.1:65118 5868
r#Twzr]X-VjCB`g\&t;U1<bj3X]}6!8XUz~P;{q9'AIj322!w0O1XK[/K4v>ZOK*
and emacs server doesn't run: when I try to open a file with emacsclientw.exe it says no server.
Apparently emacs tried to start a server but failed. I'm the owner of the ~/.emacs.d folder.
You're using a non-standard socket directory. By default, the sockets are stored in /tmp/emacsXYZQ (where XYZQ is a number). emacsclient cannot be expected to know where you put the sockets, so you need to tell it (if it's not the usual place). You can do this with the -s command.
emacsclient -s ~/.emacs.d/server/server
Normally, you'd make this more convienient by adding
EMACS_SERVER_FILE=~/.emacs.d/server/server
to your ~/.profile and using emacsclient normally, but I'm not sure what the windows analog of that would be.
references:
this SO question
emacsclient options docs

emacs 24 on windows 7, tramp cannot find plink program

I am trying to use Emacs 24.2 with Tramp on windows 7 to remotely edit files on a linux server. I installed the Putty suit program and OpenSSH. I also placed the plink.exe in the putty suit into the bin folder under the emacs 24 folder, and added the folder emacs24/bin into the PATH environment variable.
However, when I try to access the remote file from emacs with the command in the minibuffer: /username#host:filename, I get the following error message from emacs: plink is not recognized as an internal or external command. It seems that emacs cannot find the plink program. But, when I try to run plink in windows cmd, it can find the plink program. Also, I can ssh to the remote server in windows cmd.
Can anyone tell me what's my problem? Do I need to install cygwin to make it work? Thanks a lot.
To get tramp with plink to work, I had to add my PuTTY path to my system search path.
On Windows 10:
control panel >> System & Security >> System >> advanced system settings >> enviroment variables
To PATH I appended the PuTTY path: C:\Program Files (x86)\PuTTY
I'm guessing the key is that from PowerShell or the command prompt, you need to be able to run plink without specifying the path.
I was able to resolve this and I did not have to install cygwin.
Try adding the path where putty was installed to your exec-path variable in emacs. Execute the following elisp code in emacs or put it in your .emacs file. Make sure the slashes are forward, not backslashes, as Emacs and Windows use different conventions.
(add-to-list 'exec-path "C:/Program Files (x86)/PuTTy")
check what exec-path is set to by typing C-h v exec-path

Accessing OS X / UNIX environment variables in Emacs minibuffer

I compiled Emacs 23 on OS X Leopard and I am loving it. But one thing I noticed when I switched from Aquamancs is that I am no longer able to access my environment variables that I specify in my .bash_profile file. For instance, I have a line:
export WORK=/Users/myname/Documents/otherpaths/Work
So to open files I can type in the minibuffer:
Find file: $WORK/projectname/filename.txt
or something to that effect, to save myself the trouble of typing the whole file path.
I found some instructions on editing ~/.MacOSX/environment.plist, .profile, and .login files from this site:
http://www.emacswiki.org/emacs/CarbonEmacsPackage
but does not appear to work and I am not certain it is applicable. I wonder if anyone knows of a solution? Thanks in anticipation,
-Stephen
you can tell emacs any environment variable by putting a line like
(setenv "WORK" "/Users/myname/Documents/otherpaths/Work")
in your emacs config file (.emacs, .emacs.d/init.el or whatever you use)
Probably Aquamacs and CarbonEmacs uses some tricks to achieve that without specifying it by hand. Take a look at the source code of both.

Compiling Erlang code on Windows

I installed Erlang 13B and tried to follow the tutorials.
Every time I get to c(tut), I get an error instead of (ok, tut), so it seems like there are no modules installed. Can anyone point me in the right direction?
I've tried Emacs but I don't really know how to use it and haven't even got close to getting the Erlang mode working. For instance, where do I type:
(setq load-path (cons "C:/Program Files/erl5.6.2/lib/tools-<ToolsVer>/emacs"
load-path))
(setq erlang-root-dir "C:/Program Files/erl5.6.2")
(setq exec-path (cons "C:/Program Files/erl5.6.2/bin" exec-path))
(require 'erlang-start)
For c(tut) to work, there has to be a tut.erl file in the current directory.
This is easy to accomplish if you start the Erlang interpreter from the command line, as is common on systems like Linux and OS X, but this isn't the usual pattern on Windows. When you start Erlang on Windows from the icon in the Start menu, the current working directory defaults to the location of werl.exe, which isn't where your tut.erl file is.
To make your command work as expected, you have to change your working directory to be the location of tut.erl after starting the Erlang shell. If tut.erl is on the Desktop, the command will be something like this on Vista or Windows 7:
cd("c:/Users/myname/Desktop").
(Yes, you have to use forward slashes. Backslashes are special in Erlang strings.)
On Windows XP and older, your Desktop folder is buried much deeper. It might be simpler to put werl.exe in the system PATH and use the command line on such systems.
It isn't necessary, but you might want to consider installing Cygwin. Its Bash shell will give you a more Linux or OS X like environment, which will help you work with other tutorials that are structured for those OSes.
After you install Erlang open the shell and do:
1> pwd().
C:/Program Files/erl5.7.1/usr
ok
2>
Assume you have a file; "tut.erl" on your desktop. Content might look like this:
-module(tut).
-compile(export_all).
hello_world() ->
hello.
You must change the path of the current working directory to the desktop first (or where ever you want to do the compile). Like this perhaps:
2> cd("F:/Desktop").
F:/Desktop
ok
3>
Then you can perform the compile.
3> c(tut).
{ok,tut}
4>
Then test the module
4> tut:hello_world().
hello
5>
More info refer to the documentation here: Erlang official documentation
More info on the shell, look here: Shell module
Hope this gets your started.
You can also create an initialization file named .erlang under YourErlangInstallationPath\usr\
the content of the file should look something like this;
io:format("consulting .erlang in ~p~n" ,
[element(2,file:get_cwd())]).
%% Edit to the directory where you store your code
c:cd("O:/Erlang.Umut").
io:format("Now in:~p~n" , [element(2,file:get_cwd())]).
it will automatically change the path to your working folder. (Obviously, my path is O:/Erlang.Umut, you need to replace it with yours.)
No need to change folders every time you launch console. Console will be able to reach your erl files directly.
I recently tried Erlang on windows.
use the console window to make sure the text editor you are using is giving your files the correct extension ie. filename.erl and not filename.erl.txt like mine was!
when I saved my files in notepad it added .txt so I saved in unicode. fixed
If you are still getting "tut:erl:none: no such file or directory", the file name is wrong. If you open a Windows command prompt and move to your desktop and type "dir" you will see that tut.erl is really named tut.erl.txt. type "ren tut.erl.txt tut.erl" and now your compile will work.
When werl's current working directory is same as the file to be compiled, the filename is given as an argument without the whole path.
Otherwise, for eg. Assuming tut.erl is placed at C:\ErLang tutorials, one may try compiling as,
c("C:\\ErLang tutorials\\tut").
Note:
Without double quotes the : causes syntax error
The backslash is given using escape sequence

Resources