From f02624b34201aae3d69287e5ae86d466e5c4a6b3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 13 Sep 2021 06:04:32 +0200 Subject: ; Minor doc fixes found by checkdoc --- lisp/textmodes/sgml-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index fda00ec367e..5bfcc1a20cc 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -1208,7 +1208,7 @@ and move to the line in the SGML document that caused it." (compilation-start command)) (defsubst sgml-at-indentation-p () - "Return true if point is at the first non-whitespace character on the line." + "Return t if point is at the first non-whitespace character on the line." (save-excursion (skip-chars-backward " \t") (bolp))) @@ -2614,7 +2614,7 @@ HTML Autoview mode is a buffer-local minor mode for use with "") (define-skeleton html-html5-template - "Initial HTML5 template" + "Initial HTML5 template." nil "" \n "" \n -- cgit v1.2.3 From 7b3007336fedc30a1bce096fcc910a0a36370ee0 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 16 Sep 2021 16:03:36 +0200 Subject: Bind `M-o' in html-mode and enriched-mode * lisp/textmodes/enriched.el (enriched-mode-map): Actually define the `M-o' face map. * lisp/textmodes/sgml-mode.el (html-mode-map): Ditto (bug#50616). * lisp/textmodes/sgml-mode.el (html-mode): Adjust doc string. --- lisp/textmodes/enriched.el | 1 + lisp/textmodes/sgml-mode.el | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el index c650da43bff..4a5a5ab3677 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el @@ -191,6 +191,7 @@ The value is a list of \(VAR VALUE VAR VALUE...).") (define-key map "\C-x\t" #'increase-left-margin) (define-key map "\C-c[" #'set-left-margin) (define-key map "\C-c]" #'set-right-margin) + (define-key map "\M-o" #'facemenu-keymap) map) "Keymap for Enriched mode.") diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 5bfcc1a20cc..7ef8161ab5c 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -1835,6 +1835,7 @@ 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 "\M-o" 'facemenu-keymap) map) "Keymap for commands for use in HTML mode.") @@ -2372,10 +2373,11 @@ can also view with a browser to see what happens: have

Very Major Headlines

through
Very Minor Headlines

Parts can be separated with horizontal rules. -

Paragraphs only need an opening tag. Line breaks and multiple spaces are -ignored unless the text is

preformatted.
Text can be marked as -bold, italic or underlined using the normal M-o -or Edit/Text Properties/Face commands. +

Paragraphs only need an opening tag. Line breaks and multiple +spaces are ignored unless the text is

preformatted.
+Text can be marked as bold, italic or +underlined using the facemenu M-o or Edit/Text +Properties/Face commands. Pages can have named points and can link other points to them with see also somename. In the same way Date: Sat, 2 Oct 2021 15:14:15 +0200 Subject: Support 'strong-italic' facemenu face in html-mode * lisp/textmodes/sgml-mode.el (sgml-face-tag-alist) (sgml-mode-facemenu-add-face-function, html-face-tag-alist): Support 'strong-italic' facemenu face. --- lisp/textmodes/sgml-mode.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 7ef8161ab5c..22a90ca9cfb 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -440,7 +440,8 @@ These have to be run via `sgml-syntax-propertize'")) ;; internal (defvar sgml-face-tag-alist () - "Alist of face and tag name for facemenu.") + "Alist of face and tag name for facemenu. +The tag name can be a string or a list of strings.") (defvar sgml-tag-face-alist () "Tag names and face or list of faces to fontify with when invisible. @@ -528,11 +529,13 @@ an optional alist of possible values." (comment-indent-new-line soft))) (defun sgml-mode-facemenu-add-face-function (face _end) - (let ((tag-face (cdr (assq face sgml-face-tag-alist)))) + "Add \"face\" tags with `facemenu-keymap' commands." + (let ((tag-face (ensure-list (cdr (assq face sgml-face-tag-alist))))) (cond (tag-face (setq tag-face (funcall skeleton-transformation-function tag-face)) - (setq facemenu-end-add-face (concat "")) - (concat "<" tag-face ">")) + (setq facemenu-end-add-face + (mapconcat (lambda (f) (concat "")) (reverse tag-face) "")) + (mapconcat (lambda (f) (concat "<" f ">")) tag-face "")) ((and (consp face) (consp (car face)) (null (cdr face)) @@ -1868,6 +1871,7 @@ This takes effect when first loading the library.") (defvar html-face-tag-alist '((bold . "strong") (italic . "em") + (bold-italic . ("strong" "em")) (underline . "u") (mode-line . "rev")) "Value of `sgml-face-tag-alist' for HTML mode.") -- cgit v1.2.3 From bb495329e7da5026c115f6c2a28d877a8b84c4f3 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 6 Nov 2021 22:45:05 +0100 Subject: Support yank-media in html-mode * lisp/textmodes/sgml-mode.el (html-mode--html-yank-handler): New function. (html-mode): Handle text/html. --- etc/NEWS | 3 +++ lisp/textmodes/sgml-mode.el | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/etc/NEWS b/etc/NEWS index c9133195e9d..0d615b3793b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -219,6 +219,9 @@ If non-nil, 'C-c C-a' will put attached files at the end of the message. --- *** Message Mode now supports image yanking. +--- +*** HTML Mode now supports text/html yanking. + ** Gnus +++ diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 22a90ca9cfb..c9d43b6ef86 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2415,6 +2415,7 @@ To work around that, do: (setq-local css-id-list-function #'html-current-buffer-ids)) (setq imenu-create-index-function 'html-imenu-index) + (register-yank-media-handler 'text/html #'html-mode--html-yank-handler) (setq-local sgml-empty-tags ;; From HTML-4.01's loose.dtd, parsed with @@ -2430,6 +2431,11 @@ To work around that, do: ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose ) +(defun html-mode--html-yank-handler (_type html) + (save-restriction + (insert html) + (sgml-pretty-print (point-min) (point-max)))) + (defvar html-imenu-regexp "\\s-*]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" "A regular expression matching a head line to be added to the menu. -- cgit v1.2.3 From 465cb1fff12b26059896bf8e2057d06a61bc7339 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 7 Nov 2021 00:08:36 +0100 Subject: Allow yanking images to html-mode * lisp/net/mailcap.el (mailcap-mime-type-to-extension): Autoload. * lisp/textmodes/sgml-mode.el (html-mode--image-yank-handler): New function. (html-mode): Accept image/*. --- etc/NEWS | 2 +- lisp/net/mailcap.el | 1 + lisp/textmodes/sgml-mode.el | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/etc/NEWS b/etc/NEWS index 0d615b3793b..3dcaffeac46 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -220,7 +220,7 @@ If non-nil, 'C-c C-a' will put attached files at the end of the message. *** Message Mode now supports image yanking. --- -*** HTML Mode now supports text/html yanking. +*** HTML Mode now supports text/html and image/* yanking. ** Gnus diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 0ad1a53e846..2c687557181 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -1068,6 +1068,7 @@ For instance, \"foo.png\" will result in \"image/png\"." (match-string 1 file-name) ""))) +;;;###autoload (defun mailcap-mime-type-to-extension (mime-type) "Return a file name extension based on a mime type. For instance, `image/png' will result in `png'." diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index c9d43b6ef86..2b3db0bfeb2 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2416,6 +2416,7 @@ To work around that, do: (setq imenu-create-index-function 'html-imenu-index) (register-yank-media-handler 'text/html #'html-mode--html-yank-handler) + (register-yank-media-handler "image/.*" #'html-mode--image-yank-handler) (setq-local sgml-empty-tags ;; From HTML-4.01's loose.dtd, parsed with @@ -2436,6 +2437,24 @@ To work around that, do: (insert html) (sgml-pretty-print (point-min) (point-max)))) +(defun html-mode--image-yank-handler (type image) + (let ((file (read-file-name "Save %s image to: "))) + (when (file-directory-p file) + (user-error "%s is a directory")) + (when (and (file-exists-p file) + (not (yes-or-no-p "%s exists; overwrite?"))) + (user-error "%s exists")) + (with-temp-buffer + (set-buffer-multibyte nil) + (insert image) + (write-region (point-min) (point-max) file)) + (insert-image + (create-image file (mailcap-mime-type-to-extension type) nil + :max-width 200 + :max-height 200) + " ") + (insert (format "\n" (file-relative-name file))))) + (defvar html-imenu-regexp "\\s-*]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" "A regular expression matching a head line to be added to the menu. -- cgit v1.2.3 From 6a546a248696ff82152fbafb46b7cc3586abbb1d Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 7 Nov 2021 02:34:54 +0100 Subject: Fix html-mode--image-yank-handler prompting * lisp/textmodes/sgml-mode.el (html-mode--image-yank-handler): Fix two format statements and rearrange images. --- lisp/textmodes/sgml-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 2b3db0bfeb2..8985fe5cdf9 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2438,22 +2438,22 @@ To work around that, do: (sgml-pretty-print (point-min) (point-max)))) (defun html-mode--image-yank-handler (type image) - (let ((file (read-file-name "Save %s image to: "))) + (let ((file (read-file-name (format "Save %s image to: " type)))) (when (file-directory-p file) (user-error "%s is a directory")) (when (and (file-exists-p file) - (not (yes-or-no-p "%s exists; overwrite?"))) + (not (yes-or-no-p (format "%s exists; overwrite?" file)))) (user-error "%s exists")) (with-temp-buffer (set-buffer-multibyte nil) (insert image) (write-region (point-min) (point-max) file)) + (insert (format "\n" (file-relative-name file))) (insert-image (create-image file (mailcap-mime-type-to-extension type) nil :max-width 200 :max-height 200) - " ") - (insert (format "\n" (file-relative-name file))))) + " "))) (defvar html-imenu-regexp "\\s-*]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" -- cgit v1.2.3 From cddd927d36ac70bdc7614190e649b3aed56ff97f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 8 Nov 2021 01:40:58 +0100 Subject: Rename 'register-yank-media-handler' * lisp/textmodes/sgml-mode.el (html-mode): * lisp/gnus/message.el (message-mode): * doc/lispref/frames.texi (Yanking Media): Adjust. * lisp/yank-media.el (yank-media): Adjust doc string. (yank-media-handler): Rename from `register-' because that may cause confusion with register.el functions. --- doc/lispref/frames.texi | 6 +++--- lisp/gnus/message.el | 2 +- lisp/textmodes/sgml-mode.el | 4 ++-- lisp/yank-media.el | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index a0565130022..8a77fdef3fb 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -3936,13 +3936,13 @@ it by default. So Emacs has a system to let modes register handlers for these ``complicated'' selections. -@defun register-yank-media-handler types handler +@defun yank-media-handler types handler @var{types} can be a @acronym{MIME} media type symbol, a regexp to match these, or a list of these symbols and regexps. For instance: @example -(register-yank-media-handler 'text/html #'my-html-handler) -(register-yank-media-handler "image/.*" #'my-image-handler) +(yank-media-handler 'text/html #'my-html-handler) +(yank-media-handler "image/.*" #'my-image-handler) @end example A mode can register as many handlers as required. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index b7d98d52de5..77e8fcdfd16 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3157,7 +3157,7 @@ Like `text-mode', but with these additional commands: (setq-local message-checksum nil) (setq-local message-mime-part 0) (message-setup-fill-variables) - (register-yank-media-handler "image/.*" #'message--yank-media-image-handler) + (yank-media-handler "image/.*" #'message--yank-media-image-handler) (when message-fill-column (setq fill-column message-fill-column) (turn-on-auto-fill)) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 8985fe5cdf9..3b0c5d8b65c 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2415,8 +2415,8 @@ To work around that, do: (setq-local css-id-list-function #'html-current-buffer-ids)) (setq imenu-create-index-function 'html-imenu-index) - (register-yank-media-handler 'text/html #'html-mode--html-yank-handler) - (register-yank-media-handler "image/.*" #'html-mode--image-yank-handler) + (yank-media-handler 'text/html #'html-mode--html-yank-handler) + (yank-media-handler "image/.*" #'html-mode--image-yank-handler) (setq-local sgml-empty-tags ;; From HTML-4.01's loose.dtd, parsed with diff --git a/lisp/yank-media.el b/lisp/yank-media.el index 6d0d0b1a181..2c79a14e7d3 100644 --- a/lisp/yank-media.el +++ b/lisp/yank-media.el @@ -33,7 +33,7 @@ "Yank media (images, HTML and the like) from the clipboard. This command depends on the current major mode having support for accepting the media type. The mode has to register itself using -the `register-yank-media-handler' mechanism." +the `yank-media-handler' mechanism." (interactive) (unless yank-media--registered-handlers (user-error "The `%s' mode hasn't registered any handlers" major-mode)) @@ -89,7 +89,7 @@ the `register-yank-media-handler' mechanism." data))) ;;;###autoload -(defun register-yank-media-handler (types handler) +(defun yank-media-handler (types handler) "Register HANDLER for dealing with `yank-media' actions for TYPES. TYPES should be a MIME media type symbol, a regexp, or a list that can contain both symbols and regexps. -- cgit v1.2.3 From a460f3d378f52e8a09441455be764eec595a3314 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 8 Nov 2021 06:04:11 +0100 Subject: Make html-mode--html-yank-handler more resilient * lisp/textmodes/sgml-mode.el (html-mode--html-yank-handler): The HTML may not be valid, so suppress errors. --- lisp/textmodes/sgml-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/textmodes/sgml-mode.el') diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 3b0c5d8b65c..dedc3882199 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2435,7 +2435,8 @@ To work around that, do: (defun html-mode--html-yank-handler (_type html) (save-restriction (insert html) - (sgml-pretty-print (point-min) (point-max)))) + (ignore-errors + (sgml-pretty-print (point-min) (point-max))))) (defun html-mode--image-yank-handler (type image) (let ((file (read-file-name (format "Save %s image to: " type)))) -- cgit v1.2.3