diff --git a/src/FuncCode.h b/src/FuncCode.h
index b9c88c8..ebab4cc 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -413,6 +413,8 @@ enum FuncCode
LFUN_WORD_FINDADV, // Tommaso, 20081003
LFUN_REGEXP_MODE, // Tommaso, 20081003
LFUN_COPY_LABEL_AS_REF, // sts, 20081116
+ // 320
+ LFUN_VC_COMMAND,
LFUN_LASTACTION // end of the table
};
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 278cbc6..72ef570 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1967,6 +1967,22 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_VC_UNDO_LAST, "vc-undo-last", ReadOnly, System },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_VC_COMMAND
+ * \li Action: Executes external command. This command is intended to support
+ additonal VCS commands.
+ * \li Syntax: vc-command <FLAG> <PATH> <COMMAND>
+ * \li Params: <FLAG>: Flags for the command can be combined together.\n
+ U - dUmmy - no flags \n
+ D - Doc - need document loaded to proceed \n
+ I - dIrty - mark document dirty \n
+ R - Reload - reload the document after command
execution \n
+ <PATH>: path where to start. $$i will be replaced by the
current document path.
+ <COMMAND>: command to execute. $$i will be replaced by the
current document.
It seems potentially confusing to use $$i for two different things, and
I can imagine wanting the path in the latter case. I think there's some
precedent here, no?
+ * \li Origin: sanda, 12 Dec 2008
+ * \endvar
+ */
+ { LFUN_VC_COMMAND, "vc-command", NoBuffer | ReadOnly, System },
/*!
* \var lyx::FuncCode lyx::LFUN_CHANGES_TRACK
diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp
index 3a29fec..7d20aff 100644
--- a/src/LyXFunc.cpp
+++ b/src/LyXFunc.cpp
@@ -566,6 +566,15 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd)
const
break;
}
+ case LFUN_VC_COMMAND: {
+ if (cmd.argument().empty())
+ enable = false;
+
+ if (!buf && (contains(cmd.getArg(0), 'D')))
+ enable = false;
+ break;
+ }
+
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD:
case LFUN_WORD_FINDADV:
@@ -1587,6 +1596,34 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
theSession().bookmarks().clear();
break;
+ case LFUN_VC_COMMAND: {
+ string path = cmd.getArg(1);
+ if (path == "$$i" && buffer)
+ path = buffer->filePath();
The way you describe this, it looks as if you could have put:
$$i/subdir/. But apparently not. I'm not sure if you ever would want to
do that, but it'd be easy to allow it.
+ LYXERR(Debug::LYXVC, "Directory: " << path);
+ FileName pp(path);
+ support::PathChanger p(pp);
Is some kind of error checking needed here?
+
+ string command = cmd.getArg(2);
+ if (command.empty())
+ break;
+ if (buffer)
+ command = subst(command, "$$i",
buffer->absFileName());
+ LYXERR(Debug::LYXVC, "Command: " << command);
+ Systemcall one;
+ one.startscript(Systemcall::Wait, command);
+
+ if (!buffer)
+ break;
+ string flag = cmd.getArg(0);
+ if (contains(flag, 'I'))
+ buffer->markDirty();
+ if (contains(flag, 'R'))
+ reloadBuffer();
+
+ break;
+ }
+
default:
LASSERT(theApp(), /**/);
// Let the frontend dispatch its own actions.
rh