yatex
diff yahtml.el @ 623:6a0fea36298f
Code cleaning for Emacs31
| author | HIROSE Yuuji <yuuji@gentei.org> |
|---|---|
| date | Sat, 01 Aug 2026 13:51:09 +0900 |
| parents | b00018b5a0b4 |
| children | f294195d0d3f |
line diff
1.1 --- a/yahtml.el Mon Feb 24 19:34:26 2025 +0900 1.2 +++ b/yahtml.el Sat Aug 01 13:51:09 2026 +0900 1.3 @@ -1,5 +1,5 @@ 1.4 -;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- 1.5 -;;; (c) 1994-2025 by HIROSE Yuuji [yuuji(@)yatex.org] 1.6 +;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis; lexical-binding: nil -*- 1.7 +;;; (c) 1994-2026 by HIROSE Yuuji [yuuji(@)yatex.org] 1.8 ;;; $Id$ 1.9 1.10 (defconst yahtml-revision-number "1.84" 1.11 @@ -202,8 +202,8 @@ 1.12 (defvar yahtml-path-url-alist nil 1.13 "*Alist of unix path name vs. URL name of WWW server. 1.14 Ex. 1.15 -'((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") 1.16 - (\"/home/yuuji/http\" . \"http://www.gentei.org/~yuuji\"))") 1.17 +((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") 1.18 + (\"/home/yuuji/http\" . \"http://www.gentei.org/~yuuji\"))") 1.19 (defvar yahtml-directory-index "index.html" 1.20 "*Directory index file name; 1.21 Consult your site's WWW administrator.") 1.22 @@ -263,7 +263,7 @@ 1.23 "*Non-nil for translate hyphens to - when comment-region") 1.24 (defvar yahtml-escape-chars 'ask 1.25 "*Escape reserved characters to URL-encoding or not. 1.26 -Nil for never, t for everytime, and 'ask for inquiring 1.27 +Nil for never, t for everytime, and `ask' for inquiring 1.28 at each reserved chars.") 1.29 1.30 (defvar yahtml-use-font-lock (and (featurep 'font-lock) 1.31 @@ -297,6 +297,8 @@ 1.32 (or (and (boundp 'shell-command-option) shell-command-option) 1.33 (if (eq system-type 'ms-dos) "/c" "-c"))) 1.34 (defvar yahtml-use-highlighting (or yahtml-use-font-lock yahtml-use-hilit19)) 1.35 +(defvar yahtml-current-file-name nil) 1.36 +(defvar yahtml-css-class-alist nil "Alist of elements vs. their classes") 1.37 1.38 (defun yahtml-define-begend-key-normal (key env &optional map func) 1.39 "Define short cut yahtml-insert-begend key." 1.40 @@ -307,10 +309,11 @@ 1.41 (list func 'arg env)) 1.42 map))) 1.43 1.44 -(defun yahtml-define-begend-region-key (key env &optional map) 1.45 +(defun yahtml-define-begend-region-key (key env &optional map func) 1.46 "Define short cut yahtml-insert-begend-region key." 1.47 (YaTeX-define-key key (list 'lambda nil '(interactive) 1.48 - (list 'yahtml-insert-begend t env)) map)) 1.49 + (list (or func 'yahtml-insert-begend) 1.50 + t env)) map)) 1.51 1.52 (defun yahtml-define-begend-key (key env &optional map) 1.53 "Define short cut key for begin type completion. 1.54 @@ -328,7 +331,7 @@ 1.55 (yahtml-define-begend-key-normal key tag map 'yahtml-insert-tag) 1.56 (if YaTeX-inhibit-prefix-letter nil 1.57 (yahtml-define-begend-region-key 1.58 - (concat (upcase (substring key 0 1)) (substring key 1)) env map 1.59 + (concat (upcase (substring key 0 1)) (substring key 1)) tag map 1.60 'yahtml-insert-tag))) 1.61 1.62 (if yahtml-mode-map nil 1.63 @@ -602,8 +605,7 @@ 1.64 (setq charset 1)) 1.65 ((string-match "utf-8" charset) 1.66 (setq charset 4)) 1.67 - (t (setq charset nil))) 1.68 - (setq dir ""))) 1.69 + (t (setq charset nil))))) 1.70 (if (featurep 'mule) 1.71 (setq charset (cdr (assq charset YaTeX-kanji-code-alist)))) 1.72 charset)) 1.73 @@ -651,7 +653,7 @@ 1.74 (setq kanji-fileio-code coding)))) 1.75 (setq major-mode 'yahtml-mode 1.76 mode-name "yahtml" 1.77 - YaTeX-current-file-name (file-name-nondirectory 1.78 + yahtml-current-file-name (file-name-nondirectory 1.79 (or (buffer-file-name) "")) 1.80 local-abbrev-table yahtml-mode-abbrev-table) 1.81 (mapcar 1.82 @@ -755,6 +757,7 @@ 1.83 (defvar yahtml-menu-map-listing nil "Menu map of yahtml(listing)") 1.84 (defvar yahtml-menu-map-logical nil "Menu map of yahtml(logical tags)") 1.85 (defvar yahtml-menu-map-typeface nil "Menu map of yahtml(typeface tags)") 1.86 +(defvar yahtml-menu-map-item nil) 1.87 1.88 ;;; Variables for mosaic url history 1.89 (defvar yahtml-urls nil "Alist of global history") 1.90 @@ -1359,7 +1362,7 @@ 1.91 1.92 (defun yahtml-get-image-info (file) 1.93 "Return the information on the image file FILE. 1.94 -Returns list of '(WIDTH HEIGHT BYTES DEPTH COMMENTLIST)." 1.95 +Returns list of `(WIDTH HEIGHT BYTES DEPTH COMMENTLIST)'." 1.96 (save-excursion 1.97 (let*((tmpbuf (get-buffer-create " *imgheader*")) 1.98 width height bytes depth comment 1.99 @@ -1826,6 +1829,16 @@ 1.100 (if (or yahtml-always-/p arg) (yahtml-insert-tag arg "p") 1.101 (yahtml-insert-single "p"))) 1.102 1.103 +;;; ---------- translate to entity references ---------- 1.104 +(defvar yahtml-entity-reference-chars-alist-default 1.105 + ;'((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot") (?' . "apos")) 1.106 + '((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot")) 1.107 + "Default translation table from character to entity reference") 1.108 +(defvar yahtml-entity-reference-chars-alist nil 1.109 + "*Translation table from character to entity reference") 1.110 +(defvar yahtml-entity-reference-chars-regexp nil) 1.111 +(defvar yahtml-entity-reference-chars-reverse-regexp nil) 1.112 + 1.113 (defun yahtml-insert-amps (arg) 1.114 "Insert char-entity references via ampersand" 1.115 ;; Thanks; http://www.tsc.co.jp/~asada/html/wdg40_f/entities/ 1.116 @@ -1835,9 +1848,9 @@ 1.117 yahtml-entity-reference-chars-alist)) 1.118 (l list)) 1.119 (while l 1.120 - (setq mess (format "%s %c" mess (car (car l)) (cdr (car l))) 1.121 + (setq mess (format "%s %c=%s" mess (car (car l)) (cdr (car l))) 1.122 l (cdr l))) 1.123 - (message "Char-entity reference: %s SPC=& RET=&; BS=%s Other=&#..;" 1.124 + (message "Char-entity: %s RET=&; BS=%s Other=&#..;" 1.125 mess (if YaTeX-japan "直前の文字" "Preceding-Char")) 1.126 (setq c (read-char)) 1.127 (cond 1.128 @@ -1850,7 +1863,7 @@ 1.129 (insert ?&)) 1.130 ((and (memq c '(127 8)) 1.131 (setq c (preceding-char)) 1.132 - (delete-backward-char 1) 1.133 + (delete-char -1) 1.134 nil)) ;Fall through to the next 't block 1.135 (t (insert (format "&#x%x;" c)))))) 1.136 1.137 @@ -2022,7 +2035,8 @@ 1.138 t))))) 1.139 1.140 (defun yahtml-jump-to-name (name) 1.141 - "Jump to html's named tag." 1.142 + "Jump to html's named tag. 1.143 +Using dynamic variable in yahtml-goto-corresponding-href()." 1.144 (setq name (format "\\(name\\|id\\)\\s *=\\s *\"?%s\\>\"?" name)) 1.145 (or (and (re-search-forward name nil t) (goto-char (match-beginning 0))) 1.146 (and (re-search-backward name nil t) (goto-char (match-beginning 0))) 1.147 @@ -2386,7 +2400,6 @@ 1.148 ((yahtml-change-command)))) 1.149 1.150 ;;; ---------- commenting ---------- 1.151 - 1.152 (defun yahtml-comment-region (&optional uncom) 1.153 "Comment out region or environment." 1.154 (interactive) 1.155 @@ -2427,15 +2440,6 @@ 1.156 (interactive) 1.157 (yahtml-comment-region t)) 1.158 1.159 -;;; ---------- translate to entity references ---------- 1.160 -(defvar yahtml-entity-reference-chars-alist-default 1.161 - ;'((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot") (?' . "apos")) 1.162 - '((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot")) 1.163 - "Default translation table from character to entity reference") 1.164 -(defvar yahtml-entity-reference-chars-alist nil 1.165 - "*Translation table from character to entity reference") 1.166 -(defvar yahtml-entity-reference-chars-regexp nil) 1.167 -(defvar yahtml-entity-reference-chars-reverse-regexp nil) 1.168 1.169 (defun yahtml-entity-reference-chars-setup () 1.170 (let ((list (append yahtml-entity-reference-chars-alist-default 1.171 @@ -2510,7 +2514,8 @@ 1.172 (cond 1.173 ((string-match revrex right) 1.174 (setq ch (YaTeX-rassoc 1.175 - (substring right (match-beginning 1) (match-end 1))) 1.176 + (substring right (match-beginning 1) (match-end 1)) 1.177 + ct) 1.178 b0 (substring right 0 (match-beginning 0)) 1.179 right (substring right (match-end 0)) 1.180 left (concat left 1.181 @@ -2755,7 +2760,7 @@ 1.182 (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\|option\\)\\b") 1.183 (excludes 1.184 "\\b\\(a\\|p\\|span\\|code\\|tt\\|em\\|u\\|i\\|big\\|small\\|font\\)\\b") 1.185 - inenv p col peol (case-fold-search t)) 1.186 + inenv p col peol op (case-fold-search t)) 1.187 (save-excursion 1.188 (beginning-of-line) 1.189 (setq inenv (or (yahtml-inner-environment-but excludes t) 1.190 @@ -2869,8 +2874,8 @@ 1.191 1.192 (defun yahtml-lint-buffer (buf) 1.193 "Call lint on buffer BUF." 1.194 + (interactive "bCall lint on buffer: ") 1.195 (require 'yatexprc) 1.196 - (interactive "bCall lint on buffer: ") 1.197 (setq buf (get-buffer buf)) 1.198 (YaTeX-save-buffers) 1.199 (let ((bcmd (YaTeX-get-builtin "lint"))) 1.200 @@ -3179,7 +3184,7 @@ 1.201 (end-of-line) 1.202 (if (re-search-backward yahtml-error-line-regexp nil t) 1.203 (let ((f (if (string= "" (YaTeX-match-string 1)) 1.204 - YaTeX-current-file-name 1.205 + yahtml-current-file-name 1.206 (YaTeX-match-string 1))) 1.207 (l (YaTeX-str2int (or (YaTeX-match-string 2) 1.208 (YaTeX-match-string 3))))) 1.209 @@ -3190,9 +3195,6 @@ 1.210 (message "No line number usage")))) 1.211 1.212 ;;; ---------- Style Sheet Support ---------- 1.213 -(defvar yahtml-css-class-alist nil 1.214 - "Alist of elements vs. their classes") 1.215 - 1.216 (defun yahtml-css-collect-classes-region (beg end &optional initial) 1.217 (save-excursion 1.218 (save-restriction
