[vim/vim] Detect *.src/*.dat preferably from content (PR #10103)

8 views
Skip to first unread message

Patrick Meiser-Knosowski

unread,
Apr 6, 2022, 8:03:04 PM4/6/22
to vim/vim, Subscribed

KRL files are easiely recognized. Even if the user does set
g:filetype_src or g:filetype_dat he may very well profit from file
content inspection. New files will always default to g:filetype_* if
present.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/10103

Commit Summary

  • e775b9b Detect *.src/*.dat preferably from content

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10103@github.com>

Bram Moolenaar

unread,
Apr 7, 2022, 12:26:39 PM4/7/22
to vim/vim, Subscribed

The global variables are intended to overrule the automatic detection, not as a fallback.
See :help filetype-overrule


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10103/c1091954943@github.com>

Patrick Meiser-Knosowski

unread,
Apr 7, 2022, 1:20:15 PM4/7/22
to vim/vim, Subscribed

Sorry, I was mislead by FTr(), where it is the other way around.

export def FTr()
var max = line("$") > 50 ? 50 : line("$")

for n in range(1, max)
# Rebol is easy to recognize, check for that first
if getline(n) =~? '<REBOL>'
setf rebol
return
endif

... and so on...

# Nothing recognized, use user default or assume Rexx
if exists("g:filetype_r")
exe "setf " .. g:filetype_r
else
# Rexx used to be the default, but R appears to be much more popular.
setf r
endif

enddef


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10103/c1092001739@github.com>

Patrick Meiser-Knosowski

unread,
Apr 7, 2022, 1:20:18 PM4/7/22
to vim/vim, Subscribed

Closed #10103.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/10103/issue_event/6390416436@github.com>

Bram Moolenaar

unread,
Apr 7, 2022, 2:12:10 PM4/7/22
to vim...@googlegroups.com, Patrick Meiser-Knosowski

Patrick Meiser-Knosowski wrote:

> Sorry, I was mislead by FTr(), where it is the other way around.
>
> export def FTr()
> var max = line("$") > 50 ? 50 : line("$")
>
> for n in range(1, max)
> # Rebol is easy to recognize, check for that first
> if getline(n) =~? '\<REBOL\>'
> setf rebol
> return
> endif
>
> ... and so on...
>
> **# Nothing recognized, use user default or assume Rexx
> if exists("g:filetype_r")
> exe "setf " .. g:filetype_r
> else
> # Rexx used to be the default, but R appears to be much more popular.
> setf r
> endif**
> enddef

The R files are an exception, it is documented at :help ft-rexx-syntax
I would say this is unexpected, perhaps even wrong. But changing it now
probably causes more harm than improving the situation.


--
MICHAEL PALIN PLAYED: 1ST SOLDIER WITH A KEEN INTEREST IN BIRDS, DENNIS, MR
DUCK (A VILLAGE CARPENTER WHO IS ALMOST KEENER THAN
ANYONE ELSE TO BURN WITCHES), THREE-HEADED KNIGHT, SIR
GALAHAD, KING OF SWAMP CASTLE, BROTHER MAYNARD'S ROOMATE
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages