emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111243: * lisp/isearch.el (isearch-m


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111243: * lisp/isearch.el (isearch-mode-map): Bind `C-x 8 RET' to
Date: Sat, 15 Dec 2012 15:03:17 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111243
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Sat 2012-12-15 15:03:17 +0200
message:
  * lisp/isearch.el (isearch-mode-map): Bind `C-x 8 RET' to
  `isearch-insert-char-by-name'.
  (with-isearch-suspended): New defmacro with body mostly from
  `isearch-edit-string' except the part that sets
  `isearch-new-string' and `isearch-new-message'.
  (isearch-edit-string): Use new macro `with-isearch-suspended' with
  body that sets `isearch-new-string' and `isearch-new-message'.
  (isearch-insert-char-by-name): New command.
  * lisp/international/mule-cmds.el (read-char-by-name): Let-bind
  `enable-recursive-minibuffers' to t.
  http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00234.html
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/international/mule-cmds.el
  lisp/isearch.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-12-14 18:59:00 +0000
+++ b/etc/NEWS  2012-12-15 13:03:17 +0000
@@ -73,6 +73,11 @@
 *** The icomplete-separator is customizable, and its default has changed.
 *** Removed icomplete-show-key-bindings.
 
+** Isearch
+
+*** `C-x 8 RET' in Isearch mode reads a character by its Unicode name
+and adds it to the search string.
+
 ** MH-E has been updated to MH-E version 8.4.
 See MH-E-NEWS for details.
 

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-15 12:19:04 +0000
+++ b/lisp/ChangeLog    2012-12-15 13:03:17 +0000
@@ -1,5 +1,19 @@
 2012-12-15  Juri Linkov  <address@hidden>
 
+       * isearch.el (isearch-mode-map): Bind `C-x 8 RET' to
+       `isearch-insert-char-by-name'.
+       (with-isearch-suspended): New defmacro with body mostly from
+       `isearch-edit-string' except the part that sets
+       `isearch-new-string' and `isearch-new-message'.
+       (isearch-edit-string): Use new macro `with-isearch-suspended' with
+       body that sets `isearch-new-string' and `isearch-new-message'.
+       (isearch-insert-char-by-name): New command.
+       * international/mule-cmds.el (read-char-by-name): Let-bind
+       `enable-recursive-minibuffers' to t.
+       http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00234.html
+
+2012-12-15  Juri Linkov  <address@hidden>
+
        * isearch.el (isearch-delete-char, isearch-del-char): Doc fix.
        (Bug#13175)
 

=== modified file 'lisp/international/mule-cmds.el'
--- a/lisp/international/mule-cmds.el   2012-10-11 20:05:47 +0000
+++ b/lisp/international/mule-cmds.el   2012-12-15 13:03:17 +0000
@@ -2945,14 +2945,15 @@
 This function also accepts a hexadecimal number of Unicode code
 point or a number in hash notation, e.g. #o21430 for octal,
 #x2318 for hex, or #10r8984 for decimal."
-  (let ((input
-         (completing-read
-          prompt
-          (lambda (string pred action)
-            (let ((completion-ignore-case t))
-              (if (eq action 'metadata)
-                  '(metadata (category . unicode-name))
-                (complete-with-action action (ucs-names) string pred)))))))
+  (let* ((enable-recursive-minibuffers t)
+        (input
+         (completing-read
+          prompt
+          (lambda (string pred action)
+            (let ((completion-ignore-case t))
+              (if (eq action 'metadata)
+                  '(metadata (category . unicode-name))
+                (complete-with-action action (ucs-names) string pred)))))))
     (cond
      ((string-match-p "\\`[0-9a-fA-F]+\\'" input)
       (string-to-number input 16))

=== modified file 'lisp/isearch.el'
--- a/lisp/isearch.el   2012-12-15 12:19:04 +0000
+++ b/lisp/isearch.el   2012-12-15 13:03:17 +0000
@@ -520,7 +520,7 @@
     (define-key map "\C-x" nil)
     (define-key map [?\C-x t] 'isearch-other-control-char)
     (define-key map "\C-x8" nil)
-    (define-key map "\C-x8\r" 'isearch-other-control-char)
+    (define-key map "\C-x8\r" 'isearch-insert-char-by-name)
 
     map)
   "Keymap for `isearch-mode'.")
@@ -1118,23 +1118,17 @@
          (length succ-msg)
        0))))
 
