Last active
June 21, 2023 07:46
-
-
Save tani/1790309c55014cd9db184c9030040a70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) Masaya Taniguchi. | |
// This software is licensed under the Public Domain. | |
// | |
// Isabelle overrides the existing keybindings. | |
// This script prevents this behaviour with some properties. | |
// | |
// Usage | |
// $ deno run -A ./override.ts Emacs_keys.props imported_keys.props >> ../properties | |
import { readLines } from "https://deno.land/std@0.192.0/io/mod.ts" | |
const args = Deno.args | |
const afile = await Deno.open(args[0]) | |
const adict = {} as Record<string, unknown> | |
const bfile = await Deno.open(args[1]) | |
const bdict = {} as Record<string, unknown> | |
const name = 'IsabelleEmacs' | |
for await (const line of readLines(afile)) { | |
if (line.startsWith("#")) continue | |
const [key, value] = line.split("=") | |
adict[key] = value | |
} | |
for await (const line of readLines(bfile)) { | |
if (line.startsWith("#")) continue | |
const [key, value] = line.split("=") | |
bdict[key] = value | |
} | |
const ignored = {} as Record<string, bool> | |
for (const [akey, avalue] of Object.entries(adict)) { | |
for (const [bkey, bvalue] of Object.entries(bdict)) { | |
if (akey === bkey && avalue !== bvalue) { | |
ignored[akey] || console.log(`${akey}.ignore=${name}`) | |
ignored[akey] = true | |
} | |
if (akey !== bkey && avalue === bvalue) { | |
ignored[akey] || console.log(`${akey}.ignore=${name}`) | |
ignored[akey] = true | |
ignored[bkey] || console.log(`${bkey}.ignore=${name}`) | |
ignored[bkey] = true | |
} | |
} | |
} | |
for (const [akey, avalue] of Object.entries(adict)) { | |
if (! bdict[akey]) { | |
ignored[akey] || console.log(`${akey}.ignore=${name}`) | |
ignored[akey] = true | |
} | |
} | |
for (const [bkey, bvalue] of Object.entries(bdict)) { | |
if (! adict[bkey]) { | |
ignored[bkey] || console.log(`${bkey}.ignore=${name}`) | |
ignored[bkey] = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment