Blog: 2024-03-31

From razwiki
Revision as of 11:05, 31 March 2024 by Razzi (talk | contribs) (Created page with "Sigh... haven't got this vim help menu thing working, but it's maybe a good idea, to the extent that vim customization ideas can be good ideas. <pre> .vim $ cat ftplugin/help.vim set timeout timeoutlen=200 nnoremap <silent> <buffer> q :q<cr> </pre> Fan of this https://www.villagevoice.com/a-chat-with-das-racist-the-geniuses-behind-combination-pizza-hut-and-taco-bell/ Continuing with my little python scheme wrapper. It hangs when you hit enter, I guess the scheme subpr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sigh... haven't got this vim help menu thing working, but it's maybe a good idea, to the extent that vim customization ideas can be good ideas.

.vim $ cat ftplugin/help.vim
set timeout timeoutlen=200
nnoremap <silent> <buffer> q :q<cr>

Fan of this https://www.villagevoice.com/a-chat-with-das-racist-the-geniuses-behind-combination-pizza-hut-and-taco-bell/

Continuing with my little python scheme wrapper. It hangs when you hit enter, I guess the scheme subprocess can't handle it

from subprocess import Popen, PIPE
from pexpect.replwrap import REPLWrapper


def safe_input(prompt):
    try:
        return input(prompt)
    except EOFError:
        return None

def main():
    scheme = REPLWrapper('scheme', 'ts> ', prompt_change=None)

    line = ''
    prompt = '> '

    while True:
        expression = safe_input(prompt)
        if expression is None:
            return

        print('expression is: ' + repr(expression))
        line += ' ' + expression

        if line.count('(') == line.count(')'):
            print('EQ line is: ' + repr(line))

            result = scheme.run_command(line)

            print('so result is is: ' + result)
            print(f'\x1B[3m{result}\x1B[0m')

            line = ''
            prompt = '> '
        else:
            print('line is: ' + line)
            prompt = ' '

main()