notes@enea.UUCP (12/14/83)
#N:enea:3700001:000:1531
enea!sten Dec 5 23:10:00 1983
Have you ever missed environment substitution when typing file names? Well,
include this function in your .emacs_pro and you have it!
-----------------------------------------------------------------------------
; "Sten Folkerman enea!sten"
;
; Modify file referencing functions in the means of simulating environment
; substitution.
(defun
(envsub-foo out in q1 q2
(setq out "")
(setq in (arg 1 "YesDear??"))
(setq q1 0)
(while (<= (setq q1 (+ q1 1)) (length in))
(setq q2 (substr in q1 1))
(if (= q2 "$")
(progn q3 env
(setq env "")
(setq q3 1)
(while (& (<= (setq q1 (+ q1 1)) (length in)) q3)
(setq q2 (substr in q1 1))
(if
(if (& (>= q2 "a") (<= q2 "z"))
1
(if (& (>= q2 "A") (<= q2 "Z"))
1
(if (& (>= q2 "0") (<= q2 "9"))
1
(if (= q2 "_")
1
0
)
)
)
)
(setq env (concat env q2))
(progn
(setq q3 0)
(setq q1 (- q1 2))
)
)
)
(setq q2 (getenv env))
)
)
(setq out (concat out q2))
)
out
)
(envsub-bar
(execute-mlisp-line
(concat
"(defun "
"(" (arg 1) "-env"
"(" (arg 1) "(envsub-foo (arg 1 """ (arg 3) """)))"
")"
")"
)
)
(remove-binding (arg 2))
(bind-to-key (concat (arg 1) "-env") (arg 2))
)
)
(envsub-bar "insert-file" "\^x\^i" "Insert file: ")
(envsub-bar "read-file" "\^x\^r" "Read file: ")
(envsub-bar "visit-file" "\^x\^v" "Visit file: ")
(envsub-bar "write-named-file" "\^x\^w" "Write file: ")