<commit_before>! Copyright (C) 2005, 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: parser lexer kernel namespaces sequences definitions
io.files summary continuations tools.crossref tools.vocabs io
prettyprint source-files assocs vocabs vocabs.loader io.backend
splitting accessors ;
IN: editors

TUPLE: no-edit-hook ;

M: no-edit-hook summary
    drop "You must load one of the below vocabularies before using editor integration:" ;

SYMBOL: edit-hook

: available-editors ( -- seq )
    "editors" all-child-vocabs-seq [ vocab-name ] map ;

: editor-restarts ( -- alist )
    available-editors
    [ [ "Load " prepend ] keep ] { } map>assoc ;

: no-edit-hook ( -- )
    \ no-edit-hook new
    editor-restarts throw-restarts
    require ;

: edit-location ( file line -- )
    >r (normalize-path) r>
    edit-hook get [ call ] [ no-edit-hook edit-location ] if* ;

: edit ( defspec -- )
    where [ first2 edit-location ] when* ;

: edit-vocab ( name -- )
    vocab-source-path 1 edit-location ;
<commit_msg>Consistent edit-hook variable access<commit_after>! Copyright (C) 2005, 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: parser lexer kernel namespaces sequences definitions
io.files summary continuations tools.crossref tools.vocabs io
prettyprint source-files assocs vocabs vocabs.loader io.backend
splitting accessors ;
IN: editors

TUPLE: no-edit-hook ;

M: no-edit-hook summary
    drop "You must load one of the below vocabularies before using editor integration:" ;

SYMBOL: edit-hook

: available-editors ( -- seq )
    "editors" all-child-vocabs-seq [ vocab-name ] map ;

: editor-restarts ( -- alist )
    available-editors
    [ [ "Load " prepend ] keep ] { } map>assoc ;

: no-edit-hook ( -- )
    \ no-edit-hook new
    editor-restarts throw-restarts
    require ;

: edit-location ( file line -- )
    >r (normalize-path) r>
    edit-hook get-global
    [ call ] [ no-edit-hook edit-location ] if* ;

: edit ( defspec -- )
    where [ first2 edit-location ] when* ;

: edit-vocab ( name -- )
    vocab-source-path 1 edit-location ;

{'fraction_non_alphanumeric': 0.12026515151515152, 'fraction_numerical': 0.00946969696969697, 'mean_word_length': 3.0791505791505793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2333439', 'n_tokens_mistral': 723, 'n_tokens_neox': 692, 'n_words': 195}