emacsclient unable to find emacs server - macos

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.

Related

How do I more easily copy and paste all the content in open file on remote server over ssh using tmux and iterm2?

Problem: I'm on a mac running a tmux server. Within my local tmux session, I connect to a remote linux server and open a file with vim. The text I want does not fit in a single pane without having to scroll. I want to grab the text in the file and copy and paste all of it to my local machine's memory.
Current Solution:
My current procedure for copying and pasting is very convoluted:
Zoom on the pane with ctl-b z
Turn off numbering in vim with :set nonumber
If the file or text I want does not fit in entire pane, I hit cmd - until the text is small enough to fit in the entire pane
Select text I need with my mouse while holding down the option key.
Hit cmd-c to copy to my local machine.
Better Solution?
My current solution is tedious and I'm tired of wondering if there is a better way. Anyone got a better solution?
Ideally, I'd love to be able to select the text with vim and have iterm2 somehow detect what has been selected in a pane and run a single keystroke to copy to my local machine. Not sure if that's possible or not.
OK, I went with the solution at github.com/wincent/clipper which works on my mac running macos 11.2.3.
The install instructions seem to be a little dated and are a bit confusing if you don't read them carefully. It took some trial and error to figure out how to get this working with vim on the remote machine:
Install with brew on your mac
Launch clipper as a daemon with brew services start clipper
On the remote machine, add the following line to your vimrc file:
nnoremap <leader>y :call system('nc -q 1 localhost 8377', #0)<CR>
Note: I had to add the -q 1 in there because I found vim would hang otherwise. The -q 1 arguments are not in the official documentation.
In your mac's ~/.ssh/config file:
Host *
RemoteForward 8377 localhost:8377
Make sure your remote server has port 8377 open!
On the remote machine, open a file with vim. Yank some lines. Then hit <leader>y.
Note: It took a while before it finally dawned on me that just <leader>y doesnt' work by itself. It's a two-step vim command process: 1) yank the text with a vim command 2) send the copied text to your mac with <leader>y.
That's it. My life feels so much better now. :)

emacs server file empty after starting emacs server

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"

Read only for open directories in vim

Then I open vim from terminal and open an directory like vim ., my starts in Read Only Mode.
I cant figure out why this happen and how I can change it.
If I start MacVim everything is fine. But then I start vim from the terminal and open a directory this screen comes. I can navigate one dir up and back again, and I have write access.
EDIT
I installed all my vim settings on Ubuntu 15.04. Now I can use
Does anybody know how to change this behaviour of vim?
Now I can use netw with the command vim . like I always used.
As you can see, there is no RO (read only) mark. How can
I have this in Mac on iTerm too?
What you see is exactly what you are supposed to see when doing $ vim .: the built-in netrw plugin displays a listing of the current directory that you can use to navigate your project.
If you don't want that listing, don't ask for it:
$ vim
or:
$ vim file
ctrl-p is not mapped by netrw; on my system, its set up by the yankring plugin. If vim is doing something other than going up one line, then you have a plugin involved. Try using :map to see what its mapped to; then do a search for that in your plugins directory.
The netrw way of opening a file in the same window is to use the <enter> key, although the g:netrw_browse_split variable may be used to change that default behavior.
Netrw opens in read-only mode, and that's not going to change. The file being opened should not be in read-only mode, however, if that's what you meant. If you're having a problem of that sort, please update your netrw; the most up-to-date version is at http://www.drchip.org/astronaut/vim/index.html#NETRW .
After I installed macvim 7.4 Every thing works!

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

Setting up .emacs file for mac ruby development

I am having a difficult time loading ruby-mode in emacs on my mac.
The .emacs file is located at ~/.emacs I've added several commands to it (many pasted from this site) and none seem to get loaded. Any advise? I"m not sure if the file isn't loading or I have the command syntax wrong.
All I need is the following
4 space indent (auto-intedent would be great as well)
ruby mode loaded for .rb files.
Thanks!
Put the line (warn "Loading .emacs") as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.
If this does nothing, try opening the file in emacs, and running M-x eval-buffer.
Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.
This is how emacs finds the .emacs file.
57.6.4 How Emacs Finds Your Init File
Normally Emacs uses the environment variable HOME (see HOME) to find .emacs; that's what ‘~’ means in a file name. If .emacs is not found inside ~/ (nor .emacs.el), Emacs looks for ~/.emacs.d/init.el (which, like ~/.emacs.el, can be byte-compiled).
However, if you run Emacs from a shell started by su, Emacs tries to find your own .emacs, not that of the user you are currently pretending to be. The idea is that you should get your own editor customizations even if you are running as the super user.
More precisely, Emacs first determines which user's init file to use. It gets your user name from the environment variables LOGNAME and USER; if neither of those exists, it uses effective user-ID. If that user name matches the real user-ID, then Emacs uses HOME; otherwise, it looks up the home directory corresponding to that user name in the system's data base of users.
From http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init

Resources