├── .gitignore ├── .travis.yml ├── Makefile ├── README.markdown ├── ert-tests └── ucs-utils-test.el ├── ucs-utils-6.0-delta.el └── ucs-utils.el /.gitignore: -------------------------------------------------------------------------------- 1 | /ert-tests/ert.el 2 | /ert-tests/list-utils.el 3 | /ert-tests/pcache.el 4 | /ert-tests/persistent-soft.el 5 | /ert-tests/test_output/ 6 | *-autoloads.el 7 | *.elc 8 | *~ 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | ### 2 | ### Notes 3 | ### 4 | ### The travis web interface may choke silently and fail to 5 | ### update when there are issues with the .travis.yml file. 6 | ### 7 | ### The "travis-lint" command-line tool does not catch all 8 | ### errors which may lead to silent failure. 9 | ### 10 | ### Shell-style comments must have "#" as the first character 11 | ### of the line. 12 | ### 13 | 14 | ### 15 | ### language 16 | ### 17 | 18 | # travis-lint no longer permits this value 19 | # language: emacs-lisp 20 | language: ruby 21 | 22 | ### 23 | ### defining the build matrix 24 | ### 25 | ### ===> <=== 26 | ### ===> each variation in env/matrix will be built and tested <=== 27 | ### ===> <=== 28 | ### 29 | ### variables under env/global are available to the build process 30 | ### but don't cause the creation of a separate variation 31 | ### 32 | 33 | env: 34 | matrix: 35 | - EMACS=emacs22 36 | - EMACS=emacs23 37 | - EMACS=emacs24 38 | - EMACS=emacs-snapshot 39 | global: 40 | - SOME_TOKEN=some_value 41 | 42 | ### 43 | ### allowing failures 44 | ### 45 | 46 | matrix: 47 | allow_failures: 48 | - env: EMACS=emacs22 49 | - env: EMACS=emacs-snapshot 50 | 51 | ### 52 | ### limit build attempts to defined branches 53 | ### 54 | 55 | # branches: 56 | # only: 57 | # - master 58 | 59 | ### 60 | ### runtime initialization 61 | ### 62 | ### notes 63 | ### 64 | ### emacs22 is extracted manually from Ubuntu Maverick. 65 | ### 66 | ### emacs23 is the stock default, but is updated anyway to 67 | ### a GUI-capable version, which will have certain additional 68 | ### functions compiled in. 69 | ### 70 | ### emacs24 (current stable release) is obtained from the 71 | ### cassou PPA: http://launchpad.net/~cassou/+archive/emacs 72 | ### 73 | ### emacs-snapshot (trunk) is obtained from the Ubuntu Emacs Lisp PPA: 74 | ### https://launchpad.net/~ubuntu-elisp/+archive/ppa 75 | ### For the emacs-snapshot build, bleeding-edge versions 76 | ### of all test dependencies are also used. 77 | ### 78 | 79 | before_install: 80 | - git submodule --quiet update --init --recursive 81 | 82 | install: 83 | - if [ "$EMACS" = 'emacs22' ]; then 84 | curl -Os http://security.ubuntu.com/ubuntu/pool/universe/e/emacs22/emacs22_22.2-0ubuntu9_i386.deb && 85 | curl -Os http://security.ubuntu.com/ubuntu/pool/universe/e/emacs22/emacs22-bin-common_22.2-0ubuntu9_i386.deb && 86 | curl -Os http://security.ubuntu.com/ubuntu/pool/universe/e/emacs22/emacs22-common_22.2-0ubuntu9_all.deb && 87 | curl -Os http://security.ubuntu.com/ubuntu/pool/universe/e/emacs22/emacs22-el_22.2-0ubuntu9_all.deb && 88 | curl -Os http://security.ubuntu.com/ubuntu/pool/universe/e/emacs22/emacs22-gtk_22.2-0ubuntu9_i386.deb && 89 | sudo apt-get -qq update && 90 | sudo apt-get -qq remove emacs emacs23-bin-common emacs23-common emacs23-nox && 91 | sudo apt-get -qq --fix-missing install install-info emacsen-common libjpeg62:i386 xaw3dg:i386 liblockfile1:i386 libasound2:i386 libgif4:i386 libncurses5:i386 libpng12-0:i386 libtiff4:i386 libxpm4:i386 libxft2:i386 libglib2.0-0:i386 libgtk2.0-0:i386 && 92 | sudo apt-get -qq -f install && 93 | sudo dpkg -i emacs22-common_22.2-0ubuntu9_all.deb emacs22-el_22.2-0ubuntu9_all.deb && 94 | sudo dpkg -i --force-depends emacs22-bin-common_22.2-0ubuntu9_i386.deb && 95 | sudo dpkg -i emacs22_22.2-0ubuntu9_i386.deb emacs22-gtk_22.2-0ubuntu9_i386.deb && 96 | sudo update-alternatives --set emacs22 /usr/bin/emacs22-gtk; 97 | fi 98 | - if [ "$EMACS" = 'emacs23' ]; then 99 | sudo apt-get -qq update && 100 | sudo apt-get -qq -f install && 101 | sudo apt-get -qq install emacs23-gtk emacs23-el; 102 | fi 103 | - if [ "$EMACS" = 'emacs24' ]; then 104 | sudo add-apt-repository -y ppa:cassou/emacs && 105 | sudo apt-get -qq update && 106 | sudo apt-get -qq -f install && 107 | sudo apt-get -qq install emacs24 emacs24-el; 108 | fi 109 | - if [ "$EMACS" = 'emacs-snapshot' ]; then 110 | sudo add-apt-repository -y ppa:ubuntu-elisp/ppa && 111 | sudo apt-get -qq update && 112 | sudo apt-get -qq -f install && 113 | sudo apt-get -qq install emacs-snapshot && 114 | sudo apt-get -qq install emacs-snapshot-el; 115 | fi 116 | 117 | before_script: 118 | - if [ "$EMACS" = 'emacs-snapshot' ]; then 119 | make downloads-latest; 120 | else 121 | make downloads; 122 | fi 123 | 124 | ### 125 | ### the actual build/test command 126 | ### 127 | 128 | script: 129 | $EMACS --version && ( test "$EMACS" != "emacs22" && make test EMACS="$EMACS" || make test-batch EMACS="$EMACS" ) 130 | 131 | ### 132 | ### settings 133 | ### 134 | 135 | notifications: 136 | email: false 137 | 138 | # 139 | # Emacs 140 | # 141 | # Local Variables: 142 | # indent-tabs-mode: nil 143 | # mangle-whitespace: t 144 | # require-final-newline: t 145 | # coding: utf-8 146 | # End: 147 | # 148 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EMACS=emacs 2 | # EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs 3 | # EMACS=/Applications/Emacs23.app/Contents/MacOS/Emacs 4 | # EMACS=/Applications/Aquamacs.app/Contents/MacOS/Aquamacs 5 | # EMACS=/Applications/Macmacs.app/Contents/MacOS/Emacs 6 | # EMACS=/usr/local/bin/emacs 7 | # EMACS=/opt/local/bin/emacs 8 | # EMACS=/usr/bin/emacs 9 | 10 | INTERACTIVE_EMACS=/usr/local/bin/emacs 11 | # can't find an OS X variant that works correctly for interactive tests: 12 | # INTERACTIVE_EMACS=open -a Emacs.app --new --args 13 | # INTERACTIVE_EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs 14 | # INTERACTIVE_EMACS=/Applications/Emacs.app/Contents/MacOS/bin/emacs 15 | 16 | RESOLVED_EMACS=$(shell readlink `which $(EMACS)` || echo "$(EMACS)") 17 | RESOLVED_INTERACTIVE_EMACS=$(shell readlink `which "$(INTERACTIVE_EMACS)"` || echo "$(INTERACTIVE_EMACS)") 18 | 19 | EMACS_CLEAN=-Q 20 | EMACS_BATCH=$(EMACS_CLEAN) --batch 21 | # TESTS can be overridden to specify a subset of tests 22 | TESTS= 23 | WIKI_USERNAME=roland.walker 24 | 25 | CURL=curl --location --silent 26 | EDITOR=runemacs -no_wait 27 | WORK_DIR=$(shell pwd) 28 | PACKAGE_NAME=$(shell basename $(WORK_DIR)) 29 | PACKAGE_VERSION=$(shell perl -ne 'print "$$1\n" if m{^;+ *Version: *(\S+)}' $(PACKAGE_NAME).el) 30 | AUTOLOADS_FILE=$(PACKAGE_NAME)-autoloads.el 31 | TRAVIS_FILE=.travis.yml 32 | TEST_DIR=ert-tests 33 | TEST_DATADIR=test_output 34 | TEST_DEP_1=ert 35 | TEST_DEP_1_STABLE_URL=http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/ert.el?h=emacs-24.3 36 | TEST_DEP_1_LATEST_URL=http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/ert.el?h=master 37 | TEST_DEP_2=pcache 38 | TEST_DEP_2_STABLE_URL=https://raw.githubusercontent.com/sigma/pcache/fa8f863546e2e8f2fc0a70f5cc766a7f584e01b6/pcache.el 39 | TEST_DEP_2_LATEST_URL=https://raw.githubusercontent.com/sigma/pcache/master/pcache.el 40 | TEST_DEP_3=list-utils 41 | TEST_DEP_3_STABLE_URL=https://raw.githubusercontent.com/rolandwalker/list-utils/ecd6c91c71e37734af9ff4df003cb96b9d236a97/list-utils.el 42 | TEST_DEP_3_LATEST_URL=https://raw.githubusercontent.com/rolandwalker/list-utils/master/list-utils.el 43 | TEST_DEP_4=persistent-soft 44 | TEST_DEP_4_STABLE_URL=https://raw.githubusercontent.com/rolandwalker/persistent-soft/3529e1c0264326ec9a5ab9e1ed35037012e7fbd6/persistent-soft.el 45 | TEST_DEP_4_LATEST_URL=https://raw.githubusercontent.com/rolandwalker/persistent-soft/master/persistent-soft.el 46 | 47 | .PHONY : build dist not-dirty pkg-version downloads downloads-latest autoloads \ 48 | test-autoloads test-travis test test-prep test-batch test-interactive \ 49 | test-tests clean edit run-pristine run-pristine-local upload-github \ 50 | upload-wiki upload-marmalade test-dep-1 test-dep-2 test-dep-3 test-dep-4 \ 51 | test-dep-5 test-dep-6 test-dep-7 test-dep-8 test-dep-9 52 | 53 | build : 54 | $(RESOLVED_EMACS) $(EMACS_BATCH) --eval \ 55 | "(progn \ 56 | (setq byte-compile-error-on-warn t) \ 57 | (batch-byte-compile))" *.el 58 | 59 | not-dirty : 60 | @git diff --quiet '$(PACKAGE_NAME).el' || \ 61 | ( git --no-pager diff '$(PACKAGE_NAME).el'; \ 62 | echo "Uncommitted edits - do a git stash"; \ 63 | false ) 64 | 65 | pkg-version : 66 | @test -n '$(PACKAGE_VERSION)' || \ 67 | ( echo "No package version"; false ) 68 | 69 | test-dep-1 : 70 | @cd '$(TEST_DIR)' && \ 71 | $(RESOLVED_EMACS) $(EMACS_BATCH) -L . -L .. -l '$(TEST_DEP_1)' || \ 72 | (echo "Can't load test dependency $(TEST_DEP_1).el, run 'make downloads' to fetch it" ; exit 1) 73 | 74 | test-dep-2 : 75 | @cd '$(TEST_DIR)' && \ 76 | $(RESOLVED_EMACS) $(EMACS_BATCH) -L . -L .. --eval \ 77 | "(progn \ 78 | (setq package-load-list '(($(TEST_DEP_2) t))) \ 79 | (when (fboundp 'package-initialize) \ 80 | (package-initialize)) \ 81 | (require '$(TEST_DEP_2)))" || \ 82 | (echo "Can't load test dependency $(TEST_DEP_2).el, run 'make downloads' to fetch it" ; exit 1) 83 | 84 | test-dep-3 : 85 | @cd '$(TEST_DIR)' && \ 86 | $(RESOLVED_EMACS) $(EMACS_BATCH) -L . -L .. --eval \ 87 | "(progn \ 88 | (setq package-load-list '(($(TEST_DEP_3) t))) \ 89 | (when (fboundp 'package-initialize) \ 90 | (package-initialize)) \ 91 | (require '$(TEST_DEP_3)))" || \ 92 | (echo "Can't load test dependency $(TEST_DEP_3).el, run 'make downloads' to fetch it" ; exit 1) 93 | 94 | test-dep-4 : 95 | @cd '$(TEST_DIR)' && \ 96 | $(RESOLVED_EMACS) $(EMACS_BATCH) -L . -L .. --eval \ 97 | "(progn \ 98 | (setq package-load-list '(($(TEST_DEP_2) t) \ 99 | ($(TEST_DEP_3) t) \ 100 | ($(TEST_DEP_4) t))) \ 101 | (when (fboundp 'package-initialize) \ 102 | (package-initialize)) \ 103 | (require '$(TEST_DEP_4)))" || \ 104 | (echo "Can't load test dependency $(TEST_DEP_4).el, run 'make downloads' to fetch it" ; exit 1) 105 | 106 | downloads : 107 | $(CURL) '$(TEST_DEP_1_STABLE_URL)' > '$(TEST_DIR)/$(TEST_DEP_1).el' 108 | $(CURL) '$(TEST_DEP_2_STABLE_URL)' > '$(TEST_DIR)/$(TEST_DEP_2).el' 109 | $(CURL) '$(TEST_DEP_3_STABLE_URL)' > '$(TEST_DIR)/$(TEST_DEP_3).el' 110 | $(CURL) '$(TEST_DEP_4_STABLE_URL)' > '$(TEST_DIR)/$(TEST_DEP_4).el' 111 | 112 | downloads-latest : 113 | $(CURL) '$(TEST_DEP_1_LATEST_URL)' > '$(TEST_DIR)/$(TEST_DEP_1).el' 114 | $(CURL) '$(TEST_DEP_2_LATEST_URL)' > '$(TEST_DIR)/$(TEST_DEP_2).el' 115 | $(CURL) '$(TEST_DEP_3_LATEST_URL)' > '$(TEST_DIR)/$(TEST_DEP_3).el' 116 | $(CURL) '$(TEST_DEP_4_LATEST_URL)' > '$(TEST_DIR)/$(TEST_DEP_4).el' 117 | 118 | autoloads : 119 | $(RESOLVED_EMACS) $(EMACS_BATCH) --eval \ 120 | "(progn \ 121 | (setq generated-autoload-file \"$(WORK_DIR)/$(AUTOLOADS_FILE)\") \ 122 | (update-directory-autoloads \"$(WORK_DIR)\"))" 123 | 124 | test-autoloads : autoloads 125 | @$(RESOLVED_EMACS) $(EMACS_BATCH) -L . -l './$(AUTOLOADS_FILE)' || \ 126 | ( echo "failed to load autoloads: $(AUTOLOADS_FILE)" && false ) 127 | 128 | test-travis : 129 | @if test -z "$$TRAVIS" && test -e '$(TRAVIS_FILE)'; then travis-lint '$(TRAVIS_FILE)'; fi 130 | 131 | test-tests : 132 | @perl -ne 'if (m/^\s*\(\s*ert-deftest\s*(\S+)/) {die "$$1 test name duplicated in $$ARGV\n" if $$dupes{$$1}++}' '$(TEST_DIR)/'*-test.el 133 | 134 | test-prep : build test-dep-1 test-dep-2 test-dep-3 test-dep-4 test-autoloads test-travis test-tests 135 | 136 | test-batch : 137 | @cd '$(TEST_DIR)' && \ 138 | (for test_lib in *-test.el; do \ 139 | $(RESOLVED_EMACS) $(EMACS_BATCH) -L . -L .. -l cl \ 140 | -l '$(TEST_DEP_1)' -l "$$test_lib" --eval \ 141 | "(progn \ 142 | (fset 'ert--print-backtrace 'ignore) \ 143 | (ert-run-tests-batch-and-exit '(and \"$(TESTS)\" (not (tag :interactive)))))" || exit 1; \ 144 | done) 145 | 146 | test-interactive : test-prep 147 | @cd '$(TEST_DIR)' && \ 148 | (for test_lib in *-test.el; do \ 149 | $(RESOLVED_INTERACTIVE_EMACS) $(EMACS_CLEAN) --eval \ 150 | "(progn \ 151 | (cd \"$(WORK_DIR)/$(TEST_DIR)\") \ 152 | (setq dired-use-ls-dired nil) \ 153 | (setq frame-title-format \"TEST SESSION $$test_lib\") \ 154 | (setq enable-local-variables :safe))" \ 155 | -L . -L .. -l cl -l '$(TEST_DEP_1)' -l "$$test_lib" \ 156 | --visit "$$test_lib" --eval \ 157 | "(progn \ 158 | (when (> (length \"$(TESTS)\") 0) \ 159 | (push \"\\\"$(TESTS)\\\"\" ert--selector-history)) \ 160 | (setq buffer-read-only t) \ 161 | (setq cursor-in-echo-area t) \ 162 | (call-interactively 'ert-run-tests-interactively) \ 163 | (ding) \ 164 | (when (y-or-n-p \"PRESS Y TO QUIT THIS TEST SESSION\") \ 165 | (with-current-buffer \"*ert*\" \ 166 | (kill-emacs \ 167 | (if (re-search-forward \"^Failed:[^\\n]+unexpected\" 500 t) 1 0)))))" || exit 1; \ 168 | done) 169 | 170 | test : test-prep test-batch 171 | 172 | run-pristine : 173 | @cd '$(TEST_DIR)' && \ 174 | $(RESOLVED_EMACS) $(EMACS_CLEAN) --eval \ 175 | "(progn \ 176 | (setq package-enable-at-startup nil) \ 177 | (setq package-load-list '(($(TEST_DEP_2) t) \ 178 | ($(TEST_DEP_3) t))) \ 179 | (when (fboundp 'package-initialize) \ 180 | (package-initialize)) \ 181 | (cd \"$(WORK_DIR)/$(TEST_DIR)\") \ 182 | (setq dired-use-ls-dired nil) \ 183 | (setq frame-title-format \"PRISTINE SESSION $(PACKAGE_NAME)\") \ 184 | (setq enable-local-variables :safe))" \ 185 | -L .. -l '$(PACKAGE_NAME)' . 186 | 187 | run-pristine-local : 188 | @cd '$(TEST_DIR)' && \ 189 | $(RESOLVED_EMACS) $(EMACS_CLEAN) --eval \ 190 | "(progn \ 191 | (cd \"$(WORK_DIR)/$(TEST_DIR)\") \ 192 | (setq dired-use-ls-dired nil) \ 193 | (setq frame-title-format \"PRISTINE-LOCAL SESSION $(PACKAGE_NAME)\") \ 194 | (setq enable-local-variables :safe))" \ 195 | -L . -L .. -l '$(PACKAGE_NAME)' . 196 | 197 | clean : 198 | @rm -f '$(AUTOLOADS_FILE)' *.elc *~ */*.elc */*~ .DS_Store */.DS_Store *.bak */*.bak && \ 199 | cd '$(TEST_DIR)' && \ 200 | rm -f './$(TEST_DEP_1).el' './$(TEST_DEP_2).el' './$(TEST_DEP_3).el' './$(TEST_DEP_4).el' './$(TEST_DEP_5a).el' \ 201 | './$(TEST_DEP_5).el' './$(TEST_DEP_6).el' './$(TEST_DEP_7).el' './$(TEST_DEP_8).el' './$(TEST_DEP_9).el' && \ 202 | if test -n '$(TEST_DATADIR)'; then rm -rf './$(TEST_DATADIR)'; fi 203 | 204 | edit : 205 | @$(EDITOR) `git ls-files` 206 | 207 | upload-github : 208 | @git push origin master 209 | 210 | upload-marmalade : 211 | @marmalade-upload roland.walker '$(PACKAGE_NAME).el' 212 | 213 | upload-wiki : not-dirty 214 | @$(RESOLVED_EMACS) $(EMACS_BATCH) --eval \ 215 | "(progn \ 216 | (setq package-load-list '((yaoddmuse t))) \ 217 | (when (fboundp 'package-initialize) \ 218 | (package-initialize)) \ 219 | (require 'yaoddmuse) \ 220 | (setq yaoddmuse-username \"$(WIKI_USERNAME)\") \ 221 | (yaoddmuse-post-file \ 222 | \"$(PACKAGE_NAME).el\" \ 223 | yaoddmuse-default-wiki \ 224 | \"$(PACKAGE_NAME).el\" \ 225 | \"updated version\") \ 226 | (sleep-for 5))" 227 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://secure.travis-ci.org/rolandwalker/ucs-utils.png?branch=master)](http://travis-ci.org/rolandwalker/ucs-utils) 2 | 3 | # Overview 4 | 5 | Utilities for Unicode characters in Emacs. 6 | 7 | * [Quickstart](#quickstart) 8 | * [Explanation](#explanation) 9 | * [See Also](#see-also) 10 | * [Compatibility and Requirements](#compatibility-and-requirements) 11 | 12 | ## Quickstart 13 | 14 | ```elisp 15 | (require 'ucs-utils) 16 | 17 | (ucs-utils-char "Middle Dot" ; character to return 18 | ?. ; fallback if unavailable 19 | 'char-displayable-p) ; test for character to pass 20 | 21 | (ucs-utils-first-existing-char '("White Bullet" 22 | "Bullet Operator" 23 | "Circled Bullet" 24 | "Middle Dot" 25 | ?.) 'cdp) 26 | 27 | (ucs-utils-string "Horizontal Ellipsis" '[["..."]]) 28 | ``` 29 | 30 | ## Explanation 31 | 32 | This library provides utilities for manipulating Unicode 33 | characters, with integrated ability to return fallback characters 34 | when Unicode display is not possible. 35 | 36 | Some ambiguities in Emacs' built-in Unicode data are resolved, and 37 | character support is updated to Unicode 7.0. 38 | 39 | There are three interactive commands: 40 | 41 | ucs-utils-ucs-insert ; ucs-insert workalike using ido-completing-read 42 | ucs-utils-eval ; the inverse of ucs-insert 43 | ucs-utils-install-aliases ; install shorter aliases 44 | 45 | The other functions are only useful from other Lisp code: 46 | 47 | ucs-utils-char 48 | ucs-utils-first-existing-char 49 | ucs-utils-vector 50 | ucs-utils-string 51 | ucs-utils-intact-string 52 | ucs-utils-pretty-name 53 | ucs-utils-read-char-by-name 54 | ucs-utils-subst-char-in-region 55 | 56 | ## See Also 57 | 58 | * M-x customize-group RET ucs-utils RET 59 | 60 | 61 | 62 | ## Compatibility and Requirements 63 | 64 | GNU Emacs version 25.1-devel : not tested 65 | GNU Emacs version 24.5 : not tested 66 | GNU Emacs version 24.4 : yes 67 | GNU Emacs version 24.3 : yes 68 | GNU Emacs version 23.3 : yes (*) 69 | GNU Emacs version 22.3 and lower : no 70 | 71 | (*) For full Emacs 23.x support, the library [ucs-utils-6.0-delta.el](http://github.com/rolandwalker/ucs-utils/blob/master/ucs-utils-6.0-delta.el) should also be installed. 72 | 73 | Uses if present: [persistent-soft.el](http://github.com/rolandwalker/persistent-soft) (Recommended) 74 | -------------------------------------------------------------------------------- /ert-tests/ucs-utils-test.el: -------------------------------------------------------------------------------- 1 | 2 | ;; requires and setup 3 | 4 | (when load-file-name 5 | (setq pcache-directory (expand-file-name "test_output/" (file-name-directory load-file-name))) 6 | (setq package-enable-at-startup nil) 7 | (setq package-load-list '((pcache t) 8 | (list-utils t) 9 | (persistent-soft t))) 10 | (when (fboundp 'package-initialize) 11 | (package-initialize))) 12 | 13 | (require 'list-utils) 14 | (require 'persistent-soft) 15 | (require 'ucs-utils) 16 | 17 | ;;; external libraries 18 | 19 | (ert-deftest external-libraries-01 nil 20 | (should 21 | (featurep 'persistent-soft))) 22 | 23 | (ert-deftest external-libraries-02 nil 24 | (should 25 | (featurep 'pcache))) 26 | 27 | 28 | ;;; ucs-utils--lookup 29 | 30 | (ert-deftest ucs-utils--lookup-01 nil 31 | (should (eq (decode-char 'ucs #xB7) 32 | (ucs-utils--lookup "MIDDLE DOT")))) 33 | 34 | (ert-deftest ucs-utils--lookup-02 nil 35 | (should (eq (decode-char 'ucs #xB7) 36 | (ucs-utils--lookup "Middle Dot")))) 37 | 38 | (ert-deftest ucs-utils--lookup-03 nil 39 | (should (eq (decode-char 'ucs #xB7) 40 | (ucs-utils--lookup " Middle Dot ")))) 41 | 42 | (ert-deftest ucs-utils--lookup-04 nil 43 | (should-not 44 | (ucs-utils--lookup "Nonexistent Character"))) 45 | 46 | (ert-deftest ucs-utils--lookup-05 nil 47 | (should (eq (decode-char 'ucs #x3408) 48 | (ucs-utils--lookup "CJK Ideograph 3408")))) 49 | 50 | (ert-deftest ucs-utils--lookup-06 nil 51 | (should-not 52 | (ucs-utils--lookup "CJK Compatibility Ideograph-FA6E"))) 53 | 54 | 55 | ;;; ucs-utils-char 56 | 57 | (ert-deftest ucs-utils-char-01 nil 58 | (should (eq (decode-char 'ucs #xB7) 59 | (ucs-utils-char (decode-char 'ucs #xB7))))) 60 | 61 | (ert-deftest ucs-utils-char-02 nil 62 | (should (eq (decode-char 'ucs #xB7) 63 | (ucs-utils-char "Middle Dot")))) 64 | 65 | (ert-deftest ucs-utils-char-03 nil 66 | (should (eq (decode-char 'ucs #xB7) 67 | (ucs-utils-char "Middle Dot" ?.)))) 68 | 69 | (ert-deftest ucs-utils-char-04 nil 70 | (should (eq ?. 71 | (ucs-utils-char "Nonexistent Character" ?.)))) 72 | 73 | (ert-deftest ucs-utils-char-05 nil 74 | (should (eq (decode-char 'ucs #xB7) 75 | (ucs-utils-char "Middle Dot" ?. 'identity)))) 76 | 77 | (ert-deftest ucs-utils-char-06 nil 78 | (should (eq ?. 79 | (ucs-utils-char "Middle Dot" ?. 'ignore)))) 80 | 81 | ;; ambiguity in ucs-names 82 | (ert-deftest ucs-utils-char-07 nil 83 | (should (eq (decode-char 'ucs #x021C) 84 | (ucs-utils-char "Latin Capital Letter Yogh")))) 85 | 86 | ;; new in Unicode 6.0 (covered in ucs-utils-6.0-delta.el) 87 | (ert-deftest ucs-utils-char-08 nil 88 | (should (eq (decode-char 'ucs #x0841) 89 | (ucs-utils-char "Mandaic Letter Ab")))) 90 | 91 | ;; new in Unicode 6.1 (covered in ucs-utils-names-corrections) 92 | (ert-deftest ucs-utils-char-09 nil 93 | (should (eq (decode-char 'ucs #x1F600) 94 | (ucs-utils-char "Grinning Face")))) 95 | 96 | ;; new in Unicode 6.1 97 | (ert-deftest ucs-utils-char-10 nil 98 | (should (eq (decode-char 'ucs #xA7AA) 99 | (ucs-utils-char "Latin Capital Letter H with Hook")))) 100 | 101 | ;; plane 1 unicode-smp, new in Unicode 6.0 102 | (ert-deftest ucs-utils-char-11 nil 103 | (should (eq (decode-char 'ucs #x1F624) 104 | (ucs-utils-char "Face with Look of Triumph")))) 105 | 106 | ;; plane 14 unicode-ssp 107 | (ert-deftest ucs-utils-char-12 nil 108 | (should (eq (decode-char 'ucs #xE0154) 109 | (ucs-utils-char "Variation Selector-101")))) 110 | 111 | ;; new in Unicode 6.2 (covered in ucs-utils-names-corrections) 112 | (ert-deftest ucs-utils-char-13 nil 113 | (should (eq (decode-char 'ucs #x20BA) 114 | (ucs-utils-char "Turkish Lira Sign")))) 115 | 116 | ;; new in Unicode 6.3 (covered in ucs-utils-names-corrections) 117 | (ert-deftest ucs-utils-char-14 nil 118 | (should (eq (decode-char 'ucs #x2066) 119 | (ucs-utils-char "Left-to-Right Isolate")))) 120 | 121 | ;; large integer is not a character 122 | (ert-deftest ucs-utils-char-15 nil 123 | (should-not (ucs-utils-char 35252544))) 124 | 125 | ;; not covered by `ucs-names' 126 | (ert-deftest ucs-utils-char-16 nil 127 | (should (eq (decode-char 'ucs #x3408) 128 | (ucs-utils-char "CJK Ideograph 3408")))) 129 | 130 | ;; compensate for Emacs bug 131 | (ert-deftest ucs-utils-char-17 nil 132 | (should-not 133 | (ucs-utils-char "CJK Compatibility Ideograph-FA6E"))) 134 | 135 | ;;; ucs-utils-vector-flatten 136 | 137 | (ert-deftest ucs-utils-vector-flatten-01 nil 138 | (should (equal '[1 2 3] 139 | (ucs-utils-vector-flatten '[1 2 3])))) 140 | 141 | (ert-deftest ucs-utils-vector-flatten-02 nil 142 | (should (equal '[1 2 3 4 5 6 7] 143 | (ucs-utils-vector-flatten '[1 2 [3 4 5] 6 7])))) 144 | 145 | (ert-deftest ucs-utils-vector-flatten-03 nil 146 | (should (equal '[1 2 3 4 5 6 7] 147 | (ucs-utils-vector-flatten '[1 2 [3 4 5 [6 7]]])))) 148 | 149 | (ert-deftest ucs-utils-vector-flatten-04 nil 150 | (should (equal '[1 2 51 52 53] 151 | (ucs-utils-vector-flatten '[1 2 "345"])))) 152 | 153 | (ert-deftest ucs-utils-vector-flatten-05 nil 154 | (should (equal '[1 2 (3 4 5) 6 7] 155 | (ucs-utils-vector-flatten '[1 2 (3 4 5) 6 7])))) 156 | 157 | 158 | ;;; ucs-utils-prettify-ucs-string 159 | 160 | (ert-deftest ucs-utils-prettify-ucs-string-01 nil 161 | (should (equal "Face with Look of Triumph" 162 | (ucs-utils-prettify-ucs-string "FACE WITH LOOK OF TRIUMPH")))) 163 | 164 | (ert-deftest ucs-utils-prettify-ucs-string-02 nil 165 | (should (equal "Fleur-de-Lis" 166 | (ucs-utils-prettify-ucs-string "FLEUR-DE-LIS")))) 167 | 168 | (ert-deftest ucs-utils-prettify-ucs-string-03 nil 169 | (should (equal "Logical AND" 170 | (ucs-utils-prettify-ucs-string "LOGICAL AND")))) 171 | 172 | (ert-deftest ucs-utils-prettify-ucs-string-04 nil 173 | (should (equal "Logical AND with Dot Above" 174 | (ucs-utils-prettify-ucs-string "LOGICAL AND WITH DOT ABOVE")))) 175 | 176 | (ert-deftest ucs-utils-prettify-ucs-string-05 nil 177 | (should (equal "Six-per-Em Space" 178 | (ucs-utils-prettify-ucs-string "SIX-PER-EM SPACE")))) 179 | 180 | (ert-deftest ucs-utils-prettify-ucs-string-06 nil 181 | (should (equal "CJK Stroke P" 182 | (ucs-utils-prettify-ucs-string "CJK STROKE P")))) 183 | 184 | 185 | ;;; ucs-utils-pretty-name 186 | 187 | (ert-deftest ucs-utils-pretty-name-01 nil 188 | (should (equal "Middle Dot" 189 | (ucs-utils-pretty-name (decode-char 'ucs #xB7))))) 190 | 191 | ;; new in Unicode 6.0 192 | (ert-deftest ucs-utils-pretty-name-02 nil 193 | (should (equal "Pensive Face" 194 | (ucs-utils-pretty-name (decode-char 'ucs #x1F614))))) 195 | 196 | (ert-deftest ucs-utils-pretty-name-03 nil 197 | (should (equal "#xF0000" 198 | (ucs-utils-pretty-name (decode-char 'ucs #xf0000))))) 199 | 200 | (ert-deftest ucs-utils-pretty-name-04 nil 201 | (should-not 202 | (ucs-utils-pretty-name (decode-char 'ucs #xF0000) 'no-hex))) 203 | 204 | ;; new in Unicode 6.2 205 | (ert-deftest ucs-utils-pretty-name-05 nil 206 | (should (equal "Turkish Lira Sign" 207 | (ucs-utils-pretty-name (decode-char 'ucs #x20BA))))) 208 | 209 | ;; new in Unicode 6.3 210 | (ert-deftest ucs-utils-pretty-name-06 nil 211 | (should (equal "Left-to-Right Isolate" 212 | (ucs-utils-pretty-name (decode-char 'ucs #x2066))))) 213 | 214 | ;; large integer is not a character 215 | (ert-deftest ucs-utils-pretty-name-07 nil 216 | (should-not (ucs-utils-pretty-name 35252544))) 217 | 218 | 219 | ;;; ucs-utils-all-prettified-names 220 | 221 | (ert-deftest ucs-utils-all-prettified-names-01 nil 222 | (should 223 | (> (length (ucs-utils-all-prettified-names)) 30000))) 224 | 225 | (ert-deftest ucs-utils-all-prettified-names-02 nil 226 | (should 227 | (> (length (ucs-utils-all-prettified-names t t)) 30000))) 228 | 229 | (ert-deftest ucs-utils-all-prettified-names-03 nil 230 | (should 231 | (> (length (member "Middle_Dot" (ucs-utils-all-prettified-names))) 0))) 232 | 233 | 234 | ;;; ucs-utils-first-existing-char 235 | 236 | (ert-deftest ucs-utils-first-existing-char-01 nil 237 | (should (eq (decode-char 'ucs #xB7) 238 | (ucs-utils-first-existing-char '("Nonexistent Character 1" "Nonexistent Character 2" "Middle Dot"))))) 239 | 240 | (ert-deftest ucs-utils-first-existing-char-02 nil 241 | (should (eq ?. 242 | (ucs-utils-first-existing-char '("Nonexistent Character 1" "Nonexistent Character 2" ?.))))) 243 | 244 | 245 | ;;; ucs-utils-vector 246 | 247 | (ert-deftest ucs-utils-vector-01 nil 248 | (should (equal '[?.] 249 | (ucs-utils-vector ?.)))) 250 | 251 | (ert-deftest ucs-utils-vector-02 nil 252 | (should (equal '[#xB7] 253 | (ucs-utils-vector "Middle Dot")))) 254 | 255 | (ert-deftest ucs-utils-vector-03 nil 256 | (should (equal '[#xB7] 257 | (ucs-utils-vector '("Middle Dot"))))) 258 | 259 | (ert-deftest ucs-utils-vector-04 nil 260 | (should (equal '[#xB7 ?a ?b] 261 | (ucs-utils-vector '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 262 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E"))))) 263 | 264 | (ert-deftest ucs-utils-vector-05 nil 265 | (should (equal '[#xB7 ?a ?b] 266 | (ucs-utils-vector '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 267 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E") 'identity)))) 268 | 269 | (ert-deftest ucs-utils-vector-06 nil 270 | (should (equal '[?c ?d ?e] 271 | (ucs-utils-vector '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 272 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E") 'ignore)))) 273 | 274 | (ert-deftest ucs-utils-vector-07 nil 275 | (should (equal '[#xB7 ?d ?b] 276 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 277 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E"))))) 278 | 279 | (ert-deftest ucs-utils-vector-08 nil 280 | (should (equal '[#xB7 nil ?b] 281 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 282 | nil)))) 283 | 284 | (ert-deftest ucs-utils-vector-09 nil 285 | (should (equal '[#xB7 ?b] 286 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 287 | 'drop)))) 288 | 289 | (ert-deftest ucs-utils-vector-10 nil 290 | (should-error 291 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 292 | 'error))) 293 | 294 | (ert-deftest ucs-utils-vector-11 nil 295 | (should (equal '[#xB7 ?. ?. ?. ?b] 296 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 297 | '["Latin Small Letter C" ["..."] "Latin Small Letter E"])))) 298 | 299 | (ert-deftest ucs-utils-vector-12 nil 300 | (should (equal '[#xB7 ["..."] ?b] 301 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 302 | '["Latin Small Letter C" ["..."] "Latin Small Letter E"] nil 'no-flatten)))) 303 | 304 | (ert-deftest ucs-utils-vector-13 nil 305 | (should (equal '[#xB7 nil ?b] 306 | (ucs-utils-vector '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 307 | '["Latin Small Letter C" [nil] "Latin Small Letter E"])))) 308 | 309 | 310 | ;;; ucs-utils-string 311 | 312 | (ert-deftest ucs-utils-string-01 nil 313 | (should (equal "." 314 | (ucs-utils-string ?.)))) 315 | 316 | (ert-deftest ucs-utils-string-02 nil 317 | (should (equal "·" 318 | (ucs-utils-string "Middle Dot")))) 319 | 320 | (ert-deftest ucs-utils-string-03 nil 321 | (should (equal "·" 322 | (ucs-utils-string '("Middle Dot"))))) 323 | 324 | (ert-deftest ucs-utils-string-04 nil 325 | (should (equal "·ab" 326 | (ucs-utils-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 327 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E"))))) 328 | 329 | (ert-deftest ucs-utils-string-05 nil 330 | (should (equal "·ab" 331 | (ucs-utils-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 332 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E") 'identity)))) 333 | 334 | (ert-deftest ucs-utils-string-06 nil 335 | (should (equal "cde" 336 | (ucs-utils-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 337 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E") 'ignore)))) 338 | 339 | (ert-deftest ucs-utils-string-07 nil 340 | (should (equal "·db" 341 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 342 | '("Latin Small Letter C" "Latin Small Letter D" "Latin Small Letter E"))))) 343 | 344 | (ert-deftest ucs-utils-string-08 nil 345 | (should (equal "·b" 346 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 347 | nil)))) 348 | 349 | (ert-deftest ucs-utils-string-09 nil 350 | (should (equal "·b" 351 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 352 | 'drop)))) 353 | 354 | (ert-deftest ucs-utils-string-10 nil 355 | (should-error 356 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 357 | 'error))) 358 | 359 | (ert-deftest ucs-utils-string-11 nil 360 | (should (equal "·...b" 361 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 362 | '["Latin Small Letter C" ["..."] "Latin Small Letter E"])))) 363 | 364 | (ert-deftest ucs-utils-string-12 nil 365 | (should (equal "·b" 366 | (ucs-utils-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 367 | '["Latin Small Letter C" [nil] "Latin Small Letter E"])))) 368 | 369 | 370 | ;;; ucs-utils-intact-string 371 | 372 | (ert-deftest ucs-utils-intact-string-01 nil 373 | (should (equal "." 374 | (ucs-utils-intact-string ?. "F")))) 375 | 376 | (ert-deftest ucs-utils-intact-string-02 nil 377 | (should (equal "·" 378 | (ucs-utils-intact-string "Middle Dot" ".")))) 379 | 380 | (ert-deftest ucs-utils-intact-string-03 nil 381 | (should (equal "·" 382 | (ucs-utils-intact-string '("Middle Dot") ".")))) 383 | 384 | (ert-deftest ucs-utils-intact-string-04 nil 385 | (should (equal "·ab" 386 | (ucs-utils-intact-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 387 | "cde")))) 388 | 389 | (ert-deftest ucs-utils-intact-string-05 nil 390 | (should (equal "·ab" 391 | (ucs-utils-intact-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 392 | "cde")))) 393 | 394 | (ert-deftest ucs-utils-intact-string-06 nil 395 | (should (equal "·ab" 396 | (ucs-utils-intact-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 397 | "cde" 'identity)))) 398 | 399 | (ert-deftest ucs-utils-intact-string-07 nil 400 | (should (equal "cde" 401 | (ucs-utils-intact-string '("Middle Dot" "Latin Small Letter A" "Latin Small Letter B") 402 | "cde" 'ignore)))) 403 | 404 | (ert-deftest ucs-utils-intact-string-08 nil 405 | (should (equal "cde" 406 | (ucs-utils-intact-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 407 | "cde")))) 408 | 409 | (ert-deftest ucs-utils-intact-string-09 nil 410 | (should (equal "c...e" 411 | (ucs-utils-intact-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 412 | "c...e")))) 413 | 414 | (ert-deftest ucs-utils-intact-string-10 nil 415 | (should (equal "cde" 416 | (ucs-utils-intact-string '("Middle Dot" "Nonexistent Character" "Latin Small Letter B") 417 | "cde")))) 418 | 419 | 420 | ;;; ucs-utils-subst-char-in-region 421 | 422 | (ert-deftest ucs-utils-subst-char-in-region-01 nil 423 | (should (equal "testing..." 424 | (with-temp-buffer 425 | (goto-char (point-min)) 426 | (insert "testing···\n") 427 | (goto-char (point-min)) 428 | (ucs-utils-subst-char-in-region (point-min) (line-end-position) (ucs-utils-char "Middle Dot") ?.) 429 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 430 | 431 | (ert-deftest ucs-utils-subst-char-in-region-02 nil 432 | (should (equal "testing..." 433 | (with-temp-buffer 434 | (goto-char (point-min)) 435 | (insert "testing···\n") 436 | (goto-char (point-min)) 437 | (ucs-utils-subst-char-in-region (point-min) (line-end-position) "Middle Dot" ?.) 438 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 439 | 440 | ;; todo undo does not work 441 | (ert-deftest ucs-utils-subst-char-in-region-03 nil 442 | :expected-result :failed 443 | (should (equal "testing..." 444 | (with-temp-buffer 445 | (goto-char (point-min)) 446 | (insert "testing···\n") 447 | (goto-char (point-min)) 448 | (ucs-utils-subst-char-in-region (point-min) (line-end-position) (ucs-utils-char "Middle Dot") ?.) 449 | (undo 1) 450 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 451 | 452 | (ert-deftest ucs-utils-subst-char-in-region-04 nil 453 | :expected-result :failed 454 | (should (equal "testing..." 455 | (with-temp-buffer 456 | (goto-char (point-min)) 457 | (insert "testing···\n") 458 | (goto-char (point-min)) 459 | (ucs-utils-subst-char-in-region (point-min) (line-end-position) (ucs-utils-char "Middle Dot") ?. 'noundo) 460 | (undo 1) 461 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 462 | 463 | 464 | ;;; ucs-utils-eval 465 | 466 | (ert-deftest ucs-utils-eval-01 nil 467 | (should (equal "Middle Dot" 468 | (with-temp-buffer 469 | (goto-char (point-min)) 470 | (insert "·\n") 471 | (goto-char (point-min)) 472 | (ucs-utils-eval (point-min)))))) 473 | 474 | ;; @@@ todo passes, but causes spurious output at end of test run 475 | ;; in batch mode 476 | (ert-deftest ucs-utils-eval-02 nil 477 | (should (equal "\"Middle Dot\"" 478 | (with-temp-buffer 479 | (goto-char (point-min)) 480 | (insert "·\n") 481 | (goto-char (point-min)) 482 | (ucs-utils-eval (point-min) '(16)) 483 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 484 | 485 | ;;; ucs-utils-ucs-insert 486 | 487 | (ert-deftest ucs-utils-ucs-insert-01 nil 488 | (should (equal "···" 489 | (with-temp-buffer 490 | (goto-char (point-min)) 491 | (ucs-utils-ucs-insert (ucs-utils-char "Middle Dot") 3) 492 | (insert "\n") 493 | (goto-char (point-min)) 494 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 495 | 496 | (ert-deftest ucs-utils-ucs-insert-02 nil 497 | (should (equal "···" 498 | (with-temp-buffer 499 | (goto-char (point-min)) 500 | (ucs-utils-ucs-insert "Middle Dot" 3) 501 | (insert "\n") 502 | (goto-char (point-min)) 503 | (buffer-substring-no-properties (point-min) (line-end-position)))))) 504 | 505 | ;; 506 | ;; Emacs 507 | ;; 508 | ;; Local Variables: 509 | ;; indent-tabs-mode: nil 510 | ;; mangle-whitespace: t 511 | ;; require-final-newline: t 512 | ;; coding: utf-8 513 | ;; byte-compile-warnings: (not cl-functions) 514 | ;; End: 515 | ;; 516 | 517 | ;;; ucs-utils-test.el ends here 518 | --------------------------------------------------------------------------------