From dd57fe7a2310c58ce10ea8e53916dc0b9d593580 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 12 Feb 2009 02:19:31 -0600 Subject: [PATCH] editors: better error message if definition does not have an associated source file when editing a word-link, go to the word itself if the word has no help --- basis/editors/editors.factor | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor index 53887bd353..d060a3dfe6 100644 --- a/basis/editors/editors.factor +++ b/basis/editors/editors.factor @@ -1,9 +1,10 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: parser lexer kernel namespaces sequences definitions io.files io.backend io.pathnames io summary continuations tools.crossref tools.vocabs prettyprint source-files assocs -vocabs vocabs.loader splitting accessors ; +vocabs vocabs.loader splitting accessors debugger prettyprint +help.topics ; IN: editors TUPLE: no-edit-hook ; @@ -29,11 +30,21 @@ SYMBOL: edit-hook [ (normalize-path) ] dip edit-hook get-global [ call ] [ no-edit-hook edit-location ] if* ; +ERROR: cannot-find-source definition ; + +M: cannot-find-source error. + "Cannot find source for ``" write + definition>> pprint-short + "''" print ; + : edit ( defspec -- ) - where [ first2 edit-location ] when* ; + dup where + [ first2 edit-location ] + [ dup word-link? [ name>> edit ] [ cannot-find-source ] if ] + ?if ; : edit-vocab ( name -- ) - vocab-source-path 1 edit-location ; + >vocab-link edit ; GENERIC: error-file ( error -- file )