diff options
author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-04-30 16:00:46 -0700 |
---|---|---|
committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-06-24 10:21:09 -0700 |
commit | 535051db2a89a9aba615c0c4f385f70e5a77a99d (patch) | |
tree | 6550ab41ab53d138b863b96f31f01d4a520c6a8d /lisp/textmodes | |
parent | 35c72aea449a0e05849cff8d8ad4b9bde25cebb5 (diff) | |
download | emacs-535051db2a89a9aba615c0c4f385f70e5a77a99d.tar.gz |
Tweaks to html mode
* lisp/textmodes/sgml-mode.el (sgml-attributes): Add the "class" and
"id" attributes when needed.
(html-mode-map): Add the `html-div' and `html-span' commands to the
`html-quick-keys' map.
(html-ordered-list, html-unordered-list, html-paragraph): Use the
"\n" element properly.
(html-div, html-span): New HTML skeletons.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 0c5d5e56a69..8d3000e5d8b 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -816,8 +816,16 @@ If QUIET, do not print a message when there are no attributes for TAG." (symbolp (car (car alist)))) (setq car (car alist) alist (cdr alist))) - (or quiet - (message "No attributes configured.")) + (unless (or alist quiet) + (message "No attributes configured.")) + (when alist + ;; Add class and id attributes if a) the element has any + ;; other attributes configured, and b) they're not already + ;; present. + (unless (assoc-string "class" alist) + (setq alist (cons '("class") alist))) + (unless (assoc-string "id" alist) + (setq alist (cons '("id") alist)))) (if (stringp (car alist)) (progn (insert (if (eq (preceding-char) ?\s) "" ?\s) @@ -1795,6 +1803,7 @@ This takes effect when first loading the library.") (define-key map "\C-c\C-ci" 'html-image) (when html-quick-keys (define-key map "\C-c-" 'html-horizontal-rule) + (define-key map "\C-cd" 'html-div) (define-key map "\C-co" 'html-ordered-list) (define-key map "\C-cu" 'html-unordered-list) (define-key map "\C-cr" 'html-radio-buttons) @@ -1802,7 +1811,8 @@ This takes effect when first loading the library.") (define-key map "\C-cl" 'html-list-item) (define-key map "\C-ch" 'html-href-anchor) (define-key map "\C-cn" 'html-name-anchor) - (define-key map "\C-ci" 'html-image)) + (define-key map "\C-ci" 'html-image) + (define-key map "\C-cs" 'html-span)) (define-key map "\C-c\C-s" 'html-autoview-mode) (define-key map "\C-c\C-v" 'browse-url-of-buffer) (define-key map [menu-bar html] (cons "HTML" menu-map)) @@ -2003,7 +2013,7 @@ This takes effect when first loading the library.") ("dd" ,(not sgml-xml-mode)) ("del" nil ("cite") ("datetime")) ("dfn") - ("div") + ("div" \n ("id") ("class")) ("dl" (nil \n ( "Term: " "<dt>" str (if sgml-xml-mode "</dt>") @@ -2489,16 +2499,16 @@ HTML Autoview mode is a buffer-local minor mode for use with (define-skeleton html-ordered-list "HTML ordered list tags." nil - "<ol>" \n + \n "<ol>" \n "<li>" _ (if sgml-xml-mode "</li>") \n - "</ol>") + "</ol>" > \n) (define-skeleton html-unordered-list "HTML unordered list tags." nil - "<ul>" \n + \n "<ul>" \n "<li>" _ (if sgml-xml-mode "</li>") \n - "</ul>") + "</ul>" > \n) (define-skeleton html-list-item "HTML list item tag." @@ -2509,8 +2519,17 @@ HTML Autoview mode is a buffer-local minor mode for use with (define-skeleton html-paragraph "HTML paragraph tag." nil - (if (bolp) nil ?\n) - "<p>" _ (if sgml-xml-mode "</p>")) + \n "<p>" _ (if sgml-xml-mode "</p>")) + +(define-skeleton html-div + "HTML div tag." + nil + "<div>" > \n _ \n "</div>" >) + +(define-skeleton html-span + "HTML span tag." + nil + "<span>" > _ "</span>") (define-skeleton html-checkboxes "Group of connected checkbox inputs." |