From: Michael D. Lowis Date: Tue, 31 Jan 2017 13:31:27 +0000 (-0500) Subject: Added logic to load an RC file in the edit wrapper script and each subshell for comma... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9c0920d714f128ce37070193163caeb6ffdfd461;p=projs%2Ftide.git Added logic to load an RC file in the edit wrapper script and each subshell for command execution. This allows the user to define functions that may be used from within the editor for some shells (bash) nad to configure environment variables for use in and by the editor --- diff --git a/Makefile b/Makefile index 27359b4..4fd995f 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ all: xedit xpick clean: $(RM) *.o lib*/*.o tests/*.o *.a xpick xedit unittests + $(RM) *.d lib*/*.d tests/*.d $(RM) *.gcno lib*/*.gcno tests/*.gcno $(RM) *.gcda lib*/*.gcda tests/*.gcda $(RM) *.gcov lib*/*.gcov tests/*.gcov diff --git a/TODO.md b/TODO.md index a42e607..448a7c8 100644 --- a/TODO.md +++ b/TODO.md @@ -10,8 +10,6 @@ Up Next: * invalid memory accesses while viewing docs/waf * check for file changes on save * check for file changes when window regains focus -* Use $SHELL if defined, fallback on /bin/sh -* Set ENV to ~/.config/edit/rc if undefined The Rest: @@ -19,12 +17,13 @@ The Rest: * add a distinct state for pointer move versus drag * Add a SaveAs tag that takes an argument for the filename to save as * Add a GoTo tag for ctags lookup and line number jump -* implement command diffing logic to optimize the undo/redo log * add command line flags to toggle options (Tabs, Indent, etc..) * Add a ctrl+space shortcut to autocomplete ctag * off by one error on scrolling up with wrapped lines * 100% coverage with unit and unit-integration tests * shortcut to repeat previous operation +* implement command diffing logic to optimize the undo/redo log + The Future: @@ -35,3 +34,4 @@ The Future: * Acme-like window manager * Win-like terminal emulator * File browser + diff --git a/edit b/edit index f08e35e..6da5094 100755 --- a/edit +++ b/edit @@ -4,6 +4,11 @@ # while editing. export PATH="$HOME/.config/edit/tools:$PATH" +# If $SHELL is bash, this will allow us to define functions in an RC file and +# use them in the editor +export EDITRCFILE="$HOME/.config/edit/editrc" +export BASH_ENV="$EDITRCFILE" + # Now figure out the correct editor to execute if [ -z "$DISPLAY" ]; then if [ -z "$EDITOR" ]; then @@ -15,6 +20,7 @@ elif [ 0 -eq $# ]; then (nohup xedit > /dev/null 2>&1) & else for f in "$@"; do + [ -f "$EDITRCFILE" ] && . "$EDITRCFILE" (nohup xedit "$f" > /dev/null 2>&1) & done fi diff --git a/xedit.c b/xedit.c index ba59599..5349ee8 100644 --- a/xedit.c +++ b/xedit.c @@ -179,6 +179,9 @@ static KeyBinding Bindings[] = { /* External Commands *****************************************************************************/ +/* The shell: Filled in with $SHELL. Used to execute commands */ +static char* ShellCmd[] = { NULL, "-c", NULL, NULL }; + #ifdef __MACH__ static char* CopyCmd[] = { "pbcopy", NULL }; static char* PasteCmd[] = { "pbpaste", NULL }; @@ -186,7 +189,6 @@ static char* PasteCmd[] = { "pbpaste", NULL }; static char* CopyCmd[] = { "xsel", "-bi", NULL }; static char* PasteCmd[] = { "xsel", "-bo", NULL }; #endif -static char* ShellCmd[] = { "/bin/sh", "-c", NULL, NULL }; static char* PickFileCmd[] = { "xfilepick", ".", NULL }; static char* PickTagCmd[] = { "xtagpick", "tags", NULL, NULL }; static char* OpenCmd[] = { "xedit", NULL, NULL }; @@ -196,6 +198,9 @@ static char* SedCmd[] = { "sed", "-e", NULL, NULL }; *****************************************************************************/ #ifndef TEST int main(int argc, char** argv) { + /* setup the shell */ + ShellCmd[0] = getenv("SHELL"); + if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh"; /* load the buffer views */ char* tags = getenv("EDITTAGS"); view_init(getview(TAGS), NULL);