Index: src/Plugins/Qt/QTMPrinterSettings.cpp
===================================================================
--- src/Plugins/Qt/QTMPrinterSettings.cpp	(revision 4245)
+++ src/Plugins/Qt/QTMPrinterSettings.cpp	(working copy)
@@ -150,7 +150,7 @@
 }
 
 
-#if defined(Q_WS_MAC) || defined(Q_WS_X11)
+#if (defined(Q_WS_MAC) || defined(Q_WS_X11))
 
 /*!
  * @todo Read the printing program from some configuration file/preference?
Index: src/Plugins/Qt/QTMPrinterSettings.hpp
===================================================================
--- src/Plugins/Qt/QTMPrinterSettings.hpp	(revision 4245)
+++ src/Plugins/Qt/QTMPrinterSettings.hpp	(working copy)
@@ -122,7 +122,7 @@
   QHash<QString, QString> printerOptions;
 };
 
-#if defined(Q_WS_MAC) || defined (Q_WS_X11)
+#if (defined(Q_WS_MAC) || defined (Q_WS_X11))
 
 /*!
  * Implementation specific to the CUPS driver under MacOS and Linux. This
Index: src/Plugins/Qt/qt_printer_widget.cpp
===================================================================
--- src/Plugins/Qt/qt_printer_widget.cpp	(revision 4245)
+++ src/Plugins/Qt/qt_printer_widget.cpp	(working copy)
@@ -25,7 +25,7 @@
  */
 qt_printer_widget_rep::qt_printer_widget_rep (command _cmd, url _file)
 : commandAfterExecution(_cmd) {
-#if defined(Q_WS_MAC) || defined(Q_WS_X11)
+#if (defined(Q_WS_MAC) || defined(Q_WS_X11))
   if (!_settings)
     _settings = new CupsQTMPrinterSettings();
 #endif
Index: src/System/Language/text_language.cpp
===================================================================
--- src/System/Language/text_language.cpp	(revision 4245)
+++ src/System/Language/text_language.cpp	(working copy)
@@ -41,7 +41,7 @@
 text_property
 text_language_rep::advance (tree t, int& pos) {
   string s= t->label;
-  if (pos == N(s)) return &tp_normal_rep;
+  if (pos >= N(s)) return &tp_normal_rep;
 
   if (s[pos]==' ') {
     pos++;
Index: src/Texmacs/Server/tm_server.cpp
===================================================================
--- src/Texmacs/Server/tm_server.cpp	(revision 4245)
+++ src/Texmacs/Server/tm_server.cpp	(working copy)
@@ -341,8 +341,9 @@
 
 void
 tm_server_rep::focus_on_editor (editor ed) {
+  
   int i,j;
-  for (i=0; i<N(bufs); i++) {
+  for (i=0; i<=N(bufs); i++) {
     tm_buffer buf= (tm_buffer) bufs[i];
     for (j=0; j<N(buf->vws); j++) {
       tm_view vw= (tm_view) buf->vws[j];
Index: src/Edit/Interface/edit_interface.cpp
===================================================================
--- src/Edit/Interface/edit_interface.cpp	(revision 4245)
+++ src/Edit/Interface/edit_interface.cpp	(working copy)
@@ -32,7 +32,7 @@
   else if (mode == "prog") return PROG_LANGUAGE;
   else if (mode == "src") return LANGUAGE;
   cerr << "Mode = " << mode << "\n";
-  FAILED ("invalid mode");
+  //FAILED ("invalid mode");
   return LANGUAGE;
 }
 
Index: src/Edit/Replace/edit_replace.hpp
===================================================================
--- src/Edit/Replace/edit_replace.hpp	(revision 4245)
+++ src/Edit/Replace/edit_replace.hpp	(working copy)
@@ -66,6 +66,7 @@
   void search_stop ();
   void search_button_next ();
   bool search_keypress (string s);
+  void search_string (string s, bool forward);
   void replace_start (tree what, tree by, bool forward= true);
   void replace_next ();
   bool replace_keypress (string s);
Index: src/Edit/Replace/edit_search.cpp
===================================================================
--- src/Edit/Replace/edit_search.cpp	(revision 4245)
+++ src/Edit/Replace/edit_search.cpp	(working copy)
@@ -408,6 +408,29 @@
   else set_message (concat ("Searching ", verbatim (w)), r);
 }
 
+/**
+ * Skips the interactive search mode: instead of using the overloaded keypress
+ * handler, we search for a full string.
+ */
+void edit_replace_rep::search_string(string s, bool fwd) {
+  string r ("forward search");
+  if (!fwd) r= "backward search";  
+  forward     = fwd;
+  
+  // How could we avoid using these? (And still be able to "search next"?)
+  search_mode = copy (get_env_string (MODE));
+  search_lan  = copy (get_env_string (MODE_LANGUAGE (search_mode)));
+  
+  // Initialize the search
+  search_at   = tp;
+  search_what = tree ("");
+  where_stack = list<path> ();
+  what_stack  = tree("");
+  set_input_mode (INPUT_SEARCH);
+  set_message (concat ("Searching for ", verbatim(s)), r);
+  search_next(s, forward, false);
+}
+
 void
 edit_replace_rep::search_next (tree what, bool forward, bool step) {
   where_stack= list<path> (copy (search_at), where_stack);
Index: src/Edit/editor.hpp
===================================================================
--- src/Edit/editor.hpp	(revision 4245)
+++ src/Edit/editor.hpp	(working copy)
@@ -476,6 +476,7 @@
   virtual void search_start (bool forward= true) = 0;
   virtual void search_button_next () = 0;
   virtual bool search_keypress (string s) = 0;
+  virtual void search_string (string s, bool forward) = 0;
   virtual void replace_start (tree what, tree by, bool forward= true) = 0;
   virtual bool replace_keypress (string s) = 0;
   virtual void spell_start () = 0;
Index: src/Guile/Glue/glue_editor.cpp
===================================================================
--- src/Guile/Glue/glue_editor.cpp	(revision 4245)
+++ src/Guile/Glue/glue_editor.cpp	(working copy)
@@ -2342,6 +2342,21 @@
 }
 
 SCM
+tmg_search_string (SCM arg1, SCM arg2) {
+  SCM_ASSERT_STRING (arg1, SCM_ARG1, "search-string");
+  SCM_ASSERT_BOOL (arg2, SCM_ARG2, "search-string");
+
+  string in1= scm_to_string (arg1);
+  bool in2= scm_to_bool (arg2);
+
+  // SCM_DEFER_INTS;
+  get_server()->get_editor()->search_string (in1, in2);
+  // SCM_ALLOW_INTS;
+
+  return SCM_UNSPECIFIED;
+}
+
+SCM
 tmg_replace_start (SCM arg1, SCM arg2, SCM arg3) {
   SCM_ASSERT_STRING (arg1, SCM_ARG1, "replace-start");
   SCM_ASSERT_STRING (arg2, SCM_ARG2, "replace-start");
@@ -3014,6 +3029,7 @@
   scm_new_procedure ("in-spell-mode?", (FN) tmg_in_spell_modeP, 0, 0, 0);
   scm_new_procedure ("search-start", (FN) tmg_search_start, 1, 0, 0);
   scm_new_procedure ("search-button-next", (FN) tmg_search_button_next, 0, 0, 0);
+  scm_new_procedure ("search-string", (FN) tmg_search_string, 2, 0, 0);
   scm_new_procedure ("replace-start", (FN) tmg_replace_start, 3, 0, 0);
   scm_new_procedure ("spell-start", (FN) tmg_spell_start, 0, 0, 0);
   scm_new_procedure ("spell-replace", (FN) tmg_spell_replace, 1, 0, 0);
Index: src/Guile/Glue/build-glue-editor.scm
===================================================================
--- src/Guile/Glue/build-glue-editor.scm	(revision 4245)
+++ src/Guile/Glue/build-glue-editor.scm	(working copy)
@@ -246,6 +246,7 @@
   (in-spell-mode? in_spell_mode (bool))
   (search-start search_start (void bool))
   (search-button-next search_button_next (void))
+  (search-string search_string (void string bool))
   (replace-start replace_start (void string string bool))
   (spell-start spell_start (void))
   (spell-replace spell_replace (void string))
Index: TeXmacs/progs/utils/library/cursor.scm
===================================================================
--- TeXmacs/progs/utils/library/cursor.scm	(revision 4245)
+++ TeXmacs/progs/utils/library/cursor.scm	(working copy)
@@ -231,3 +231,7 @@
   (:argument what "Replace")
   (:argument by "Replace by")
   (replace-start what by #t))
+
+(tm-define (search-string-start what)
+  (:argument what "Search string")
+  (search-string what #t))
\ No newline at end of file
Index: TeXmacs/progs/texmacs/menus/edit-menu.scm
===================================================================
--- TeXmacs/progs/texmacs/menus/edit-menu.scm	(revision 4245)
+++ TeXmacs/progs/texmacs/menus/edit-menu.scm	(working copy)
@@ -61,9 +61,14 @@
   (if (detailed-menus?)
       ("Clear" (clipboard-clear "primary")))
   ---
-  ("Search" (search-start #t))
+  ("Incremental search" (search-start #t))
+  ("Search" (interactive search-string-start))
+  ; search-button-next is just a wrapper for edit_replace_rep::search_button_next()
+  ; which in turn sets the input mode and performs a search_next() with the proper
+  ; parameters. A direct call to search-next would end the search after one step.
+  (when (search-mode?)
+      ("Find next match" (search-button-next)))
   ("Replace" (interactive replace-start-forward))
-
   (if (not (in-math?))
       ("Spell" (spell-start)))
   (if (in-math?)
