Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor to improve speed and customisation: #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
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.
28 changes: 22 additions & 6 deletions Support/bin/edit
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@

##
# edit: backend script of the MailMate MacVim bundle, used to invoke vim
#
#
# Original author: O'Shaughnessy Evans <[email protected]>
#
# 2015-11-02: Modified by Mark Sprevak <http://sites.google.com/site/msprevak>
# - 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`)
##

PATH=$HOME/bin:~/Applications/MacVim.app/Contents/MacOS:/Applications/MacVim.app/Contents/MacOS:/usr/local/bin:$PATH
MVIM=/usr/local/bin/mvim
PATH=$HOME/bin:/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<CR>"
fi