Mercurial > hgrepos > hgweb.cgi > yatex
comparison yahtml.el @ 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 | 8a9ef7c96a0a |
children | 1b9beabd3fd1 |
comparison
equal
deleted
inserted
replaced
436:e78a87bc2c9e | 437:27f00e6e0150 |
---|---|
1 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- | 1 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- |
2 ;;; (c) 1994-2015 by HIROSE Yuuji [yuuji(@)yatex.org] | 2 ;;; (c) 1994-2015 by HIROSE Yuuji [yuuji(@)yatex.org] |
3 ;;; Last modified Tue Jan 5 10:17:40 2016 on firestorm | 3 ;;; Last modified Sat Jul 16 13:32:35 2016 on firestorm |
4 ;;; $Id$ | 4 ;;; $Id$ |
5 | 5 |
6 (defconst yahtml-revision-number "1.78.1" | 6 (defconst yahtml-revision-number "1.78.1" |
7 "Revision number of running yahtml.el") | 7 "Revision number of running yahtml.el") |
8 | 8 |
423 (defvar yahtml-command-regexp "[A-Za-z0-9]+" | 423 (defvar yahtml-command-regexp "[A-Za-z0-9]+" |
424 "Regexp of constituent of html commands.") | 424 "Regexp of constituent of html commands.") |
425 | 425 |
426 ;;; Completion tables for `form' | 426 ;;; Completion tables for `form' |
427 (defvar yahtml-form-table | 427 (defvar yahtml-form-table |
428 '(("img") ("input") ("link") ("meta"))) | 428 '(("img") ("input") ("link") ("meta") ("label"))) |
429 (defvar yahtml-user-form-table nil) | 429 (defvar yahtml-user-form-table nil) |
430 (defvar yahtml-tmp-form-table nil) | 430 (defvar yahtml-tmp-form-table nil) |
431 (defvar yahtml-last-form "img") | 431 (defvar yahtml-last-form "img") |
432 | 432 |
433 (defvar yahtml-env-table | 433 (defvar yahtml-env-table |
440 ("table") ("thead") ("tbody") ("tfoot") ("tr") ("th") ("td") | 440 ("table") ("thead") ("tbody") ("tfoot") ("tr") ("th") ("td") |
441 ("address") ("button") | 441 ("address") ("button") |
442 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") | 442 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") |
443 ;; ("p") ;This makes indentation screwed up! | 443 ;; ("p") ;This makes indentation screwed up! |
444 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") | 444 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") |
445 ("option") | 445 ("option") ("datalist") |
446 )) | 446 )) |
447 | 447 |
448 (if yahtml-html4-strict | 448 (if yahtml-html4-strict |
449 (setq yahtml-env-table | 449 (setq yahtml-env-table |
450 (delete (assoc "center" yahtml-env-table) yahtml-env-table))) | 450 (delete (assoc "center" yahtml-env-table) yahtml-env-table))) |
949 (string< "" s)) | 949 (string< "" s)) |
950 (if (eq (aref s 0) ? ) s (concat " " s)) | 950 (if (eq (aref s 0) ? ) s (concat " " s)) |
951 "")))) | 951 "")))) |
952 | 952 |
953 (defvar yahtml-completing-buffer nil) | 953 (defvar yahtml-completing-buffer nil) |
954 (defun yahtml-collect-labels (&optional file) | 954 (defun yahtml-collect-labels (&optional file ptn withouthash) |
955 "Collect current buffers label (<?? name=...>). | 955 "Collect current buffers label (<?? name=...>). |
956 If optional argument FILE is specified collect labels in FILE." | 956 If optional argument FILE is specified collect labels in FILE." |
957 (let (list end) | 957 (let ((attrptn (concat "\\(" (or ptn "name\\|id") "\\)\\s *=")) |
958 (hash (if withouthash "" "#")) | |
959 list end) | |
958 (save-excursion | 960 (save-excursion |
959 (set-buffer yahtml-completing-buffer) | 961 (set-buffer (or yahtml-completing-buffer (current-buffer))) |
960 (if file (let (hilit-auto-highlight) | 962 (if file (let (hilit-auto-highlight) |
961 (set-buffer (find-file-noselect file)))) | 963 (set-buffer (find-file-noselect file)))) |
962 (save-excursion | 964 (save-excursion |
963 (goto-char (point-min)) | 965 (goto-char (point-min)) |
964 (while ;(re-search-forward "<\\w+\\b" nil t) | 966 (while ;(re-search-forward "<\\w+\\b" nil t) |
965 (re-search-forward "\\(name\\|id\\)\\s *=" nil t) | 967 (re-search-forward attrptn nil t) |
966 ;(setq bound (match-end 0)) | 968 ;(setq bound (match-end 0)) |
967 ;(search-forward ">" nil t) | 969 ;(search-forward ">" nil t) |
968 (setq end (match-end 0)) | 970 (setq end (match-end 0)) |
969 (if (and ;(re-search-backward "\\(name\\|id\\)\\s *=" bound t) | 971 (if (and ;(re-search-backward "\\(name\\|id\\)\\s *=" bound t) |
970 (yahtml-on-assignment-p) | 972 (yahtml-on-assignment-p) |
971 (progn | 973 (progn |
972 (goto-char end) | 974 (goto-char end) |
973 (skip-chars-forward " \t\n") | 975 (skip-chars-forward " \t\n") |
974 (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) | 976 (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) |
975 (setq list (cons | 977 (setq list (cons |
976 (list (concat "#" (YaTeX-match-string 1))) | 978 (list (concat hash (YaTeX-match-string 1))) |
977 list)))) | 979 list)))) |
978 list)))) | 980 list)))) |
981 | |
982 (defun yahtml-collect-ids (&optional file) | |
983 (yahtml-collect-labels file "id" 'withouthash)) | |
979 | 984 |
980 (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") | 985 (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") |
981 (if yahtml-url-completion-map nil | 986 (if yahtml-url-completion-map nil |
982 (setq yahtml-url-completion-map | 987 (setq yahtml-url-completion-map |
983 (copy-keymap minibuffer-local-completion-map)) | 988 (copy-keymap minibuffer-local-completion-map)) |
1415 " " (if yahtml-prefer-upcase-attributes "ACTION" "action") "=\"" | 1420 " " (if yahtml-prefer-upcase-attributes "ACTION" "action") "=\"" |
1416 (read-string-with-history "Action: ") "\"")) | 1421 (read-string-with-history "Action: ") "\"")) |
1417 | 1422 |
1418 (defun yahtml:select () | 1423 (defun yahtml:select () |
1419 "Add-in function for `select' input format" | 1424 "Add-in function for `select' input format" |
1420 (setq yahtml-last-single-cmd "option") | 1425 (setq yahtml-last-single-cmd "option" ;;<- it's old |
1426 yahtml-last-typeface-cmd "option") | |
1421 (concat " " (if yahtml-prefer-upcase-attributes "NAME" "name") "=\"" | 1427 (concat " " (if yahtml-prefer-upcase-attributes "NAME" "name") "=\"" |
1422 (read-string-with-history "name: ") "\"")) | 1428 (read-string-with-history "name: ") "\"")) |
1429 (defun yahtml:label () | |
1430 "Add-in function for `<label>'" | |
1431 (concat " " (if yahtml-prefer-upcase-attributes "FOR" "for") "=\"" | |
1432 (read-string-with-history "for: ") "\"")) | |
1423 | 1433 |
1424 (defun yahtml:ol () | 1434 (defun yahtml:ol () |
1425 "Add-in function for <ol>" | 1435 "Add-in function for <ol>" |
1426 (setq yahtml-last-single-cmd "li") | 1436 (setq yahtml-last-single-cmd "li") |
1427 (let ((start (YaTeX-read-string-or-skip "start=")) | 1437 (let ((start (YaTeX-read-string-or-skip "start=")) |
1446 '(("text") ("password") ("checkbox") ("radio") ("submit") | 1456 '(("text") ("password") ("checkbox") ("radio") ("submit") |
1447 ("reset") ("image") ("hidden") ("file"))) | 1457 ("reset") ("image") ("hidden") ("file"))) |
1448 | 1458 |
1449 (defun yahtml:input () | 1459 (defun yahtml:input () |
1450 "Add-in function for `input' form" | 1460 "Add-in function for `input' form" |
1451 (let ((size "") name type value checked (maxlength "") | 1461 (let ((size "") name type value id (maxlength "") |
1452 (l yahtml-prefer-upcase-attributes)) | 1462 (l yahtml-prefer-upcase-attributes)) |
1453 (setq name (read-string-with-history "name: ") | 1463 (setq name (read-string-with-history "name: ") |
1454 type (YaTeX-completing-read-or-skip "type (default=text): " | 1464 type (YaTeX-completing-read-or-skip "type (default=text): " |
1455 yahtml-input-types nil t) | 1465 yahtml-input-types nil t) |
1456 value (YaTeX-read-string-or-skip "value: ")) | 1466 value (YaTeX-read-string-or-skip "value: ") |
1457 (if (string-match "text\\|password\\|^$" type) | 1467 id (YaTeX-read-string-or-skip "id: ")) |
1468 (if (string-match "text\\|password\\|^$" typxe) | |
1458 (setq size (YaTeX-read-string-or-skip "size: ") | 1469 (setq size (YaTeX-read-string-or-skip "size: ") |
1459 maxlength (YaTeX-read-string-or-skip "maxlength: "))) | 1470 maxlength (YaTeX-read-string-or-skip "maxlength: "))) |
1460 (concat | 1471 (concat |
1461 (if l "NAME" "name") "=\"" name "\"" | 1472 (if l "NAME" "name") "=\"" name "\"" |
1462 (yahtml-make-optional-argument "type" type) | 1473 (yahtml-make-optional-argument "type" type) |
1463 (yahtml-make-optional-argument "value" value) | 1474 (yahtml-make-optional-argument "value" value) |
1475 (yahtml-make-optional-argument "id" id) | |
1464 (yahtml-make-optional-argument "size" size) | 1476 (yahtml-make-optional-argument "size" size) |
1465 (yahtml-make-optional-argument "maxlength" maxlength)))) | 1477 (yahtml-make-optional-argument "maxlength" maxlength)))) |
1478 | |
1479 (defun yahtml:datalist () | |
1480 "Add-in function for `datalist' form" | |
1481 (setq yahtml-last-typeface-cmd "option") | |
1482 (let ((ids (yahtml-collect-ids))) | |
1483 (yahtml-make-optional-argument | |
1484 "id" (YaTeX-completing-read-or-skip "id: " ids nil t)))) | |
1466 | 1485 |
1467 (defun yahtml:textarea () | 1486 (defun yahtml:textarea () |
1468 "Add-in function for `textarea'" | 1487 "Add-in function for `textarea'" |
1469 (interactive) | 1488 (interactive) |
1470 (let (name rows cols) | 1489 (let (name rows cols) |
2836 (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " ")) | 2855 (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " ")) |
2837 (yahtml-indent-line)) | 2856 (yahtml-indent-line)) |
2838 | 2857 |
2839 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) | 2858 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) |
2840 | 2859 |
2860 (defun yahtml-intelligent-newline-datalist () | |
2861 (interactive) | |
2862 (yahtml-insert-form "option") | |
2863 (save-excursion (yahtml-insert-form "/option"))) | |
2864 | |
2841 (defun yahtml-intelligent-newline-dl () | 2865 (defun yahtml-intelligent-newline-dl () |
2842 (interactive) | 2866 (interactive) |
2843 (let ((case-fold-search t)) | 2867 (let ((case-fold-search t)) |
2844 (if (save-excursion | 2868 (if (save-excursion |
2845 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)[ \t>]" | 2869 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)[ \t>]" |