Macos – Warnings/Errors with emacs cocoa (23.2) on OSX Terminal

emacsmacos

I'm using emacs on OSX Terminal, just installed newer version 23.2, its located on /Applications/Emacs/Content/Emacs, it's an executable, so i linked it to /usr/bin/emacs, and moved the older one to /usr/bin/emacs.old as it was a bin file.

Now when i use "emacs -nw "" (with no .emacs and empty ".emacs.d") it opens the file, with no syntax highlight (php in my case, but it's understandable), and when i close it, there are the following errors:

Warning: arch-dependent data dir (/Users/david/src/emacs-dev/ftp-versions/emacs-23.2/nextstep/Emacs.app/Contents/MacOS/libexec/emacs/23.2/x86_64-apple-darwin/) does not exist.
Warning: arch-independent data dir (/Users/david/src/emacs-dev/ftp-versions/emacs-23.2/nextstep/Emacs.app/Contents/Resources/share/emacs/23.2/etc/) does not exist.
Error: charsets directory (/Users/david/src/emacs-dev/ftp-versions/emacs-23.2/nextstep/Emacs.app/Contents/Resources/share/emacs/23.2/etc/charsets) does not exist.
Emacs will not function correctly without the character map files.
Please check your installation!

If i move my .emacs.old to .emacs and put the contents of my .emacs.d.old to .emacs.d, when open some file, emacs shows an error, saying it couldn'y open the file due to warnings, and when i close it, the same warnings appear.

The strange thing is my username isn't david, as it looks on the warning "/Users/david/…", so where did it come from? Can i fix it?

Thanks.

edit: here's the error i get when i try to open a .module file:

Cannot open load file: warnings

edit2:

All i wanted is shift-selection on the 'emacs -nw', if anyone got a better sugestion, i'd love it. I'm using the older emacs now, new one is too buggy on the -nw.

Best Answer

This got rid of the error for me:

$ sudo mv /usr/bin/emacs /usr/bin/emacs.old

Now edit /usr/bin/emacs in a text editor and paste this in:

#!/bin/sh

EMACS_PATH=/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs

if [ $(id -u) = "0" ]; then
    sudo $EMACS_PATH "$@"
else
    $EMACS_PATH "$@"
fi

(Replace $EMACS_PATH with the actual path to your Emacs binary.) Finally, make your shell script executable:

$ sudo chmod +x /usr/bin/emacs

For whatever reason, Cocoa Emacs doesn't like to be linked to /usr/bin/emacs, but it runs without complaints if you invoke it from its actual path. Probably a working directory issue.

If someone knows a better way to do this, I'm all ears.

edit: updated script to handle quotes in arguments properly

Related Question