ox icon indicating copy to clipboard operation
ox copied to clipboard

Add modeline magic for file type etc.

Open mjf opened this issue 4 years ago • 1 comments

At least for file types you should provide modeline magic:

$ cat script
#! /bin/sh

echo "Hello, world!"
exit 0

# ox: ft=sh

Not everyone likes to add file extension to determine the file type! Therefor modeline magic can help to force it. Also the #! ... shebang can be split to get the interpreter name (i.e. sh). You can also add some sort of aliases for it. For example (for syntax etc. for some "shell" and "c"):

(
    filetypes: {
        "shell": {
            files: [".bash*", ".profile"],
            extensions: [".sh", ".bash", ".dash", ".sh.inc"],
            interpreters: ["sh", "bash", "dash"],
            modeline: {
                keywords: ["filetype", "ft"],
                values: ["shell", "sh"],
            },
        },
        "c": {
            files: ["~/dev/c/**"],
            extensions: [".c", ".h", ".cpp"],
            interpreters: ["tcc"],
            modeline: {
                keywords: ["filetype", "ft"],
                values: ["c", "c++"],
            },
        },
    },
)

Where the files, extensions, interpreters and modeline are "or-ed" (any of them can match). Just an idea... May be related to #76.

mjf avatar Nov 18 '20 08:11 mjf

I'll look into this

curlpipe avatar Nov 18 '20 18:11 curlpipe