yatex

diff yahtml.el @ 475:d6952c7e35cc

Add-in completion for "meta" element now supports charset attribute.
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 10 Sep 2017 16:30:41 +0859
parents 4f8551386af2
children 31864e5830fe
line diff
     1.1 --- a/yahtml.el	Mon Jul 24 11:08:34 2017 +0859
     1.2 +++ b/yahtml.el	Sun Sep 10 16:30:41 2017 +0859
     1.3 @@ -1,6 +1,6 @@
     1.4  ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*-
     1.5  ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji(@)yatex.org]
     1.6 -;;; Last modified Mon Jul 24 11:03:07 2017 on firestorm
     1.7 +;;; Last modified Sun Sep 10 15:57:47 2017 on firestorm
     1.8  ;;; $Id$
     1.9  
    1.10  (defconst yahtml-revision-number "1.79.3"
    1.11 @@ -1174,7 +1174,9 @@
    1.12      ("rel" . yahtml-link-types-alist)
    1.13      ("type" . yahtml-content-types-alist)
    1.14      ("codetype" . yahtml-content-types-alist)
    1.15 -    ("http-equiv" ("Refresh"))))
    1.16 +    ("http-equiv" ("Refresh") ("Content-Language") ("Content-Type"))
    1.17 +    ("charset"
    1.18 +     ("utf-8")("euc-jp")("iso-2022-jp")("iso-8859-1")("shift_jis"))))
    1.19  
    1.20  (defvar yahtml-link-types-alist 
    1.21    '(("alternate") ("stylesheet") ("start") ("next") ("prev")
    1.22 @@ -1620,27 +1622,29 @@
    1.23  	(read-from-minibuffer-with-history
    1.24  	 "href: " "" yahtml-url-completion-map)))))))
    1.25  
    1.26 -(defvar yahtml:meta-names
    1.27 -  '(("name" ("keywords")("author")("copyright")("date")("GENERATOR"))))
    1.28 +(defvar yahtml:meta-attrs
    1.29 +  '(("charset" value)
    1.30 +    ("name" content ("keywords")("author")("copyright")("date")("GENERATOR"))
    1.31 +    ("http-equiv" content)))
    1.32  
    1.33  (defun yahtml:meta ()
    1.34 -  (let ((name (yahtml-make-optional-argument
    1.35 -	       "name"
    1.36 -	       (yahtml-read-parameter "name" nil yahtml:meta-names)))
    1.37 -	http-equiv content)
    1.38 -    (if (string= "" name)
    1.39 -	(if (string-match
    1.40 -	     "Content-type"
    1.41 -	     (setq http-equiv (yahtml-make-optional-argument
    1.42 -			       "http-equiv"
    1.43 -			       (yahtml-read-parameter "http-equiv" nil))))
    1.44 -	    (error "It's very bad idea to set Content-type in META.  %s"
    1.45 -		     "See docs/qanda")
    1.46 -	  (concat http-equiv
    1.47 -		  (yahtml-make-optional-argument
    1.48 -		   "content" (yahtml-read-parameter "content"))))
    1.49 +  (let ((attr (completing-read-with-history
    1.50 +	       "Meta Attribute: " yahtml:meta-attrs))
    1.51 +	(case-fold-search t)
    1.52 +	(completion-ignore-case t)
    1.53 +	todonext name http-equiv content)
    1.54 +    (cond
    1.55 +     ((string= "" attr) nil)
    1.56 +     ((and (setq todonext (cdr-safe (assoc attr yahtml:meta-attrs)))
    1.57 +	   (eq 'value (car todonext)))
    1.58 +      (yahtml-make-optional-argument attr (yahtml-read-parameter attr)))
    1.59 +     ((eq 'content (car todonext))
    1.60 +      (setq name (if (cdr todonext)
    1.61 +		     (completing-read-with-history
    1.62 +		      (format "%s: " attr) (cdr todonext))
    1.63 +		   (yahtml-read-parameter attr)))
    1.64        (concat
    1.65 -       name
    1.66 +       (yahtml-make-optional-argument attr name)
    1.67         (yahtml-make-optional-argument
    1.68  	"content"
    1.69  	(cond
    1.70 @@ -1657,7 +1661,14 @@
    1.71  	  (if (string-match "yahtml" content)
    1.72  	      (message "Thank you!"))
    1.73  	  content)
    1.74 -	 (t (read-string-with-history (concat name ": ")))))))))
    1.75 +	 ((string-match "content-type" name)
    1.76 +	  (if (string-match "http-equiv" attr )
    1.77 +	      (error "Use <meta charset=\"...\" instead..  See docs/qanda.")
    1.78 +	    (yahtml-make-optional-argument
    1.79 +	     "content" (yahtml-read-parameter "content"))))
    1.80 +	 (t (read-string-with-history (concat name ": ")))))))
    1.81 +     (t (yahtml-make-optional-argument
    1.82 +	 attr (yahtml-read-parameter attr))))))
    1.83  
    1.84  (defun yahtml:br ()
    1.85    (yahtml-make-optional-argument "clear" (yahtml-read-parameter "clear")))