diff options
Diffstat (limited to 'lisp/textmodes/sgml-mode.el')
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 7051f520b90..fda00ec367e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -34,6 +34,7 @@ (require 'dom) (require 'seq) +(require 'facemenu) (eval-when-compile (require 'subr-x)) (eval-when-compile (require 'skeleton) @@ -117,8 +118,7 @@ definitions. So we normally turn it off.") This takes effect when first loading the `sgml-mode' library.") (defvar sgml-mode-map - (let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets. - (menu-map (make-sparse-keymap "SGML"))) + (let ((map (make-keymap))) ;`sparse' doesn't allow binding to charsets. (define-key map "\C-c\C-i" 'sgml-tags-invisible) (define-key map "/" 'sgml-slash) (define-key map "\C-c\C-n" 'sgml-name-char) @@ -153,26 +153,24 @@ This takes effect when first loading the `sgml-mode' library.") (map (nth 1 map))) (while (< (setq c (1+ c)) 256) (aset map c 'sgml-maybe-name-self))) - (define-key map [menu-bar sgml] (cons "SGML" menu-map)) - (define-key menu-map [sgml-validate] '("Validate" . sgml-validate)) - (define-key menu-map [sgml-name-8bit-mode] - '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode)) - (define-key menu-map [sgml-tags-invisible] - '("Toggle Tag Visibility" . sgml-tags-invisible)) - (define-key menu-map [sgml-tag-help] - '("Describe Tag" . sgml-tag-help)) - (define-key menu-map [sgml-delete-tag] - '("Delete Tag" . sgml-delete-tag)) - (define-key menu-map [sgml-skip-tag-forward] - '("Forward Tag" . sgml-skip-tag-forward)) - (define-key menu-map [sgml-skip-tag-backward] - '("Backward Tag" . sgml-skip-tag-backward)) - (define-key menu-map [sgml-attributes] - '("Insert Attributes" . sgml-attributes)) - (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag)) map) "Keymap for SGML mode. See also `sgml-specials'.") +(easy-menu-define sgml-mode-menu sgml-mode-map + "Menu for SGML mode." + '("SGML" + ["Insert Tag" sgml-tag] + ["Insert Attributes" sgml-attributes] + ["Backward Tag" sgml-skip-tag-backward] + ["Forward Tag" sgml-skip-tag-forward] + ["Delete Tag" sgml-delete-tag] + ["Describe Tag" sgml-tag-help] + "---" + ["Toggle Tag Visibility" sgml-tags-invisible] + ["Toggle 8 Bit Insertion" sgml-name-8bit-mode] + "---" + ["Validate" sgml-validate])) + (defun sgml-make-syntax-table (specials) (let ((table (make-syntax-table text-mode-syntax-table))) (modify-syntax-entry ?< "(>" table) @@ -192,8 +190,19 @@ This takes effect when first loading the `sgml-mode' library.") "Syntax table used in SGML mode. See also `sgml-specials'.") (defconst sgml-tag-syntax-table - (let ((table (sgml-make-syntax-table sgml-specials))) - (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/)) + (let ((table (sgml-make-syntax-table sgml-specials)) + brackets) + (map-char-table + (lambda (key value) + (setq brackets (cons (list + (if (consp key) + (list (car key) (cdr key)) + key) + value) + brackets))) + (unicode-property-table-internal 'paired-bracket)) + (setq brackets (delete-dups (flatten-tree brackets))) + (dolist (char (append brackets (list ?$ ?% ?& ?* ?+ ?/))) (modify-syntax-entry char "." table)) (unless (memq ?' sgml-specials) ;; Avoid that skipping a tag backwards skips any "'" prefixing it. @@ -625,7 +634,8 @@ Do \\[describe-key] on the following bindings to discover what they do. (setq-local syntax-propertize-function #'sgml-syntax-propertize) (setq-local syntax-ppss-table sgml-tag-syntax-table) (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) - (setq-local sgml-xml-mode (sgml-xml-guess)) + (when (sgml-xml-guess) + (setq-local sgml-xml-mode t)) (unless sgml-xml-mode (setq-local skeleton-transformation-function sgml-transformation-function)) ;; This will allow existing comments within declarations to be @@ -1788,8 +1798,7 @@ This defaults to `sgml-quick-keys'. This takes effect when first loading the library.") (defvar html-mode-map - (let ((map (make-sparse-keymap)) - (menu-map (make-sparse-keymap "HTML"))) + (let ((map (make-sparse-keymap))) (set-keymap-parent map sgml-mode-map) (define-key map "\C-c6" 'html-headline-6) (define-key map "\C-c5" 'html-headline-5) @@ -1826,34 +1835,35 @@ This takes effect when first loading the library.") (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)) - (define-key menu-map [html-autoview-mode] - '("Toggle Autoviewing" . html-autoview-mode)) - (define-key menu-map [browse-url-of-buffer] - '("View Buffer Contents" . browse-url-of-buffer)) - (define-key menu-map [nil] '("--")) - ;;(define-key menu-map "6" '("Heading 6" . html-headline-6)) - ;;(define-key menu-map "5" '("Heading 5" . html-headline-5)) - ;;(define-key menu-map "4" '("Heading 4" . html-headline-4)) - (define-key menu-map "3" '("Heading 3" . html-headline-3)) - (define-key menu-map "2" '("Heading 2" . html-headline-2)) - (define-key menu-map "1" '("Heading 1" . html-headline-1)) - (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons)) - (define-key menu-map "c" '("Checkboxes" . html-checkboxes)) - (define-key menu-map "l" '("List Item" . html-list-item)) - (define-key menu-map "u" '("Unordered List" . html-unordered-list)) - (define-key menu-map "o" '("Ordered List" . html-ordered-list)) - (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule)) - (define-key menu-map "\n" '("Line Break" . html-line)) - (define-key menu-map "\r" '("Paragraph" . html-paragraph)) - (define-key menu-map "i" '("Image" . html-image)) - (define-key menu-map "h" '("Href Anchor URL" . html-href-anchor)) - (define-key menu-map "f" '("Href Anchor File" . html-href-anchor-file)) - (define-key menu-map "n" '("Name Anchor" . html-name-anchor)) - (define-key menu-map "#" '("ID Anchor" . html-id-anchor)) map) "Keymap for commands for use in HTML mode.") +(easy-menu-define html-mode-menu html-mode-map + "Menu for HTML mode." + '("HTML" + ["ID Anchor" html-id-anchor] + ["Name Anchor" html-name-anchor] + ["Href Anchor File" html-href-anchor-file] + ["Href Anchor URL" html-href-anchor] + ["Image" html-image] + ["Paragraph" html-paragraph] + ["Line Break" html-line] + ["Horizontal Rule" html-horizontal-rule] + ["Ordered List" html-ordered-list] + ["Unordered List" html-unordered-list] + ["List Item" html-list-item] + ["Checkboxes" html-checkboxes] + ["Radio Buttons" html-radio-buttons] + ["Heading 1" html-headline-1] + ["Heading 2" html-headline-2] + ["Heading 3" html-headline-3] + ;; ["Heading 4" html-headline-4] + ;; ["Heading 5" html-headline-5] + ;; ["Heading 6" html-headline-6] + "---" + ["View Buffer Contents" browse-url-of-buffer] + ["Toggle Autoviewing" html-autoview-mode])) + (defvar html-face-tag-alist '((bold . "strong") (italic . "em") @@ -2370,7 +2380,7 @@ or Edit/Text Properties/Face commands. Pages can have <a name=\"SOMENAME\">named points</a> and can link other points to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a href=\"URL\">see also URL</a> where URL is a filename relative to current -directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'. +directory, or absolute as in `https://www.cs.indiana.edu/elisp/w3/docs.html'. Images in many formats can be inlined with <img src=\"URL\">. @@ -2442,7 +2452,7 @@ The third `match-string' will be the used in the menu.") HTML Autoview mode is a buffer-local minor mode for use with `html-mode'. If enabled, saving the file automatically runs `browse-url-of-buffer' to view it." - nil nil nil + :lighter nil (if html-autoview-mode (add-hook 'after-save-hook #'browse-url-of-buffer nil t) (remove-hook 'after-save-hook #'browse-url-of-buffer t))) |