aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-02-03 19:51:07 +0000
committerRichard M. Stallman1994-02-03 19:51:07 +0000
commit07f4d1231f754ba29908086fe57a0b044ecefe5d (patch)
treef9ba19d77bd4aea66a71e4a6847b7dac98d451ba /src
parent0736cafe0d5fbd2f432f3bae6eb73ef68e79109a (diff)
downloademacs-07f4d1231f754ba29908086fe57a0b044ecefe5d.tar.gz
emacs-07f4d1231f754ba29908086fe57a0b044ecefe5d.zip
(init_cmdargs): Set Vinstallation_directory.
(syms_of_emacs): staticpro it.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c
index bd5e175bebe..e7b2f41b0aa 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -63,6 +63,10 @@ Lisp_Object Vinvocation_name;
63/* The directory name from which Emacs was invoked. */ 63/* The directory name from which Emacs was invoked. */
64Lisp_Object Vinvocation_directory; 64Lisp_Object Vinvocation_directory;
65 65
66/* The directory name in which to find subdirs such as lisp and etc.
67 nil means get them only from PATH_LOADSEARCH. */
68Lisp_Object Vinstallation_directory;
69
66/* Hook run by `kill-emacs' before it does really anything. */ 70/* Hook run by `kill-emacs' before it does really anything. */
67Lisp_Object Vkill_emacs_hook; 71Lisp_Object Vkill_emacs_hook;
68 72
@@ -179,6 +183,7 @@ init_cmdargs (argc, argv, skip_args)
179 int skip_args; 183 int skip_args;
180{ 184{
181 register int i; 185 register int i;
186 Lisp_Object name, dir;
182 187
183 Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0])); 188 Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0]));
184 Vinvocation_directory = Ffile_name_directory (build_string (argv[0])); 189 Vinvocation_directory = Ffile_name_directory (build_string (argv[0]));
@@ -193,6 +198,81 @@ init_cmdargs (argc, argv, skip_args)
193 Vinvocation_directory = Ffile_name_directory (found); 198 Vinvocation_directory = Ffile_name_directory (found);
194 } 199 }
195 200
201 Vinstallation_directory = Qnil;
202
203 if (!NILP (Vinvocation_directory))
204 {
205 dir = Vinvocation_directory;
206 name = Fexpand_file_name (Vinvocation_name, dir);
207 while (1)
208 {
209 Lisp_Object tem, lisp_exists, lib_src_exists;
210 Lisp_Object etc_exists, info_exists;
211
212 /* See if dir contains subdirs for use by Emacs. */
213 tem = Fexpand_file_name (build_string ("lisp"), dir);
214 lisp_exists = Ffile_exists_p (tem);
215 if (!NILP (lisp_exists))
216 {
217 tem = Fexpand_file_name (build_string ("lib-src"), dir);
218 lib_src_exists = Ffile_exists_p (tem);
219 if (!NILP (lib_src_exists))
220 {
221 tem = Fexpand_file_name (build_string ("etc"), dir);
222 etc_exists = Ffile_exists_p (tem);
223 if (!NILP (etc_exists))
224 {
225 tem = Fexpand_file_name (build_string ("info"), dir);
226 info_exists = Ffile_exists_p (tem);
227 if (!NILP (info_exists))
228 {
229 Vinstallation_directory
230 = Ffile_name_as_directory (dir);
231 break;
232 }
233 }
234 }
235 }
236
237 /* See if dir's parent contains those subdirs. */
238 tem = Fexpand_file_name (build_string ("../lisp"), dir);
239 lisp_exists = Ffile_exists_p (tem);
240 if (!NILP (lisp_exists))
241 {
242 tem = Fexpand_file_name (build_string ("../lib-src"), dir);
243 lib_src_exists = Ffile_exists_p (tem);
244 if (!NILP (lib_src_exists))
245 {
246 tem = Fexpand_file_name (build_string ("../etc"), dir);
247 etc_exists = Ffile_exists_p (tem);
248 if (!NILP (etc_exists))
249 {
250 tem = Fexpand_file_name (build_string ("../info"), dir);
251 info_exists = Ffile_exists_p (tem);
252 if (!NILP (info_exists))
253 {
254 tem = Fexpand_file_name (build_string (".."), dir);
255 Vinstallation_directory
256 = Ffile_name_as_directory (tem);
257 break;
258 }
259 }
260 }
261 }
262
263 /* If the Emacs executable is actually a link,
264 next try the dir that the link points into. */
265 tem = Ffile_symlink_p (name);
266 if (!NILP (tem))
267 {
268 name = tem;
269 dir = Ffile_name_directory (name);
270 }
271 else
272 break;
273 }
274 }
275
196 Vcommand_line_args = Qnil; 276 Vcommand_line_args = Qnil;
197 277
198 for (i = argc - 1; i >= 0; i--) 278 for (i = argc - 1; i >= 0; i--)
@@ -962,6 +1042,8 @@ and only if the Emacs executable is installed with setuid to permit\n\
962it to change priority. (Emacs sets its uid back to the real uid.)"); 1042it to change priority. (Emacs sets its uid back to the real uid.)");
963 emacs_priority = 0; 1043 emacs_priority = 0;
964 1044
1045 staticpro (&Vinstallation_directory);
1046 Vinstallation_directory = Qnil;
965 staticpro (&Vinvocation_name); 1047 staticpro (&Vinvocation_name);
966 Vinvocation_name = Qnil; 1048 Vinvocation_name = Qnil;
967 staticpro (&Vinvocation_directory); 1049 staticpro (&Vinvocation_directory);