yatex
changeset 437:27f00e6e0150 dev
yahtml:datalist can complete id in a buffer
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 16 Jul 2016 13:33:36 +0859 |
parents | e78a87bc2c9e |
children | 1b9beabd3fd1 |
files | yahtml.el |
diffstat | 1 files changed, 36 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/yahtml.el Fri Jan 08 08:18:54 2016 +0859 1.2 +++ b/yahtml.el Sat Jul 16 13:33:36 2016 +0859 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- 1.5 ;;; (c) 1994-2015 by HIROSE Yuuji [yuuji(@)yatex.org] 1.6 -;;; Last modified Tue Jan 5 10:17:40 2016 on firestorm 1.7 +;;; Last modified Sat Jul 16 13:32:35 2016 on firestorm 1.8 ;;; $Id$ 1.9 1.10 (defconst yahtml-revision-number "1.78.1" 1.11 @@ -425,7 +425,7 @@ 1.12 1.13 ;;; Completion tables for `form' 1.14 (defvar yahtml-form-table 1.15 - '(("img") ("input") ("link") ("meta"))) 1.16 + '(("img") ("input") ("link") ("meta") ("label"))) 1.17 (defvar yahtml-user-form-table nil) 1.18 (defvar yahtml-tmp-form-table nil) 1.19 (defvar yahtml-last-form "img") 1.20 @@ -442,7 +442,7 @@ 1.21 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") 1.22 ;; ("p") ;This makes indentation screwed up! 1.23 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") 1.24 - ("option") 1.25 + ("option") ("datalist") 1.26 )) 1.27 1.28 (if yahtml-html4-strict 1.29 @@ -951,18 +951,20 @@ 1.30 "")))) 1.31 1.32 (defvar yahtml-completing-buffer nil) 1.33 -(defun yahtml-collect-labels (&optional file) 1.34 +(defun yahtml-collect-labels (&optional file ptn withouthash) 1.35 "Collect current buffers label (<?? name=...>). 1.36 If optional argument FILE is specified collect labels in FILE." 1.37 - (let (list end) 1.38 + (let ((attrptn (concat "\\(" (or ptn "name\\|id") "\\)\\s *=")) 1.39 + (hash (if withouthash "" "#")) 1.40 + list end) 1.41 (save-excursion 1.42 - (set-buffer yahtml-completing-buffer) 1.43 + (set-buffer (or yahtml-completing-buffer (current-buffer))) 1.44 (if file (let (hilit-auto-highlight) 1.45 (set-buffer (find-file-noselect file)))) 1.46 (save-excursion 1.47 (goto-char (point-min)) 1.48 (while ;(re-search-forward "<\\w+\\b" nil t) 1.49 - (re-search-forward "\\(name\\|id\\)\\s *=" nil t) 1.50 + (re-search-forward attrptn nil t) 1.51 ;(setq bound (match-end 0)) 1.52 ;(search-forward ">" nil t) 1.53 (setq end (match-end 0)) 1.54 @@ -973,10 +975,13 @@ 1.55 (skip-chars-forward " \t\n") 1.56 (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) 1.57 (setq list (cons 1.58 - (list (concat "#" (YaTeX-match-string 1))) 1.59 + (list (concat hash (YaTeX-match-string 1))) 1.60 list)))) 1.61 list)))) 1.62 1.63 +(defun yahtml-collect-ids (&optional file) 1.64 + (yahtml-collect-labels file "id" 'withouthash)) 1.65 + 1.66 (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") 1.67 (if yahtml-url-completion-map nil 1.68 (setq yahtml-url-completion-map 1.69 @@ -1417,9 +1422,14 @@ 1.70 1.71 (defun yahtml:select () 1.72 "Add-in function for `select' input format" 1.73 - (setq yahtml-last-single-cmd "option") 1.74 + (setq yahtml-last-single-cmd "option" ;;<- it's old 1.75 + yahtml-last-typeface-cmd "option") 1.76 (concat " " (if yahtml-prefer-upcase-attributes "NAME" "name") "=\"" 1.77 (read-string-with-history "name: ") "\"")) 1.78 +(defun yahtml:label () 1.79 + "Add-in function for `<label>'" 1.80 + (concat " " (if yahtml-prefer-upcase-attributes "FOR" "for") "=\"" 1.81 + (read-string-with-history "for: ") "\"")) 1.82 1.83 (defun yahtml:ol () 1.84 "Add-in function for <ol>" 1.85 @@ -1448,22 +1458,31 @@ 1.86 1.87 (defun yahtml:input () 1.88 "Add-in function for `input' form" 1.89 - (let ((size "") name type value checked (maxlength "") 1.90 + (let ((size "") name type value id (maxlength "") 1.91 (l yahtml-prefer-upcase-attributes)) 1.92 (setq name (read-string-with-history "name: ") 1.93 type (YaTeX-completing-read-or-skip "type (default=text): " 1.94 yahtml-input-types nil t) 1.95 - value (YaTeX-read-string-or-skip "value: ")) 1.96 - (if (string-match "text\\|password\\|^$" type) 1.97 + value (YaTeX-read-string-or-skip "value: ") 1.98 + id (YaTeX-read-string-or-skip "id: ")) 1.99 + (if (string-match "text\\|password\\|^$" typxe) 1.100 (setq size (YaTeX-read-string-or-skip "size: ") 1.101 maxlength (YaTeX-read-string-or-skip "maxlength: "))) 1.102 (concat 1.103 (if l "NAME" "name") "=\"" name "\"" 1.104 (yahtml-make-optional-argument "type" type) 1.105 (yahtml-make-optional-argument "value" value) 1.106 + (yahtml-make-optional-argument "id" id) 1.107 (yahtml-make-optional-argument "size" size) 1.108 (yahtml-make-optional-argument "maxlength" maxlength)))) 1.109 1.110 +(defun yahtml:datalist () 1.111 + "Add-in function for `datalist' form" 1.112 + (setq yahtml-last-typeface-cmd "option") 1.113 + (let ((ids (yahtml-collect-ids))) 1.114 + (yahtml-make-optional-argument 1.115 + "id" (YaTeX-completing-read-or-skip "id: " ids nil t)))) 1.116 + 1.117 (defun yahtml:textarea () 1.118 "Add-in function for `textarea'" 1.119 (interactive) 1.120 @@ -2838,6 +2857,11 @@ 1.121 1.122 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) 1.123 1.124 +(defun yahtml-intelligent-newline-datalist () 1.125 + (interactive) 1.126 + (yahtml-insert-form "option") 1.127 + (save-excursion (yahtml-insert-form "/option"))) 1.128 + 1.129 (defun yahtml-intelligent-newline-dl () 1.130 (interactive) 1.131 (let ((case-fold-search t))