# HG changeset patch # User HIROSE Yuuji # Date 1468643617 -32399 # Node ID 27f00e6e0150fb59905b19ae4aaac1610de3f9e8 # Parent e78a87bc2c9e4a35ff5f53b0b765ea0e0a1c080b yahtml:datalist can complete id in a buffer diff -r e78a87bc2c9e -r 27f00e6e0150 yahtml.el --- a/yahtml.el Fri Jan 08 08:18:54 2016 +0859 +++ b/yahtml.el Sat Jul 16 13:33:36 2016 +0859 @@ -1,6 +1,6 @@ ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- ;;; (c) 1994-2015 by HIROSE Yuuji [yuuji(@)yatex.org] -;;; Last modified Tue Jan 5 10:17:40 2016 on firestorm +;;; Last modified Sat Jul 16 13:32:35 2016 on firestorm ;;; $Id$ (defconst yahtml-revision-number "1.78.1" @@ -425,7 +425,7 @@ ;;; Completion tables for `form' (defvar yahtml-form-table - '(("img") ("input") ("link") ("meta"))) + '(("img") ("input") ("link") ("meta") ("label"))) (defvar yahtml-user-form-table nil) (defvar yahtml-tmp-form-table nil) (defvar yahtml-last-form "img") @@ -442,7 +442,7 @@ ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") ;; ("p") ;This makes indentation screwed up! ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") - ("option") + ("option") ("datalist") )) (if yahtml-html4-strict @@ -951,18 +951,20 @@ "")))) (defvar yahtml-completing-buffer nil) -(defun yahtml-collect-labels (&optional file) +(defun yahtml-collect-labels (&optional file ptn withouthash) "Collect current buffers label (). If optional argument FILE is specified collect labels in FILE." - (let (list end) + (let ((attrptn (concat "\\(" (or ptn "name\\|id") "\\)\\s *=")) + (hash (if withouthash "" "#")) + list end) (save-excursion - (set-buffer yahtml-completing-buffer) + (set-buffer (or yahtml-completing-buffer (current-buffer))) (if file (let (hilit-auto-highlight) (set-buffer (find-file-noselect file)))) (save-excursion (goto-char (point-min)) (while ;(re-search-forward "<\\w+\\b" nil t) - (re-search-forward "\\(name\\|id\\)\\s *=" nil t) + (re-search-forward attrptn nil t) ;(setq bound (match-end 0)) ;(search-forward ">" nil t) (setq end (match-end 0)) @@ -973,10 +975,13 @@ (skip-chars-forward " \t\n") (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) (setq list (cons - (list (concat "#" (YaTeX-match-string 1))) + (list (concat hash (YaTeX-match-string 1))) list)))) list)))) +(defun yahtml-collect-ids (&optional file) + (yahtml-collect-labels file "id" 'withouthash)) + (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") (if yahtml-url-completion-map nil (setq yahtml-url-completion-map @@ -1417,9 +1422,14 @@ (defun yahtml:select () "Add-in function for `select' input format" - (setq yahtml-last-single-cmd "option") + (setq yahtml-last-single-cmd "option" ;;<- it's old + yahtml-last-typeface-cmd "option") (concat " " (if yahtml-prefer-upcase-attributes "NAME" "name") "=\"" (read-string-with-history "name: ") "\"")) +(defun yahtml:label () + "Add-in function for `