From 67c39d9d3827aadffd022ac75500c288e9b4c98b Mon Sep 17 00:00:00 2001 From: Mark Sprevak Date: Mon, 2 Nov 2015 20:52:23 +0000 Subject: [PATCH 1/2] refactor to improve speed and customisation: - open buffer (fast), rather than launching new MacVim process (slow), for each message - send arbitrary Ex commands to MacVim on opening message (default is `set filetype=markdown`) --- README.mdown | 13 ++++++++++++- Support/bin/edit | 26 +++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/README.mdown b/README.mdown index 6c8f635..0c78b54 100644 --- a/README.mdown +++ b/README.mdown @@ -2,6 +2,17 @@ You can install this bundle in MailMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you. +# Customization + +You can run arbitrary Ex commands on opening a message in MacVim. +The command are set using the `CMD` variable inside `Support/bin/edit`. +The default commands are: + +``` +set filetype=markdown +redraw! +``` + # License If not otherwise specified (see below), files in this repository fall under the following license: @@ -11,4 +22,4 @@ If not otherwise specified (see below), files in this repository fall under the express or implied warranty, and with no claim as to its suitability for any purpose. -An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. \ No newline at end of file +An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. diff --git a/Support/bin/edit b/Support/bin/edit index 95fe624..d111b12 100755 --- a/Support/bin/edit +++ b/Support/bin/edit @@ -2,14 +2,30 @@ ## # edit: backend script of the MailMate MacVim bundle, used to invoke vim -# +# # Original author: O'Shaughnessy Evans +# +# 2015-11-02: Modified by Mark Sprevak +# - open buffer (fast), rather than launching new MacVim process (slow), for each message +# - send arbitrary Ex commands to MacVim on opening message (default is `set filetype=markdown`) ## +MVIM=/usr/local/bin/mvim PATH=$HOME/bin:~/Applications/MacVim.app/Contents/MacOS:/Applications/MacVim.app/Contents/MacOS:/usr/local/bin:$PATH -hash mvim 2>/dev/null && VISUAL=mvim || VISUAL=Vim +# Ex commands to run on opening message +CMD=''\ +'set filetype=markdown | '\ +'redraw!' -open -g -a Marked "$MM_EDIT_FILEPATH" 2>/dev/null -$VISUAL -gf +$MM_LINE_NUMBER -c "set filetype=markdown" "$MM_EDIT_FILEPATH" -osascript -e 'tell app "MailMate" to activate' +# check if mvim already running +SERVERS=$($MVIM --serverlist) + +if [ -z "$SERVERS" ]; then + # Open new mvim instance + $MVIM +"$CMD" "${MM_EDIT_FILEPATH}" +else + # load file in current mvim instance + $MVIM --remote "${MM_EDIT_FILEPATH}" + $MVIM --remote-send ":$CMD" +fi From 703f34c4c21a8ba345123c8d022794837e556db8 Mon Sep 17 00:00:00 2001 From: Mark Sprevak Date: Tue, 3 Nov 2015 09:40:14 +0000 Subject: [PATCH 2/2] simplify PATH; can assume mvim in /usr/local/bin --- Support/bin/edit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Support/bin/edit b/Support/bin/edit index d111b12..5fa3e3c 100755 --- a/Support/bin/edit +++ b/Support/bin/edit @@ -11,7 +11,7 @@ ## MVIM=/usr/local/bin/mvim -PATH=$HOME/bin:~/Applications/MacVim.app/Contents/MacOS:/Applications/MacVim.app/Contents/MacOS:/usr/local/bin:$PATH +PATH=$HOME/bin:/usr/local/bin:$PATH # Ex commands to run on opening message CMD=''\