aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2012-12-15 15:03:17 +0200
committerJuri Linkov2012-12-15 15:03:17 +0200
commit279f9b06fd693b67d1178cdb5ad1ecf513d199ad (patch)
tree5125c3cfb425a9c1304d577a526747a09e23f43a
parent8370def5c87fbab5f72420be9517b0e4676c306d (diff)
downloademacs-279f9b06fd693b67d1178cdb5ad1ecf513d199ad.tar.gz
emacs-279f9b06fd693b67d1178cdb5ad1ecf513d199ad.zip
* 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
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/international/mule-cmds.el17
-rw-r--r--lisp/isearch.el90
4 files changed, 82 insertions, 44 deletions
diff --git a/etc/NEWS b/etc/NEWS
index d2a85507034..9b847b5ee70 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -73,6 +73,11 @@ amounts of data into the ERC input.
73*** The icomplete-separator is customizable, and its default has changed. 73*** The icomplete-separator is customizable, and its default has changed.
74*** Removed icomplete-show-key-bindings. 74*** Removed icomplete-show-key-bindings.
75 75
76** Isearch
77
78*** `C-x 8 RET' in Isearch mode reads a character by its Unicode name
79and adds it to the search string.
80
76** MH-E has been updated to MH-E version 8.4. 81** MH-E has been updated to MH-E version 8.4.
77See MH-E-NEWS for details. 82See MH-E-NEWS for details.
78 83
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index db5ae7e35d6..8c441af4bf5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,19 @@
12012-12-15 Juri Linkov <juri@jurta.org> 12012-12-15 Juri Linkov <juri@jurta.org>
2 2
3 * isearch.el (isearch-mode-map): Bind `C-x 8 RET' to
4 `isearch-insert-char-by-name'.
5 (with-isearch-suspended): New defmacro with body mostly from
6 `isearch-edit-string' except the part that sets
7 `isearch-new-string' and `isearch-new-message'.
8 (isearch-edit-string): Use new macro `with-isearch-suspended' with
9 body that sets `isearch-new-string' and `isearch-new-message'.
10 (isearch-insert-char-by-name): New command.
11 * international/mule-cmds.el (read-char-by-name): Let-bind
12 `enable-recursive-minibuffers' to t.
13 http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00234.html
14
152012-12-15 Juri Linkov <juri@jurta.org>
16
3 * isearch.el (isearch-delete-char, isearch-del-char): Doc fix. 17 * isearch.el (isearch-delete-char, isearch-del-char): Doc fix.
4 (Bug#13175) 18 (Bug#13175)
5 19
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 3431c81df88..f324446fa74 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2945,14 +2945,15 @@ at the beginning of the name.
2945This function also accepts a hexadecimal number of Unicode code 2945This function also accepts a hexadecimal number of Unicode code
2946point or a number in hash notation, e.g. #o21430 for octal, 2946point or a number in hash notation, e.g. #o21430 for octal,
2947#x2318 for hex, or #10r8984 for decimal." 2947#x2318 for hex, or #10r8984 for decimal."
2948 (let ((input 2948 (let* ((enable-recursive-minibuffers t)
2949 (completing-read 2949 (input
2950 prompt 2950 (completing-read
2951 (lambda (string pred action) 2951 prompt
2952 (let ((completion-ignore-case t)) 2952 (lambda (string pred action)
2953 (if (eq action 'metadata) 2953 (let ((completion-ignore-case t))
2954 '(metadata (category . unicode-name)) 2954 (if (eq action 'metadata)
2955 (complete-with-action action (ucs-names) string pred))))))) 2955 '(metadata (category . unicode-name))
2956 (complete-with-action action (ucs-names) string pred)))))))
2956 (cond 2957 (cond
2957 ((string-match-p "\\`[0-9a-fA-F]+\\'" input) 2958 ((string-match-p "\\`[0-9a-fA-F]+\\'" input)
2958 (string-to-number input 16)) 2959 (string-to-number input 16))
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 6f98e2d3b12..df922edf45d 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -520,7 +520,7 @@ This is like `describe-bindings', but displays only Isearch keys."
520 (define-key map "\C-x" nil) 520 (define-key map "\C-x" nil)
521 (define-key map [?\C-x t] 'isearch-other-control-char) 521 (define-key map [?\C-x t] 'isearch-other-control-char)
522 (define-key map "\C-x8" nil) 522 (define-key map "\C-x8" nil)
523 (define-key map "\C-x8\r" 'isearch-other-control-char) 523 (define-key map "\C-x8\r" 'isearch-insert-char-by-name)
524 524
525 map) 525 map)
526 "Keymap for `isearch-mode'.") 526 "Keymap for `isearch-mode'.")
@@ -1118,23 +1118,17 @@ If MSG is non-nil, use `isearch-message', otherwise `isearch-string'."
1118 (length succ-msg) 1118 (length succ-msg)
1119 0)))) 1119 0))))
1120 1120
1121(defun isearch-edit-string () 1121(defmacro with-isearch-suspended (&rest body)
1122 "Edit the search string in the minibuffer. 1122 "Exit Isearch mode, run BODY, and reinvoke the pending search.
1123The following additional command keys are active while editing. 1123You can update the global isearch variables by setting new values to
1124\\<minibuffer-local-isearch-map> 1124`isearch-new-string', `isearch-new-message', `isearch-new-forward',
1125\\[exit-minibuffer] to resume incremental searching with the edited string. 1125`isearch-new-word', `isearch-new-case-fold'."
1126\\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search.
1127\\[isearch-forward-exit-minibuffer] to resume isearching forward.
1128\\[isearch-reverse-exit-minibuffer] to resume isearching backward.
1129\\[isearch-complete-edit] to complete the search string using the search ring."
1130
1131 ;; This code is very hairy for several reasons, explained in the code. 1126 ;; This code is very hairy for several reasons, explained in the code.
1132 ;; Mainly, isearch-mode must be terminated while editing and then restarted. 1127 ;; Mainly, isearch-mode must be terminated while editing and then restarted.
1133 ;; If there were a way to catch any change of buffer from the minibuffer, 1128 ;; If there were a way to catch any change of buffer from the minibuffer,
1134 ;; this could be simplified greatly. 1129 ;; this could be simplified greatly.
1135 ;; Editing doesn't back up the search point. Should it? 1130 ;; Editing doesn't back up the search point. Should it?
1136 (interactive) 1131 `(condition-case nil
1137 (condition-case nil
1138 (progn 1132 (progn
1139 (let ((isearch-nonincremental isearch-nonincremental) 1133 (let ((isearch-nonincremental isearch-nonincremental)
1140 1134
@@ -1197,29 +1191,7 @@ The following additional command keys are active while editing.
1197 (setq old-point (point) old-other-end isearch-other-end) 1191 (setq old-point (point) old-other-end isearch-other-end)
1198 1192
1199 (unwind-protect 1193 (unwind-protect
1200 (let* ((message-log-max nil) 1194 (progn ,@body)
1201 ;; Don't add a new search string to the search ring here
1202 ;; in `read-from-minibuffer'. It should be added only
1203 ;; by `isearch-update-ring' called from `isearch-done'.
1204 (history-add-new-input nil)
1205 ;; Binding minibuffer-history-symbol to nil is a work-around
1206 ;; for some incompatibility with gmhist.
1207 (minibuffer-history-symbol))
1208 (setq isearch-new-string
1209 (read-from-minibuffer
1210 (isearch-message-prefix nil isearch-nonincremental)
1211 (cons isearch-string (1+ (or (isearch-fail-pos)
1212 (length isearch-string))))
1213 minibuffer-local-isearch-map nil
1214 (if isearch-regexp
1215 (cons 'regexp-search-ring
1216 (1+ (or regexp-search-ring-yank-pointer -1)))
1217 (cons 'search-ring
1218 (1+ (or search-ring-yank-pointer -1))))
1219 nil t)
1220 isearch-new-message
1221 (mapconcat 'isearch-text-char-description
1222 isearch-new-string "")))
1223 1195
1224 ;; Set point at the start (end) of old match if forward (backward), 1196 ;; Set point at the start (end) of old match if forward (backward),
1225 ;; so after exiting minibuffer isearch resumes at the start (end) 1197 ;; so after exiting minibuffer isearch resumes at the start (end)
@@ -1278,6 +1250,41 @@ The following additional command keys are active while editing.
1278 (isearch-abort) ;; outside of let to restore outside global values 1250 (isearch-abort) ;; outside of let to restore outside global values
1279 ))) 1251 )))
1280 1252
1253(defun isearch-edit-string ()
1254 "Edit the search string in the minibuffer.
1255The following additional command keys are active while editing.
1256\\<minibuffer-local-isearch-map>
1257\\[exit-minibuffer] to resume incremental searching with the edited string.
1258\\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search.
1259\\[isearch-forward-exit-minibuffer] to resume isearching forward.
1260\\[isearch-reverse-exit-minibuffer] to resume isearching backward.
1261\\[isearch-complete-edit] to complete the search string using the search ring."
1262 (interactive)
1263 (with-isearch-suspended
1264 (let* ((message-log-max nil)
1265 ;; Don't add a new search string to the search ring here
1266 ;; in `read-from-minibuffer'. It should be added only
1267 ;; by `isearch-update-ring' called from `isearch-done'.
1268 (history-add-new-input nil)
1269 ;; Binding minibuffer-history-symbol to nil is a work-around
1270 ;; for some incompatibility with gmhist.
1271 (minibuffer-history-symbol))
1272 (setq isearch-new-string
1273 (read-from-minibuffer
1274 (isearch-message-prefix nil isearch-nonincremental)
1275 (cons isearch-string (1+ (or (isearch-fail-pos)
1276 (length isearch-string))))
1277 minibuffer-local-isearch-map nil
1278 (if isearch-regexp
1279 (cons 'regexp-search-ring
1280 (1+ (or regexp-search-ring-yank-pointer -1)))
1281 (cons 'search-ring
1282 (1+ (or search-ring-yank-pointer -1))))
1283 nil t)
1284 isearch-new-message
1285 (mapconcat 'isearch-text-char-description
1286 isearch-new-string "")))))
1287
1281(defun isearch-nonincremental-exit-minibuffer () 1288(defun isearch-nonincremental-exit-minibuffer ()
1282 (interactive) 1289 (interactive)
1283 (setq isearch-nonincremental t) 1290 (setq isearch-nonincremental t)
@@ -1841,6 +1848,17 @@ Subword is used when `subword-mode' is activated. "
1841 (lambda () (let ((inhibit-field-text-motion t)) 1848 (lambda () (let ((inhibit-field-text-motion t))
1842 (line-end-position (if (eolp) 2 1)))))) 1849 (line-end-position (if (eolp) 2 1))))))
1843 1850
1851(defun isearch-insert-char-by-name ()
1852 "Read a character by its Unicode name and insert it into search string."
1853 (interactive)
1854 (with-isearch-suspended
1855 (let ((char (read-char-by-name "Insert character (Unicode name or hex): ")))
1856 (when char
1857 (setq isearch-new-string (concat isearch-string (string char))
1858 isearch-new-message (concat isearch-message
1859 (mapconcat 'isearch-text-char-description
1860 (string char) "")))))))
1861
1844(defun isearch-search-and-update () 1862(defun isearch-search-and-update ()
1845 ;; Do the search and update the display. 1863 ;; Do the search and update the display.
1846 (when (or isearch-success 1864 (when (or isearch-success