diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2021-12-07 19:13:45 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2021-12-07 19:13:45 +0100 |
| commit | 918c15049c06cdf0deb8362e9ccee8de2eb6dbb0 (patch) | |
| tree | 881d1004e09b539ee4e309e370536308e5d8e5fd /cape.el | |
| parent | b895c8cf280f80a0cf724f137de06217679cb846 (diff) | |
Add cape-charchar
Diffstat (limited to 'cape.el')
| -rw-r--r-- | cape.el | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -392,6 +392,35 @@ VALID is the input comparator, see `cape--input-valid-p'." ;;;; Capfs +;;;;; cape-char + +(defvar cape--char-properties + (list :annotation-function #'cape--char-annotation + :exit-function #'cape--char-replace + :company-kind (lambda (_) 'text)) + "Completion extra properties for `cape-char'.") + +(defun cape--char-replace (name _status) + "Replace character with NAME." + (when-let (char (gethash name ucs-names)) + (delete-region (- (point) (length name)) (point)) + (insert (char-to-string char)))) + +(defun cape--char-annotation (name) + "Return annotation for character with NAME." + (when-let (char (gethash name ucs-names)) + (format " %c" char))) + +;;;###autoload +(defun cape-char (&optional interactive) + "Complete character at point. +If INTERACTIVE is nil the function acts like a capf." + (interactive (list t)) + (if interactive + (cape--interactive #'cape-char) + `(,(point) ,(point) ,(ucs-names) + :exclusive no ,@cape--char-properties))) + ;;;;; cape-file (defvar cape--file-properties |
