Sunday, October 9, 2022

Re: Prolog filetype problem

On my system (Ubuntu MATE 20.04) there is no default file /etc/magic (per the man for "file").

My local definitions were placed in that file which are interpreted before other system definitions.

The content of my "/etc/magic" file is as follows:

# Magic local data for file(1) command.
# Insert here your local magic data. Format is described in magic(5).
0    string    %%Prolog    Prolog Predicate File (Non-Specific)

0    string    %%gprolog    Prolog Predicate File (GNU Prolog)

0    string    %%swipl        Prolog Predicate File (SWI-Prolog)

0    string    %%yap        Prolog Predicate File (YAP Prolog)

0    string    %%eclipse    Prolog Predicate File (ECLiPSe)

0    string    %%bprolog    Prolog Predicate File (B-Prolog)

0    string    %%poplog    Prolog Predicate File (Poplog)

0    string    %%lpaprolog    Prolog Predicate File (LPA Prolog)

0    string    %%isoprolog    Prolog Predicate File (ISO-Compliant Prolog)

0    string    [Pp][Rr][Oo][Ll][Oo][Gg]    Prolog Predicate File (ISO-Compliant Prolog)

0    search    :-    Prolog Predicate File (Non-Specific :-)

0    search    -->    Prolog Predicate File (Non-Specific -->)
#
#0    search/2048    [Pp][Rr][Oo][Ll][Oo][Gg]    Prolog Predicate File (ISO-Compliant Prolog)
#
#0    string    %     Prolog Predicate File (Non-Specific %)
#
#

As can be seen, I was attempting to specify definitions which would identify the various dialects of Prolog and have "file" report those.  Works splendidly for me!
On Monday, 1 October 2012 at 11:20:20 UTC-4 Gautier DI FOLCO wrote:
2012/9/30 Ben Fritz <fritzo...@gmail.com>

It looks like Vim will automatically detect prolog rather than Perl if the first non-blank line contains any of:

1. the word "prolog"
2. a prolog comment, % or /* ... */
3. the prolog :- construct

Otherwise, Vim detects Perl. So for existing files, just get into the habit of starting the file with a header comment and you'll be fine.

I guess new files will always detect as Perl, but there's really not any way I can think of for Vim to detect in a general way what filetype a brand-new empty file should be. You could set up some BufNewFile autocmds based on project directory or something if you like for this.

Clever, thank you.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8e314f69-0d62-471c-88a2-c9a0c255e292n%40googlegroups.com.

No comments:

Post a Comment