aboutsummaryrefslogtreecommitdiff
path: root/generic/proof-syntax.el
diff options
context:
space:
mode:
authorDavid Aspinall2000-03-22 12:45:35 +0000
committerDavid Aspinall2000-03-22 12:45:35 +0000
commitb1e72f62ada72021ce4c4c124ff0c54d19010847 (patch)
tree23ed0dbf65109979854f23cc71295f4db15ce580 /generic/proof-syntax.el
parent59412ffa7c58e14121aab37a55882cd5be03cd65 (diff)
Added utility functions proof-format, proof-format-filename.
Diffstat (limited to 'generic/proof-syntax.el')
-rw-r--r--generic/proof-syntax.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/generic/proof-syntax.el b/generic/proof-syntax.el
index 07591a06..798e2727 100644
--- a/generic/proof-syntax.el
+++ b/generic/proof-syntax.el
@@ -136,5 +136,32 @@ may assign this function to `after-change-function'."
(append (delq 'proof-zap-commas-region after-change-functions)
'(proof-zap-commas-region))))
+;;
+;; Functions for doing something like "format" but with customizable
+;; control characters.
+;;
+
+(defun proof-format (alist string)
+ "Format a string by matching regexps in ALIST against STRING"
+ (while alist
+ (let ((idx 0))
+ (while (string-match (car (car alist)) string idx)
+ (setq string
+ (concat (substring string 0 (match-beginning 0))
+ (cdr (car alist))
+ (substring string (match-end 0))))
+ (setq idx (+ (match-beginning 0) (length (cdr (car alist)))))))
+ (setq alist (cdr alist)))
+ string)
+
+(defun proof-format-filename (string filename)
+ "Format STRING by replacing %s or %e by expanded version of FILENAME.
+%e is special form meaning use proof-shell-string-escapes."
+ (proof-format
+ (list (cons "%s" (expand-file-name filename))
+ (cons "%e" (proof-format proof-shell-string-escapes
+ (expand-file-name filename))))
+ string))
+
(provide 'proof-syntax)