style/default/mode-line.css: hide text widgets with no contents
[conkeror/arlinius.git] / modules / rc.js
blobbd257271ba901d64b258cf172dc91798d12ad8ff
1 /**
2  * (C) Copyright 2004-2007 Shawn Betts
3  * (C) Copyright 2007-2010 John J. Foerch
4  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
5  *
6  * Use, modification, and distribution are subject to the terms specified in the
7  * COPYING file.
8 **/
10 let (default_rc = get_home_directory()) {
11     default_rc.appendRelativePath(".conkerorrc");
12     default_pref("conkeror.rcfile", default_rc.path);
15 function load_rc () {
16     var path;
17     var rcfile = get_pref("conkeror.rcfile");
18     if (rcfile.length == 0)
19         //FIXME: log that the rc is disabled
20         return;
21     path = make_file(rcfile);
22     if (! path.exists()) {
23         if (path.isSymlink())
24             dumpln("w: broken symlink, \""+rcfile+"\"");
25         else if (pref_has_user_value("conkeror.rcfile"))
26             dumpln("w: preference conkeror.rcfile is set to "+
27                    "non-existent path, \""+rcfile+"\"");
28         //FIXME: else log that the rc does not exist
29         return;
30     }
31     var files = [];
32     var ret;
33     if (path.isDirectory()) {
34         var entries = path.directoryEntries;
35         while (entries.hasMoreElements()) {
36             var entry = entries.getNext();
37             entry.QueryInterface(Ci.nsIFile);
38             if (entry.leafName.substr(-3).toLowerCase() == '.js')
39                 files.push(entry);
40         }
41         files.sort(function (a, b) {
42             if (a.leafName < b.leafName)
43                 return -1;
44             else if (a.leafName > b.leafName)
45                 return 1;
46             else
47                 return 0;
48         });
49         path.appendRelativePath("a");
50         ret = path.path.substr(0, path.path.length - 1) + "*.js";
51     } else {
52         files.push(path);
53         ret = path.path;
54     }
55     for (var i = 0; files[i]; i++) {
56         try {
57             load(files[i]);
58         } catch (e) {
59             dump_error(e);
60         }
61     }
62     //FIXME: log what was loaded instead of returning the value to be
63     //       logged by the caller.
64     return ret;
67 provide("rc");