improved macro syntax

This commit is contained in:
Burkhart Wolff 2020-12-22 20:37:15 +01:00
parent 5593c22a36
commit 6899c4059e
4 changed files with 18 additions and 11 deletions

View File

@ -26,7 +26,7 @@ define_shortcut* isadof \<rightleftharpoons> \<open>\isadof\<close>
Protege \<rightleftharpoons> \<open>Prot{\'e}g{\'e}\<close>
(* slanted text in contrast to italics *)
define_macro* slanted_text \<rightleftharpoons> \<open>\textsl{\<close> \<open>}\<close>
define_macro* slanted_text \<rightleftharpoons> \<open>\textsl{\<close> _ \<open>}\<close>
(*>*)

View File

@ -33,8 +33,8 @@ define_shortcut* TeXLive \<rightleftharpoons> \<open>\TeXLive\<close>
text\<open>Note that these setups assume that the associated \<^LaTeX> macros
are defined, \<^eg>, in the document prelude. \<close>
define_macro* index \<rightleftharpoons> \<open>\index{\<close> \<open>}\<close>
define_macro* bindex \<rightleftharpoons> \<open>\bindex{\<close> \<open>}\<close>
define_macro* index \<rightleftharpoons> \<open>\index{\<close> _ \<open>}\<close>
define_macro* bindex \<rightleftharpoons> \<open>\bindex{\<close> _ \<open>}\<close>
ML\<open>

View File

@ -429,15 +429,21 @@ ML\<open>
val parse_literal = Parse.alt_string || Parse.cartouche
val parse_define_shortcut = (Parse.binding
-- ((\<^keyword>\<open>\<rightleftharpoons>\<close> || \<^keyword>\<open>==\<close>) |-- parse_literal))
--|Parse.underscore
-- parse_literal
-- (Scan.option (\<^keyword>\<open>(\<close> |-- Parse.ML_source --|\<^keyword>\<open>)\<close>))
fun define_macro (X,NONE) = (uncurry(uncurry(uncurry DOF_lib.define_macro)))(X,K(K()));
fun define_macro (X,NONE) = (uncurry(uncurry(uncurry DOF_lib.define_macro)))(X,K(K()))
|define_macro (X,SOME(src:Input.source)) =
let val _ = ()
in
(uncurry(uncurry(uncurry DOF_lib.define_macro)))(X,K(K()))
end;
val _ = Outer_Syntax.command \<^command_keyword>\<open>define_macro*\<close> "define LaTeX shortcut"
(Scan.repeat1 parse_define_shortcut >> (Toplevel.theory o (fold define_macro)));
Parse.underscore;
\<close>

View File

@ -481,13 +481,14 @@ define_shortcut* eg \<rightleftharpoons> \<open>\eg\<close> (* Latin: „exemp
subsection\<open>Layout Trimming Commands\<close>
define_macro* hs \<rightleftharpoons> \<open>\hspace{\<close> \<open>}\<close>
define_macro* vs \<rightleftharpoons> \<open>\vspace{\<close> \<open>}\<close>
define_macro* hs \<rightleftharpoons> \<open>\hspace{\<close> _ \<open>}\<close>
define_macro* vs \<rightleftharpoons> \<open>\vspace{\<close> _ \<open>}\<close>
(* setup\<open> DOF_lib.define_macro \<^binding>\<open>hs\<close> "\\hspace{" "}" (K(K())) \<close> *)
ML\<open> Parse.real \<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>vs2\<close> "\\vspace{" "}" (fn ctxt => fn src => ()) \<close>
(*
setup\<open> DOF_lib.define_macro \<^binding>\<open>hs\<close> "\\hspace{" "}" (K(K())) \<close>
setup\<open> DOF_lib.define_macro \<^binding>\<open>vs\<close> "\\vspace{" "}" (K(K())) \<close>
*)
define_shortcut* clearpage \<rightleftharpoons> \<open>\clearpage{}\<close>