Commits

Éric Araujo committed d8ad23b

Add vim cleverness to the script.

Sadly, this is at the cost of flexibility; I’ll see how to have custom
vim invocations for commits with and without diffs without removing the
possibility to use other editors. I’ll probably change the variable
EDITOR for a couple of functions, edit_message and edit_message_diff.

Comments (0)

Files changed (1)

 # This is an example of using HGEDITOR to create of diff to review the
 # changes while commiting.
 
-# If you want to pass your favourite editor some other parameters
-# only for Mercurial, modify this:
-case "${EDITOR}" in
-    "")
-        EDITOR="vi"
-        ;;
-    emacs)
-        EDITOR="$EDITOR -nw"
-        ;;
-    gvim|vim)
-        EDITOR="$EDITOR -f -o"
-        ;;
-esac
-
-
 # set envvar that can be useful in the editor
 REPO="$PWD"; export REPO
 HGTMP=""
     MD5=$(which md5 2>/dev/null)
 [ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/message"`
 if [ -s "$HGTMP/diff" ]; then
-    $EDITOR "$HGTMP/message" "$HGTMP/diff" || exit $?
+    # This buftype + vsplit combo makes vim quit when the diff buffer is
+    # closed, even if the diff buffer is not
+    vim -f "$HGTMP/diff" +"set buftype=help" +"vsplit $HGTMP/message" +"set textwidth=72" || exit $?
 else
-    $EDITOR "$HGTMP/message" || exit $?
+    vim -f "$HGTMP/message" +"set textwidth=72" || exit $?
 fi
 
 [ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)