Tfzalias
Basicly coppied from tflib/alias.tf
changed priority and -F of send hooks to be in line with my scheme
Added to zhelp February 11, 2010 11:57:01 PM
also added /aliassave macro
NOTE: DO NOT LOAD ALIAS.TF ALSO!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Zalias.tf ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Basicly coppied from tflib/alias.tf
; changed priority and -F of send hooks to be in line with my scheme
; Added to zhelp February 11, 2010 11:57:01 PM
; also added /aliassave macro
; NOTE: DO NOT LOAD ALIAS.TF ALSO!
;;; ZAliases ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Create command aliases. Like simple macros, but no leading '/' is required.
; syntax: /alias
; syntax: /alias <name>
; syntax: /alias <name> <command...>
; syntax: /unalias <name>
; syntax: /aliassave
; syntax: /purgealias <mask>
;;; Loaded and Required ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; I leave this because this is the REPLACEMENT for alias.tf
; but add my own loaded too
;
/loaded __TFLIB__/alias.tf
/loaded z::zalias.tf
/require -q zhelp.tf
; on load this checks and warns if alias=~"old" which SHOULD NOT BE
/if ( alias =~ "old" ) \
/echo -e Note: you have alias=old, so argument substitutions will follow \
the old style, where %%1 is the alias name, %%2 is the first \
argument, etc.%;\
/endif
;;; alias ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; if /alias <name> it lists
; if /alias <name> <cmds> it sets up :
; the alias body as a macro
; the send hook for the alias that calls the alias body
;
/def -i alias = \
/if ( {#} < 2 ) \
/quote -S /~listalias `/@list -s -I -mglob ~alias_body_%{1-*}%; \
/else \
/def -i ~alias_body_%1 = %-1%;\
; The ~alias_call_* macro /shifts unless [alias=~"old"] at runtime.
/def -i -F -p950 -ag -mglob -h"send {%1}*" ~alias_call_%1 = \
/shift $$[alias !~ "old"]%%; \
/~alias_body_%1 %%*%; \
/endif
/test zhelp_add("alias","A slighty tuned version of tflib/alias.tf, Type /help alias \
for info and see zalias.tf for details. Type /zhelp alias all for info on this version.")
;;; ~listalias ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; helper macro for alias
;
/def -i ~listalias = /echo /alias $[substr({L}, 12)] ${%{L}}
;;; unalias ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; undefs an alias setup by alias
;
/def -i unalias = \
/if /ismacro ~alias_call_%1%; /then \
/undef ~alias_call_%1%; \
/undef ~alias_body_%1%; \
/else \
/echo -e - %% %0: "%1": no such alias%; \
/endif
;;; purgealias ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; removes the defs for ~alias_call and ~alias_body_
;
/def -i purgealias = \
/purge -I ~alias_call_*%; \
/purge -I ~alias_body_*
;;; aliassave ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; lists the alias through ~listalias to set up for a load, and saves them all to Zafile.tf
; these are loaded in zorbo.tfrc right after loading zalias.tf
;
/def aliassave = \
/quote -S /~listalias `/@list -s -I -mglob ~alias_body_%{1-*} %| /writefile Zafile.tf%; \
/test PPNotice(3,"Alias file written - Zafile.tf")
/test zhelp_add("alias_aliassave","Saves all the aliases to Zafile.tf")





