1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-01 01:41:01 -08:00

(ucs-names): New internal variable.

(ucs-names): New function.
(ucs-completions): New lazy completion variable.
(read-char-by-name): New function.
(ucs-insert): Replace interactive spec letter "s" with the call to
`read-char-by-name'.
This commit is contained in:
Juri Linkov 2008-07-29 14:46:18 +00:00
parent 8677dea3af
commit 838d78d411
2 changed files with 68 additions and 1 deletions

View file

@ -1,3 +1,34 @@
2008-07-29 Juri Linkov <juri@jurta.org>
* international/mule-cmds.el (ucs-names): New internal variable.
(ucs-names): New function.
(ucs-completions): New lazy completion variable.
(read-char-by-name): New function.
(ucs-insert): Replace interactive spec letter "s" with the call to
`read-char-by-name'.
* replace.el (read-regexp): Add second arg `default'. Doc fix.
* replace.el (occur-read-primary-args):
* hi-lock.el (hi-lock-line-face-buffer, hi-lock-face-buffer)
(hi-lock-face-phrase-buffer): Use `(car regexp-history)' as the
second arg of `read-regexp'.
* dired-aux.el (dired-isearch-filenames): New user option.
(dired-isearch-orig-success-function): New internal variable.
(dired-isearch-filenames-setup, dired-isearch-filenames-end)
(dired-isearch-success-function): New functions.
(dired-isearch-filenames, dired-isearch-filenames-regexp):
New commands.
* dired.el (dired-insert-set-properties): Add new text property
`dired-filename' to put on file names.
(dired-mode-map): Bind `M-s f C-s' to `dired-isearch-filenames'
and `M-s f M-C-s' to `dired-isearch-filenames-regexp'.
Add menu items.
(dired-mode): Add hook `dired-isearch-filenames-setup' to
buffer-local `isearch-mode-hook'.
2008-07-29 Juanma Barranquero <lekktu@gmail.com>
* progmodes/ada-mode.el (ada-batch-reformat): Doc fix.

View file

@ -2832,10 +2832,46 @@ If CODING-SYSTEM can't safely encode CHAR, return nil."
(defvar nonascii-insert-offset 0 "This variable is obsolete.")
(defvar nonascii-translation-table nil "This variable is obsolete.")
(defvar ucs-names nil
"Alist of cached (CHAR-NAME . CHAR-CODE) pairs.")
(defun ucs-names ()
"Return alist of (CHAR-NAME . CHAR-CODE) pairs cached in `ucs-names'."
(or ucs-names
(setq ucs-names
(let (name names)
(dotimes (c #xEFFFF)
(unless (or
(and (>= c #x3400 ) (<= c #x4dbf )) ; CJK Ideograph Extension A
(and (>= c #x4e00 ) (<= c #x9fff )) ; CJK Ideograph
(and (>= c #xd800 ) (<= c #xfaff )) ; Private/Surrogate
(and (>= c #x20000) (<= c #x2ffff)) ; CJK Ideograph Extension B
)
(if (setq name (get-char-code-property c 'name))
(setq names (cons (cons name c) names)))
(if (setq name (get-char-code-property c 'old-name))
(setq names (cons (cons name c) names)))))
names))))
(defvar ucs-completions (lazy-completion-table ucs-completions ucs-names)
"Lazy completion table for completing on Unicode character names.")
(defun read-char-by-name (prompt)
"Read a character by its Unicode name or hex number string.
Display PROMPT and read a string that represents a character
by its Unicode property `name' or `old-name'. It also accepts
a hexadecimal number of Unicode code point. Returns a character
as a number."
(let* ((completion-ignore-case t)
(input (completing-read prompt ucs-completions)))
(or (and (string-match "^[0-9a-fA-F]+$" input)
(string-to-number input 16))
(cdr (assoc input (ucs-names))))))
(defun ucs-insert (arg)
"Insert a character of the given Unicode code point.
Interactively, prompts for a hex string giving the code."
(interactive "sUnicode (hex): ")
(interactive (list (read-char-by-name "Unicode (name or hex): ")))
(or (integerp arg)
(setq arg (string-to-number arg 16)))
(if (or (< arg 0) (> arg #x10FFFF))