From: "Bob Hiestand" <bob.hiestand@gmail.com>
To: "SZEDER Gábor" <szeder@ira.uka.de>
Cc: "Jeff King" <peff@peff.net>,
vim@tpope.info, "Shawn O. Pearce" <spearce@spearce.org>,
git@vger.kernel.org
Subject: Re: [RFC/PATCH] remove vim syntax highlighting in favor of upstream
Date: Thu, 25 Sep 2008 09:00:49 -0500 [thread overview]
Message-ID: <cc29171c0809250700s3efa7601pbdb96d1bd94ab89b@mail.gmail.com> (raw)
In-Reply-To: <20080925124817.GC6816@neumann>
On Thu, Sep 25, 2008 at 7:48 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
> Hi,
>
> OK, so I'm complaining a bit.
>
> On Wed, Sep 24, 2008 at 09:56:58PM +0200, SZEDER Gábor wrote:
>> +To install:
>> +
>> + 1. Copy these files to vim's syntax directory $HOME/.vim/syntax
>> + 2. Auto-detect the editing of various git-related filetypes:
>> + $ cat >>$HOME/.vimrc <<'EOF'
>> + autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit
>> + autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
>> + autocmd BufNewFile,BufRead git-rebase-todo setf gitrebase
>> + autocmd BufNewFile,BufRead .msg.[0-9]*
>> + \ if getline(1) =~ '^From.*# This line is ignored.$' |
>> + \ setf gitsendemail |
>> + \ endif
>> + autocmd BufNewFile,BufRead *.git/**
>> + \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
>> + \ setf git |
>> + \ endif
>> + EOF
>
> There are issues with this second step. If I append this code to my
> .vimrc, then vim sometimes overrides the filetype with conf.
>
> vim has a guessing rule for detecting conf files, which triggers if
> one of the first five lines of the file begins with a '#'. So if I
> start to write a new commit message or I interactively rebase 4 or
> less commits, then this rule triggers and vim overrides the git
> filetype with filetype conf. If I do a commit --amend with a long
> enough original commit message or an interactive rebase with more than
> 4 commit, then this rule no more triggers and everything is fine.
>
> But what's really puzzling is that if I insert the above code into
> $VIMRUNTIME/filetype.vim (at the spot where it can be found in vim
> 7.2's filetype.vim), then everything works as expected, git filetypes
> are never overridden.
>
> This is not related to the changes in this patch. git's original vim
> syntax highlight for commit messages has the exact same behaviour.
>
> The first step is OK: it doesn't matter whether I put git-related
> syntax files under $HOME/.vim/syntax/ or under $VIMRUNTIME/syntax/.
I'd guess that your autocommands defined in .vimrc take effect after
the default file type settings. When you use ':setf', it
intentionally will not override the existing file type if one has
already been detected.
Use ':help new-filetype' to see the various ways you can interact with
and/or override the default filetype detection.
bob
next prev parent reply other threads:[~2008-09-25 14:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 15:22 [PATCH] vim syntax: highlight the diff in commit message template SZEDER Gábor
2008-09-24 15:57 ` Jeff King
2008-09-24 17:01 ` SZEDER Gábor
2008-09-24 17:53 ` [RFC/PATCH] remove vim syntax highlighting in favor of upstream Jeff King
2008-09-24 18:07 ` Shawn O. Pearce
2008-09-24 18:39 ` Garry Dolley
2008-09-24 19:56 ` SZEDER Gábor
2008-09-24 19:59 ` Jeff King
2008-09-25 12:48 ` SZEDER Gábor
2008-09-25 14:00 ` Bob Hiestand [this message]
2008-09-29 14:55 ` Shawn O. Pearce
2008-09-29 20:08 ` [PATCH] " SZEDER Gábor
2008-09-29 20:12 ` Jeff King
2008-09-30 8:29 ` Michael J Gruber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc29171c0809250700s3efa7601pbdb96d1bd94ab89b@mail.gmail.com \
--to=bob.hiestand@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=spearce@spearce.org \
--cc=szeder@ira.uka.de \
--cc=vim@tpope.info \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).