-(defun isearch-edit-string ()
-  "Edit the search string in the minibuffer.
-The following additional command keys are active while editing.
-\\<minibuffer-local-isearch-map>
-\\[exit-minibuffer] to resume incremental searching with the edited string.
-\\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search.
-\\[isearch-forward-exit-minibuffer] to resume isearching forward.
-\\[isearch-reverse-exit-minibuffer] to resume isearching backward.
-\\[isearch-complete-edit] to complete the search string using the search ring."
-
+(defmacro with-isearch-suspended (&rest body)
+  "Exit Isearch mode, run BODY, and reinvoke the pending search.
+You can update the global isearch variables by setting new values to
+`isearch-new-string', `isearch-new-message', `isearch-new-forward',
+`isearch-new-word', `isearch-new-case-fold'."
   ;; This code is very hairy for several reasons, explained in the code.
   ;; Mainly, isearch-mode must be terminated while editing and then restarted.
   ;; If there were a way to catch any change of buffer from the minibuffer,
   ;; this could be simplified greatly.
   ;; Editing doesn't back up the search point.  Should it?
-  (interactive)
-  (condition-case nil
+  `(condition-case nil
       (progn
        (let ((isearch-nonincremental isearch-nonincremental)
 
@@ -1197,29 +1191,7 @@
          (setq old-point (point) old-other-end isearch-other-end)
 
          (unwind-protect
-             (let* ((message-log-max nil)
-                    ;; Don't add a new search string to the search ring here
-                    ;; in `read-from-minibuffer'. It should be added only
-                    ;; by `isearch-update-ring' called from `isearch-done'.
-                    (history-add-new-input nil)
-                    ;; Binding minibuffer-history-symbol to nil is a 
work-around
-                    ;; for some incompatibility with gmhist.
-                    (minibuffer-history-symbol))
-               (setq isearch-new-string
-                      (read-from-minibuffer
-                       (isearch-message-prefix nil isearch-nonincremental)
-                      (cons isearch-string (1+ (or (isearch-fail-pos)
-                                                   (length isearch-string))))
-                       minibuffer-local-isearch-map nil
-                       (if isearch-regexp
-                          (cons 'regexp-search-ring
-                                (1+ (or regexp-search-ring-yank-pointer -1)))
-                        (cons 'search-ring
-                              (1+ (or search-ring-yank-pointer -1))))
-                       nil t)
-                     isearch-new-message
-                     (mapconcat 'isearch-text-char-description
-                                isearch-new-string "")))
+             (progn ,@body)
 
            ;; Set point at the start (end) of old match if forward (backward),
            ;; so after exiting minibuffer isearch resumes at the start (end)
@@ -1278,6 +1250,41 @@
      (isearch-abort)  ;; outside of let to restore outside global values
      )))
 
+(defun isearch-edit-string ()
+  "Edit the search string in the minibuffer.
+The following additional command keys are active while editing.
+\\<minibuffer-local-isearch-map>
+\\[exit-minibuffer] to resume incremental searching with the edited string.
+\\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search.
+\\[isearch-forward-exit-minibuffer] to resume isearching forward.
+\\[isearch-reverse-exit-minibuffer] to resume isearching backward.
+\\[isearch-complete-edit] to complete the search string using the search ring."
+  (interactive)
+  (with-isearch-suspended
+   (let* ((message-log-max nil)
+         ;; Don't add a new search string to the search ring here
+         ;; in `read-from-minibuffer'. It should be added only
+         ;; by `isearch-update-ring' called from `isearch-done'.
+         (history-add-new-input nil)
+         ;; Binding minibuffer-history-symbol to nil is a work-around
+         ;; for some incompatibility with gmhist.
+         (minibuffer-history-symbol))
+     (setq isearch-new-string
+          (read-from-minibuffer
+           (isearch-message-prefix nil isearch-nonincremental)
+           (cons isearch-string (1+ (or (isearch-fail-pos)
+                                        (length isearch-string))))
+           minibuffer-local-isearch-map nil
+           (if isearch-regexp
+               (cons 'regexp-search-ring
+                     (1+ (or regexp-search-ring-yank-pointer -1)))
+             (cons 'search-ring
+                   (1+ (or search-ring-yank-pointer -1))))
+           nil t)
+          isearch-new-message
+          (mapconcat 'isearch-text-char-description
+                     isearch-new-string "")))))
+
 (defun isearch-nonincremental-exit-minibuffer ()
   (interactive)
   (setq isearch-nonincremental t)
@@ -1841,6 +1848,17 @@
    (lambda () (let ((inhibit-field-text-motion t))
                (line-end-position (if (eolp) 2 1))))))
 
+(defun isearch-insert-char-by-name ()
+  "Read a character by its Unicode name and insert it into search string."
+  (interactive)
+  (with-isearch-suspended
+   (let ((char (read-char-by-name "Insert character (Unicode name or hex): ")))
+     (when char
+       (setq isearch-new-string (concat isearch-string (string char))
+            isearch-new-message (concat isearch-message
+                                        (mapconcat 
'isearch-text-char-description
+                                                   (string char) "")))))))
+
 (defun isearch-search-and-update ()
   ;; Do the search and update the display.
   (when (or isearch-success


reply via email to

[Prev in Thread] Current Thread [Next in Thread]