--- a/MIMETypes.st Thu Aug 02 11:58:56 2001 +0200
+++ b/MIMETypes.st Fri Aug 03 16:52:26 2001 +0200
@@ -260,12 +260,55 @@
"
!
+commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
+ "return a useful comment definition; heuristics for now.
+ The returned value is an array of 2 elements;
+ the first is the end-of-line comment string (or nil);
+ the second an array of opening/closing delimiters (or an array of nils)"
+
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:aFilename.
+ ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
+
+ "
+ MIMETypes commentStringsForFilename:'Makefile'.
+ MIMETypes commentStringsForFilename:'Object.st'.
+ MIMETypes commentStringsForFilename:'Foo.java'.
+ "
+!
+
commentStringsForMimeType:mime suffix:suff
"return a useful comment definition; heuristics for now.
The returned value is an array of 2 elements;
the first is the end-of-line comment string (or nil);
the second an array of opening/closing delimiters (or an array of nils)"
+ ^ self
+ commentStringsForMimeType:mime suffix:suff
+ ifUnknown: #(';' (nil nil))
+
+ "
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:'Makefile'.
+ MIMETypes commentStringsForMimeType:mime suffix:nil.
+ "
+
+ "
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:'Object.st'.
+ MIMETypes commentStringsForMimeType:mime suffix:nil.
+ "
+!
+
+commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
+ "return a useful comment definition; heuristics for now.
+ The returned value is an array of 2 elements;
+ the first is the end-of-line comment string (or nil);
+ the second an array of opening/closing delimiters (or an array of nils)"
+
(mime = 'application/x-make') ifTrue:[
"/ makefile
^ #('#' (nil nil)).
@@ -309,9 +352,7 @@
^ #(';' (nil nil)).
].
- "/ default: shell comments
-
- ^ #(';' (nil nil)).
+ ^ alternativeBlockReturningCommentString value
"
|mime|
@@ -532,6 +573,6 @@
!MIMETypes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.32 2001-05-23 14:45:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.33 2001-08-03 14:52:26 tm Exp $'
! !
MIMETypes initialize!