From 838d78d411955dbe3ef5d75ff404ced8ca832c5a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 29 Jul 2008 14:46:18 +0000 Subject: [PATCH] (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'. --- lisp/ChangeLog | 31 +++++++++++++++++++++++++++++++ lisp/international/mule-cmds.el | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f30596b3b2..b3c7d59a49d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,34 @@ +2008-07-29 Juri Linkov + + * 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 * progmodes/ada-mode.el (ada-batch-reformat): Doc fix. diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 4b8ee720d7e..aa45bda2c48 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -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)) -- 2.11.4.GIT