├── .github
├── dependabot.yml
└── workflows
│ └── test.yml
├── Makefile
├── README.md
└── list-unicode-display.el
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: github-actions
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | open-pull-requests-limit: 10
8 | commit-message:
9 | prefix: "chore"
10 | include: "scope"
11 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | pull_request:
5 | push:
6 | paths-ignore:
7 | - '**.md'
8 |
9 | jobs:
10 | lint:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: purcell/setup-emacs@master
14 | with:
15 | version: 29.4
16 | - uses: actions/checkout@v4
17 | - name: Run tests
18 | run: make package-lint
19 |
20 | build:
21 | runs-on: ubuntu-latest
22 | strategy:
23 | matrix:
24 | emacs_version:
25 | - 24.3
26 | - 25.3
27 | - 26.3
28 | - 27.2
29 | - 28.2
30 | - 29.4
31 | - snapshot
32 | steps:
33 | - uses: purcell/setup-emacs@master
34 | with:
35 | version: ${{ matrix.emacs_version }}
36 |
37 | - uses: actions/checkout@v4
38 | - name: Compile
39 | run: make compile
40 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | EMACS ?= emacs
2 |
3 | # A space-separated list of required package names
4 | DEPS =
5 |
6 | INIT_PACKAGES="(progn \
7 | (require 'package) \
8 | (push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
9 | (package-initialize) \
10 | (dolist (pkg '(PACKAGES)) \
11 | (unless (package-installed-p pkg) \
12 | (unless (assoc pkg package-archive-contents) \
13 | (package-refresh-contents)) \
14 | (package-install pkg))) \
15 | )"
16 |
17 | all: compile package-lint test clean-elc
18 |
19 | package-lint:
20 | ${EMACS} -Q --eval $(subst PACKAGES,package-lint,${INIT_PACKAGES}) -batch -f package-lint-batch-and-exit list-unicode-display.el
21 |
22 | compile: clean-elc
23 | ${EMACS} -Q --eval $(subst PACKAGES,${DEPS},${INIT_PACKAGES}) -L . -batch -f batch-byte-compile *.el
24 |
25 | clean-elc:
26 | rm -f f.elc
27 |
28 | .PHONY: all compile clean-elc package-lint
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://melpa.org/#/list-unicode-display)
2 | [](https://stable.melpa.org/#/list-unicode-display)
3 | [](https://github.com/purcell/list-unicode-display/actions/workflows/test.yml)
4 |
5 |
6 | list-unicode-display
7 | ====================
8 |
9 | Provides a command which searches for unicode characters by name, and
10 | displays a list of matching characters with their names in a buffer.
11 |
12 | ### Installation
13 |
14 | Preferred method: install [Melpa](http://melpa.org/).
15 |
16 | Otherwise:
17 |
18 | (add-to-list 'load-path "/dir/containing/list-unicode-display")
19 | (require 'list-unicode-display)
20 |
21 | ### Usage
22 |
23 | M-x list-unicode-display
24 |
25 | Alternatively, `list-unicode-display-find-copy` may be used to search
26 | interactively for a character and copy it to the kill ring.
27 |
28 |
29 |
30 |
31 | [💝 Support this project and my other Open Source work](https://www.patreon.com/sanityinc)
32 |
33 | [💼 LinkedIn profile](https://uk.linkedin.com/in/stevepurcell)
34 |
35 | [✍ sanityinc.com](http://www.sanityinc.com/)
36 |
--------------------------------------------------------------------------------
/list-unicode-display.el:
--------------------------------------------------------------------------------
1 | ;;; list-unicode-display.el --- Search for and list unicode characters by name
2 |
3 | ;; Copyright (C) 2015 Steve Purcell
4 |
5 | ;; Author: Steve Purcell
6 | ;; Keywords: convenience
7 | ;; Homepage: https://github.com/purcell/list-unicode-display
8 | ;; Package-Version: 0
9 | ;; Package-Requires: ((emacs "24.3"))
10 |
11 | ;; This program is free software; you can redistribute it and/or modify
12 | ;; it under the terms of the GNU General Public License as published by
13 | ;; the Free Software Foundation, either version 3 of the License, or
14 | ;; (at your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful,
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | ;; GNU General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with this program. If not, see .
23 |
24 | ;;; Commentary:
25 |
26 | ;; This is a packaged version of code by @jpkotta, taken from a
27 | ;; comment on http://tromey.com/blog/?p=831.
28 |
29 | ;;; Code:
30 |
31 | (defgroup list-unicode-display nil
32 | "Explore unicode characters."
33 | :group 'i18n)
34 |
35 | (define-derived-mode list-unicode-display-mode help-mode "Unicode Characters"
36 | "Major mode to display a list of unicode characters.")
37 |
38 | (defun list-unicode-display-describe ()
39 | "Apply `describe-char' to the character in a row of a `list-unicode-display-mode' buffer."
40 | (interactive)
41 | (save-excursion
42 | (beginning-of-line)
43 | (search-forward "\t" (line-end-position))
44 | (describe-char (point))))
45 |
46 | (defun list-unicode-display-copy ()
47 | "Copy the character in a row of a `list-unicode-display-mode' buffer to the kill ring."
48 | (interactive)
49 | (save-excursion
50 | (beginning-of-line)
51 | (search-forward "\t" (line-end-position))
52 | (kill-ring-save (point) (1+ (point)))
53 | (message "Saved `%s' to the kill-ring."
54 | (buffer-substring-no-properties (point) (1+ (point))))))
55 |
56 | (define-key list-unicode-display-mode-map (kbd "RET") #'list-unicode-display-describe)
57 | (define-key list-unicode-display-mode-map (kbd "w") #'list-unicode-display-copy)
58 | (define-key list-unicode-display-mode-map (kbd "g") #'list-unicode-display)
59 |
60 | ;;;###autoload
61 | (defun list-unicode-display (&optional regexp)
62 | "Display a list of unicode characters with names matching REGEXP.
63 | If no regexp is supplied, all characters are shown. This takes
64 | some time."
65 | (interactive "sRegexp (default \".*\"): ")
66 | (let* ((regexp (or regexp ".*"))
67 | (case-fold-search t)
68 | (cmp (lambda (x y) (< (cdr x) (cdr y))))
69 | (pred (lambda (name) (string-match-p regexp name)))
70 | ;; alist like ("name" . code-point)
71 | (char-alist ()))
72 |
73 | (let ((names (ucs-names)))
74 | (if (hash-table-p names)
75 | ;; ucs-names returns a hash table in emacs 26+
76 | (maphash (lambda (name char)
77 | (when (funcall pred name)
78 | (push (cons name char) char-alist)))
79 | names)
80 | (mapc (lambda (pair)
81 | (when (funcall pred (car pair))
82 | (push pair char-alist)))
83 | names)))
84 |
85 | (setq char-alist (sort char-alist cmp))
86 |
87 | (let ((buf (get-buffer-create "*Unicode Characters*"))
88 | (display-buffer-base-action '(display-buffer-same-window . nil)))
89 | (with-current-buffer buf
90 | (let ((inhibit-read-only t))
91 | (erase-buffer)
92 | (dolist (c char-alist)
93 | (insert (format "0x%06X\t" (cdr c)))
94 | (insert (char-to-string (cdr c)))
95 | (insert (format "\t%s\n" (car c))))
96 | (list-unicode-display-mode)
97 | (goto-char (point-min))))
98 | (display-buffer buf))))
99 |
100 |
101 | ;;;###autoload
102 | (defun list-unicode-display-find-copy ()
103 | "Copy a prompted character to the kill ring.
104 |
105 | Also see `insert-char', which is similar to this command, but inserts the
106 | character instead."
107 | (interactive)
108 | (kill-new (char-to-string (read-char-by-name "Copy char: "))))
109 |
110 | (provide 'list-unicode-display)
111 | ;;; list-unicode-display.el ends here
112 |
--------------------------------------------------------------------------------