changeset 18714:5d47a06d19bf

(create-fontset-from-fontset-spec): Add optional arg NOERROR. (create-fontset-from-x-resource): Give t as arg NOERROR to create-fontset-from-fontset-spec.
author Kenichi Handa <handa@m17n.org>
date Thu, 10 Jul 1997 06:46:42 +0000
parents bca5a6b78f91
children d37ea94a4bb1
files lisp/international/fontset.el
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/fontset.el	Thu Jul 10 06:46:42 1997 +0000
+++ b/lisp/international/fontset.el	Thu Jul 10 06:46:42 1997 +0000
@@ -324,14 +324,16 @@
 	    name))
       fontset)))
 
-(defun create-fontset-from-fontset-spec (fontset-spec &optional style)
+(defun create-fontset-from-fontset-spec (fontset-spec &optional style noerror)
   "Create a fontset from fontset specification string FONTSET-SPEC.
 FONTSET-SPEC is a string of the format:
 	FONTSET-NAME,CHARSET-NAME0:FONT-NAME0,CHARSET-NAME1:FONT-NAME1, ...
 Any number of SPACE, TAB, and NEWLINE can be put before and after commas.
 If optional argument STYLE is specified, create a fontset of STYLE
 by modifying FONTSET-SPEC appropriately.  STYLE can be one of `bold',
-`italic', and `bold-italic'."
+`italic', and `bold-italic'.
+If this function attemps to create already existing fontset, error is
+signaled unlress the optional 3rd argument NOERROR is non-nil."
   (if (not (string-match "^[^,]+" fontset-spec))
       (error "Invalid fontset spec: %s" fontset-spec))
   (let ((idx (match-end 0))
@@ -367,16 +369,18 @@
 	  (setq fontlist
 		(x-complement-fontset-spec xlfd-fields fontlist))))
 
-    ;; Create the fontset, and define the alias if appropriate.
-    (new-fontset name fontlist)
-    (if (and (not style)
-	     (not (assoc name fontset-alias-alist))
-	     (string-match "fontset-.*$" name))
-	(let ((alias (match-string 0 name)))
-	  (or (rassoc alias fontset-alias-alist)
-	      (setq fontset-alias-alist
-		    (cons (cons name alias) fontset-alias-alist)))))
-    ))
+    (if (and noerror (query-fontset name))
+	;; Don't try to create an already existing fontset.
+	nil
+      ;; Create the fontset, and define the alias if appropriate.
+      (new-fontset name fontlist)
+      (if (and (not style)
+	       (not (assoc name fontset-alias-alist))
+	       (string-match "fontset-.*$" name))
+	  (let ((alias (match-string 0 name)))
+	    (or (rassoc alias fontset-alias-alist)
+		(setq fontset-alias-alist
+		      (cons (cons name alias) fontset-alias-alist))))))))
 
 
 ;; Create standard fontset from 16 dots fonts which are the most widely
@@ -409,7 +413,7 @@
 	fontset-spec)
     (while (setq fontset-spec (x-get-resource (concat "fontset-" idx)
 					      (concat "Fontset-" idx)))
-      (create-fontset-from-fontset-spec fontset-spec)
+      (create-fontset-from-fontset-spec fontset-spec nil 'noerror)
       (setq idx (1+ idx)))))
 
 (defsubst fontset-list ()