]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
cosmetic fix
[lyx.git] / src / lyx_main.C
index 2a6b9b84ccd6bd7dd28c15b7041bfdaef6b5313c..eb44e0bb296fd3749ce492e21d616b733bf54166 100644 (file)
@@ -59,8 +59,6 @@ using std::signal;
 using std::system;
 #endif
 
-namespace grfx = lyx::graphics;
-
 extern void LoadLyXFile(string const &);
 extern void QuitLyX();
 
@@ -68,7 +66,6 @@ extern LyXServer * lyxserver;
 
 string system_lyxdir;
 string build_lyxdir;
-string system_tempdir;
 string user_lyxdir;
 
 DebugStream lyxerr;
@@ -99,14 +96,10 @@ LyX::LyX(int & argc, char * argv[])
        // we need to parse for "-dbg" and "-help"
        bool const want_gui = easyParse(argc, argv);
 
-       // Global bindings (this must be done as early as possible.) (Lgb)
-       toplevel_keymap.reset(new kb_keymap);
-       defaultKeyBindings(toplevel_keymap.get());
-
        // set the DisplayTranslator only once; should that be done here??
        // if this should not be in this file, please also remove
        // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
-       grfx::setDisplayTranslator();
+       lyx::graphics::setDisplayTranslator();
 
        if (want_gui) {
                lyx_gui::parse_init(argc, argv);
@@ -167,17 +160,15 @@ LyX::LyX(int & argc, char * argv[])
                        }
                }
 
-               bool success = false;
-
                // try to dispatch to last loaded buffer first
-               if (last_loaded)
-                       last_loaded->dispatch(batch_command, &success);
-               else
-                       lyxerr << _("Batch command specified but no "
-                                   "file loaded. Exiting.") << endl;
-
-               QuitLyX();
-               exit(!success);
+               if (last_loaded) {
+                       bool success = false;
+                       if (last_loaded->dispatch(batch_command, &success)) {
+                               QuitLyX();
+                               exit(!success);
+                       }
+               } 
+               files.clear(); // the files are already loaded
        }
 
        lyx_gui::start(batch_command, files);
@@ -475,20 +466,22 @@ void LyX::init(bool gui)
        lyxerr[Debug::INIT] << "Reading layouts..." << endl;
        LyXSetStyle();
 
-       // Ensure that we have really read a bind file, so that LyX is
-       // usable.
-       lyxrc.readBindFileIfNeeded();
+       if (gui) {
+               // Set up bindings
+               toplevel_keymap.reset(new kb_keymap);
+               defaultKeyBindings(toplevel_keymap.get());
+               toplevel_keymap->read(lyxrc.bind_file);
 
-       // Read menus
-       readUIFile(lyxrc.ui_file);
+               // Read menus
+               readUIFile(lyxrc.ui_file);
+       }
 
        if (lyxerr.debugging(Debug::LYXRC))
                lyxrc.print();
 
        os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
-       system_tempdir = os::getTmpDir();
        if (lyxerr.debugging(Debug::INIT)) {
-               lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
+               lyxerr << "LyX tmp dir: `" << os::getTmpDir() << '\'' << endl;
        }
 
        lyxerr[Debug::INIT] << "Reading lastfiles `"