From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#35517: 27.0.50; Small improvements to HTML mode Date: Tue, 30 Apr 2019 16:38:33 -0700 Message-ID: <87wojb5aiu.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="135289"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 35517@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 01 01:41:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLcN4-000Z4E-Gl for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 May 2019 01:41:10 +0200 Original-Received: from localhost ([127.0.0.1]:55232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLcN3-0004mY-CH for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Apr 2019 19:41:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLcLz-00047x-KM for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:40:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLcLy-0004AP-9O for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:40:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLcLy-0004AG-56 for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hLcLy-00082X-07 for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Apr 2019 23:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35517 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.155666756230854 (code B ref -1); Tue, 30 Apr 2019 23:40:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Apr 2019 23:39:22 +0000 Original-Received: from localhost ([127.0.0.1]:42789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLcLJ-00081a-Tz for submit@debbugs.gnu.org; Tue, 30 Apr 2019 19:39:22 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLcLH-00081N-Uv for submit@debbugs.gnu.org; Tue, 30 Apr 2019 19:39:20 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLcLC-0003te-JL for submit@debbugs.gnu.org; Tue, 30 Apr 2019 19:39:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLcL8-0003b6-Fh for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:39:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLcL7-0003s1-Ax for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:39:10 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:47872 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLcL6-0003hS-SR for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 19:39:08 -0400 Original-Received: from localhost (50-251-205-17-static.hfc.comcastbusiness.net [50.251.205.17]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 48DBCFA026 for ; Tue, 30 Apr 2019 23:38:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158556 Archived-At: --=-=-= Content-Type: text/plain The attached patch provides some small improvements to HTML mode. It adds `html-div' and `html-span' skeleton commands, and changes the newline/indent behavior of `html-ordered-list', `html-unordered-list', `html-list-item', and `html-paragraph'. It also offers "class" and "id" attributes to most HTML tags in `sgml-attributes'. Comments welcome! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Tweaks-to-html-mode.patch >From 0293d7bb423950264558363e4e3a3d695f323347 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Tue, 30 Apr 2019 16:00:46 -0700 Subject: [PATCH] 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. --- lisp/textmodes/sgml-mode.el | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 9e3be99af1..b0d0ba8536 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -773,8 +773,16 @@ sgml-attributes (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) @@ -1752,6 +1760,7 @@ html-mode-map (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) @@ -1759,7 +1768,8 @@ html-mode-map (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)) @@ -2446,16 +2456,16 @@ html-line (define-skeleton html-ordered-list "HTML ordered list tags." nil - "
    " \n + \n "
      " \n "
    1. " _ (if sgml-xml-mode "
    2. ") \n - "
    ") + "
" > \n) (define-skeleton html-unordered-list "HTML unordered list tags." nil - "
    " \n + \n "
      " \n "
    • " _ (if sgml-xml-mode "
    • ") \n - "
    ") + "
" > \n) (define-skeleton html-list-item "HTML list item tag." @@ -2466,8 +2476,17 @@ html-list-item (define-skeleton html-paragraph "HTML paragraph tag." nil - (if (bolp) nil ?\n) - "

" _ (if sgml-xml-mode "

")) + \n "

" _ (if sgml-xml-mode "

")) + +(define-skeleton html-div + "HTML div tag." + nil + "
" > \n _ \n "
" >) + +(define-skeleton html-span + "HTML span tag." + nil + "" > _ "") (define-skeleton html-checkboxes "Group of connected checkbox inputs." -- 2.21.0 --=-=-=--