From 15409bae5ffdfce4ef17c4ccf14c8cd4c1b8f37e Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 14 Jun 2015 19:08:06 +0200 Subject: handle environment variables more consistently * the registers beginning with "$" are exported into sub-process environments. Therefore macros can now modify the environment (variables) of commands executed via EC/EG. A variable can be modified temporarily, e.g.: [[$FOO] ^U[$FOO]bar$ EC...$ ][$FOO] * SciTECO accesses the global environment registers instead of using g_getenv(). Therefore now, tilde-expansion will always use the current value of the "$HOME" register. Previously, both register and environment variable could diverge. * This effectively fully maps the process environment to a subset of Q-Registers beginning with "$". * This hasn't been implemented by mapping those registers to special implementations that updates the process environment directly, since g_setenv() is non-thread-safe on UNIX and we're expected to have threads soon - at least in the GTK+ UI. --- src/qregisters.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/qregisters.h') diff --git a/src/qregisters.h b/src/qregisters.h index ec40bb4..0ca230e 100644 --- a/src/qregisters.h +++ b/src/qregisters.h @@ -255,6 +255,10 @@ public: insert(QRegister *reg) { reg->must_undo = must_undo; + /* FIXME: Returns already existing regs with the same name. + This could be used to optimize commands that initialize + a register if it does not yet exist (saves one table + lookup): */ RBTree::insert(reg); return reg; } @@ -283,6 +287,13 @@ public: return operator [](buf); } + inline QRegister * + nfind(const gchar *name) + { + QRegister reg(name); + return (QRegister *)RBTree::nfind(®); + } + void edit(QRegister *reg); inline QRegister * edit(const gchar *name) @@ -295,6 +306,9 @@ public: return reg; } + void set_environ(void); + gchar **get_environ(void); + void clear(void); }; -- cgit v1.2.3