Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions xmlunicode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down