svndiff

Index: src/LyXAction.cpp
===================================================================
--- src/LyXAction.cpp	(révision 29393)
+++ src/LyXAction.cpp	(copie de travail)
@@ -3263,6 +3263,21 @@ void LyXAction::init()
  */
 		{ LFUN_BUFFER_ZOOM_OUT, "buffer-zoom-out", ReadOnly, Buffer },
 
+/*!
+ * \var lyx::FuncCode lyx::LFUN_INSET_FORALL
+
+ * \li Action: Apply the given commands on insets of a given name. WARNING: use
+               at your own risks; this function gives you too many ways of
+	       shooting yourself in the foot.
+ * \li Syntax: inset-forall <NAME> <LFUN-COMMAND>
+ * \li Sample: The name is used like for InsetLayout in layout files: "Note" 
+               matches all note insets, while "Note:Note" only matches LyX 
+	       yellow note insets. 
+ * \li Origin: JMarc, 22 Apr 2009
+ * \endvar
+ */
+		{ LFUN_INSET_FORALL, "inset-forall", ReadOnly, Edit },
+
 		{ LFUN_NOACTION, "", Noop, Hidden }
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 	};
Index: src/BufferView.cpp
===================================================================
--- src/BufferView.cpp	(révision 29393)
+++ src/BufferView.cpp	(copie de travail)
@@ -35,6 +35,7 @@
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "LyX.h"
+#include "LyXAction.h"
 #include "lyxfind.h"
 #include "LyXFunc.h"
 #include "Layout.h"
@@ -1002,6 +1003,7 @@ bool BufferView::getStatus(FuncRequest c
 	case LFUN_SCROLL:
 	case LFUN_SCREEN_UP_SELECT:
 	case LFUN_SCREEN_DOWN_SELECT:
+	case LFUN_INSET_FORALL:
 		flag.setEnabled(true);
 		break;
 
@@ -1474,6 +1476,42 @@ bool BufferView::dispatch(FuncRequest co
 		break;
 	}
 
+
+	// This would be in Buffer class if only Cursor did not require a bufferview
+	case LFUN_INSET_FORALL: {
+		docstring name;
+		docstring const commandstr = split(cmd.argument(), name, ' ');
+		FuncRequest const fr = lyxaction.lookupFunc(to_utf8(commandstr));
+
+		Cursor & cur = d->cursor_;
+		cur.reset(buffer().inset());
+		cur.forwardInset();
+		cur.beginUndoGroup();
+		while(cur) {
+			Inset * ins = cur.nextInset();
+			if (!ins)
+				break;
+			docstring insname = ins->name();
+			while (!insname.empty()) {
+				if (insname == name) {
+					cur.recordUndo();
+					lyx::dispatch(fr);
+					break;
+				}
+				size_t const i = insname.rfind(':');
+				if (i == string::npos)
+					break;
+				insname = insname.substr(0, i);
+			}
+			cur.forwardInset();
+		}
+		cur.endUndoGroup();
+		cur.reset(buffer().inset());
+		processUpdateFlags(Update::Force);
+		break;
+	}
+
+
 	case LFUN_ALL_INSETS_TOGGLE: {
 		string action;
 		string const name = split(to_utf8(cmd.argument()), action, ' ');
Index: src/FuncCode.h
===================================================================
--- src/FuncCode.h	(révision 29393)
+++ src/FuncCode.h	(copie de travail)
@@ -428,6 +428,7 @@ enum FuncCode
 	// 330
 	LFUN_MATH_BIGDELIM,
 	LFUN_MATH_FONT_STYLE,
+	LFUN_INSET_FORALL,		// JMarc, 20090422
 
 
 	LFUN_LASTACTION                 // end of the table
