/
EmacsApp
138 lines (90 loc) · 6.54 KB
/
EmacsApp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
== How to Install ==
Build from source:
# get Emacs sources (version 23 or later)
# ./configure --with-ns
# make
# make install
# copy nextstep/Emacs.app to target location
Emacs.app is the result of building Emacs with support for the !NeXTstep / !OpenStep / Cocoa API family. [http://lists.gnu.org/archive/html/emacs-devel/2005-09/msg00634.html]
It will run on Mac OS 10.3 and later as well as [http://gnustep.org/ GNUstep], the free implementation of !OpenStep for GNU/Linux, Windows, Darwin, the free BSDs, and other unix platforms.
For emacs 24 (pulled directly from bzr), I use
$ CC='gcc -arch i386' ./configure --with-ns --without-dbus
$ make
$ make install
Next, copy nextstep/Emacs.app to target location.
NOTE: I found I needed to add "--without-dbus" to allow emacs 24 to compile without error.
Install via macports:
{{{
sudo port install emacs-app-devel
}}}
== Enhancement ==
A set of enhancements making Emacs.app more Mac-like without going as far as AquamacsEmacs or similar distributions is available as an elisp package: NSPlatformSupport.
== Path ==
Emacs.app on Mac OS X does not inherit the same value of PATH environment variable as on another OS, or as in the shell running in either Terminal or Emacs. Apple describes this behaviour a bit here: http://developer.apple.com/qa/qa2001/qa1067.html. The file ~/.MacOSX/environment.plist can also be used as central place to save key:value pairs for all shells. The defaults programme allows to read and write, for example:
export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH) # bash
set path=(`defaults read ~/.MacOSX/environment PATH | tr ':' ' '`) # tcsh
NOTE: Remember when you make a change to environment.plist, you need to restart your computer before it takes effect.
For those that like their PATHs from .bashrc and would like the environment.plist to update itself at every start up, put the following in your /etc/profile file:
#/etc/profile begin
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
defaults write $HOME/.MacOSX/environment PATH "$PATH"
fi
#/etc/profile end
CREDIT GOES TO: http://www.nabble.com/unicode-character-in-aquamacs-td24259615.html
== Alternative Path Solution ==
I found the above to be not quite right on my Mac OS 10.6 laptop. The ##defaults## command generated gibberish in my ##environment.plist## file so I took the approach of creating a startup script (##~/bin/macosx-startup##) and added it to my User account login items list. ##macosx-startup## is a bash one-liner:
#!/bin/bash
bash -l -c "/Applications/Emacs.app/Contents/MacOS/Emacs --batch -l ~/lib/emacs/elisp/macosx/environment-support.el -f generate-env-plist"
where ##environment-support.el## is:
;;; Provide support for the environment on Mac OS X
(defun generate-env-plist ()
"Dump the current environment into the ~/.MacOSX/environment.plist file."
;; The system environment is found in the global variable:
;; 'initial-environment as a list of "KEY=VALUE" pairs.
(let ((list initial-environment)
pair start)
;; clear out the current environment settings
(find-file "~/.MacOSX/environment.plist")
(goto-char (point-min))
(setq start (search-forward "<dict>\n"))
(search-forward "</dict>")
(beginning-of-line)
(delete-region start (point))
(while list
(setq pair (split-string (car list) "=")
list (cdr list))
(insert " <key>" (nth 0 pair) "</key>\n")
(insert " <string>" (nth 1 pair) "</string>\n"))
;; Save the buffer.
(save-buffer)))
Note: You must create a dummy ##environment.plist## file to seed the process.
== Launching from Spotlight ==
Because Spotlight's parent process is launchd, Emacs won't pick up any environment variables you have set in your ##.bashrc## or similar. To set environment variables for launchd, put them in in ##/etc/launchd.conf## or ##$HOME/.launchd.conf##. The syntax is tcsh.
For example:
% cat /etc/launchd.conf
# include macports in global path - basically so Emacs.app can see git
setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
You will have to reboot for launchd to reload ##launchd.conf##. If you don't want to do that, you can use ##launchctl setenv## to set environment variables for launchd like so:
% launchctl setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
== Keyboard Handling and European Characters ==
Some useful resources: http://en.wikipedia.org/wiki/Keyboard_layout http://www.petermaurer.de/nasi.php?section=keycodes
I have tried outlining 3 basic options for European users in a blog post/video [[http://blog.enqueue.eu/emacs_mac_2 here]]. I do not have a clue about Asian character input, though. Open to comment.
== Questions ==
* Can not set default window position and size by ./Emacs.app/Contents/MacOS/Emacs -q -g 400x400 or org.gnu.Emacs.plist. Is there another way to set default window size except from .emacs?
[new:AlpAker:2011-05-23 19:29 UTC]
Not without recompiling, unfortunately. The NextStep (i.e., OS X) port explicitly disregards any geometry parameters that appear among the command line arguments (look at the the definition of `command-line-ns-option-alist' in lisp/startup.el). It *should* read org.gnu.Emacs.plist, but the implementation of that is incomplete, so as you've found out, that method doesn't work either. Your only options are to modify startup.el to pass size parameters to the initial make-frame command, or to change the values of ##DEFAULT_ROWS## and ##DEFAULT_COLS## in src/frame.c. In either case, you'll have to rebuild the application. -- AlpAker
[new]
* I'm missing an "emacs" binary, to execute from the command line, from Emacs.app. It's expected by some Makefiles, for instance. Does anyone know how to create or fake one? -- ThomasKappler
The executable binary is already there: Emacs.app/Contents/MacOS/Emacs. -- UntitledApple
[new]
* Is there a way to get visual beep to NOT be a 100x100 black square
in the middle of the window? That's beyond unusable and completely
preventing me from upgrading from 22 to 23. -- RyanDavis
* These build directions fail under 10.6.1 (Snow Leopard). Does anyone know when a fix is planned?
** Snow Leopard (10.6.1) has to be 32bit.
$ CC='gcc -arch i386' ./configure --with-ns
$ make bootstrap
** The above still blows up for me on 10.6.1, trying to compile 23.1, as does trying to just run 'make' after the configure step.
----
CategoryPorts