src/Pure/Tools/jedit.ML
changeset 61621 70b8085f51b4
parent 61620 01db1bed4487
child 63669 256fc20716f2
     1.1 --- a/src/Pure/Tools/jedit.ML	Tue Nov 10 21:52:18 2015 +0100
     1.2 +++ b/src/Pure/Tools/jedit.ML	Tue Nov 10 22:20:46 2015 +0100
     1.3 @@ -44,16 +44,27 @@
     1.4          | _ => [])
     1.5      | (_, rc) => error ("Cannot unzip jedit.jar\nreturn code = " ^ string_of_int rc)));
     1.6  
     1.7 -fun is_action a =
     1.8 -  member (op =) (Lazy.force isabelle_jedit_actions) a orelse
     1.9 -  member (op =) (Lazy.force isabelle_jedit_dockables) a orelse
    1.10 -  member (op =) (Lazy.force jedit_actions) a;
    1.11 +val all_actions =
    1.12 +  Lazy.lazy (fn () =>
    1.13 +    Lazy.force isabelle_jedit_actions @
    1.14 +    Lazy.force isabelle_jedit_dockables @
    1.15 +    Lazy.force jedit_actions);
    1.16  
    1.17  in
    1.18  
    1.19 -fun check_action (a, pos) =
    1.20 -  if is_action a then a
    1.21 -  else error ("Bad jEdit action " ^ quote a ^ Position.here pos);
    1.22 +fun check_action (name, pos) =
    1.23 +  if member (op =) (Lazy.force all_actions) name then name
    1.24 +  else
    1.25 +    let
    1.26 +      val completion =
    1.27 +        Completion.make (name, pos)
    1.28 +          (fn completed =>
    1.29 +            Lazy.force all_actions
    1.30 +            |> filter completed
    1.31 +            |> sort_strings
    1.32 +            |> map (fn a => (a, ("action", a))));
    1.33 +      val report = Markup.markup_report (Completion.reported_text completion);
    1.34 +    in error ("Bad jEdit action " ^ quote name ^ Position.here pos ^ report) end
    1.35  
    1.36  end;
    1.37