From ef7d66dc8f6718222dfc4347a96593f0001597a8 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Sat, 8 Mar 2025 14:19:40 -0500 Subject: [PATCH] Support insertion of Guillemet when using < and > Fixes #10 --- xmlunicode.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xmlunicode.el b/xmlunicode.el index 1184122..f26f853 100644 --- a/xmlunicode.el +++ b/xmlunicode.el @@ -206,6 +206,8 @@ (defvar xmlunicode-ndash (decode-char 'ucs #x002013)) (defvar xmlunicode-mdash (decode-char 'ucs #x002014)) (defvar xmlunicode-hellip (decode-char 'ucs #x002026)) +(defvar xmlunicode-lguill (decode-char 'ucs #x0000ab)) +(defvar xmlunicode-rguill (decode-char 'ucs #x0000bb)) (defvar xmlunicode-default-single-quote xmlunicode-apos "The default single quote character.") @@ -660,6 +662,31 @@ there too." (insert xmlunicode-hellip))) (t (insert "."))))) +(defun xmlunicode-smart-compare () + "Insert a guillemet instead of double angle-brackets." + (interactive) + (let* ((ch1 (char-before)) + (key (aref (this-command-keys) 0)) + (keys (this-command-keys)) + (substitution (if (char-equal key ?<) xmlunicode-lguill xmlunicode-rguill)) + (xml (derived-mode-p 'nxml-mode))) ; only do XML tests in XML modes + (cond + ((eq nil ch1) + (insert keys)) + ((xmlunicode--be-stupid) + (insert keys)) + ((and xml (xmlunicode-in-comment)) + (insert keys)) + ((char-equal ch1 substitution) + (progn + (delete-char -1) + (insert (make-string 3 key)))) + ((char-equal ch1 key) + (progn + (delete-char -1) + (insert substitution))) + (t (insert keys))))) + (defun xmlunicode-smart-semicolon () "Detect numeric character references and replace them with the appropriate char." (interactive)