branch: elpa/adoc-mode
commit d1aaea28ef2eff033267b4cd7e1844552d1ac245
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
[Fix #36] Remove unichars.el dependency
Replace adoc-make-unichar-alist to use Emacs's built-in
sgml-char-names vector instead of the unmaintained unichars.el
package. This provides the same HTML entity name resolution
without any external dependency.
---
CHANGELOG.md | 1 +
adoc-mode.el | 33 ++++++++++++++-------------------
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ceb4ed759..cb19e7fee8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@
- [#57](https://github.com/bbatsov/adoc-mode/issues/57): Fix Emacs hang on
escaped curly braces in attribute reference regex.
- [#54](https://github.com/bbatsov/adoc-mode/issues/54): Fix multiline
font-lock for inline formatting by extending fontification region to paragraph
boundaries.
- [#52](https://github.com/bbatsov/adoc-mode/issues/52): Prevent
`auto-fill-mode` from breaking section title lines.
+- [#36](https://github.com/bbatsov/adoc-mode/issues/36): Remove `unichars.el`
dependency; use built-in `sgml-char-names` instead.
## 0.7.0 (2023-03-09)
diff --git a/adoc-mode.el b/adoc-mode.el
index a20df38ca8..b90b900d0c 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -104,10 +104,10 @@ function returns nil, nothing is done with named character
entities. Note that if `adoc-insert-replacement' is nil,
adoc-unichar-name-resolver is not used.
-You can set it to `adoc-unichar-by-name'; however it requires
-unichars.el (http://nwalsh.com/emacs/xmlchars/unichars.el). When
-you set adoc-unichar-name-resolver to adoc-unichar-by-name, you
-need to call `adoc-calc' for the change to take effect."
+You can set it to `adoc-unichar-by-name' which uses the built-in
+`sgml-char-names' table. When you set adoc-unichar-name-resolver
+to adoc-unichar-by-name, you need to call `adoc-calc' for the
+change to take effect."
:type '(choice (const nil)
(const adoc-unichar-by-name)
function)
@@ -3416,23 +3416,18 @@ and title's text are not preserved, afterwards its
always one space."
(forward-line -1))
(move-to-column saved-col))))
-(defvar unicode-character-list) ;; From unichars.el
-
-(defun adoc-make-unichar-alist()
- "Creates `adoc-unichar-alist' from `unicode-character-list'"
- (unless (boundp 'unicode-character-list)
- (load "unichars"))
- (let ((i unicode-character-list))
- (setq adoc-unichar-alist nil)
- (while i
- (let ((name (nth 2 (car i)))
- (codepoint (nth 0 (car i))))
- (when name
- (push (cons name codepoint) adoc-unichar-alist))
- (setq i (cdr i))))))
+(defvar sgml-char-names)
+
+(defun adoc-make-unichar-alist ()
+ "Create `adoc-unichar-alist' from the built-in `sgml-char-names'."
+ (require 'sgml-mode)
+ (setq adoc-unichar-alist nil)
+ (dotimes (i (length sgml-char-names))
+ (when (aref sgml-char-names i)
+ (push (cons (aref sgml-char-names i) i) adoc-unichar-alist))))
(defun adoc-unichar-by-name (name)
- "Returns unicode codepoint of char with the given NAME"
+ "Return unicode codepoint of char with the given NAME."
(cdr (assoc name adoc-unichar-alist)))
(defun adoc-entity-to-string (entity)