aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-06 22:11:22 +0000
committerRichard M. Stallman1993-06-06 22:11:22 +0000
commitb78559b08704bc5de1a5c822a582461c08db9b29 (patch)
tree5e19676b917baf3bee97f32a19879e5227abeed5 /lisp
parent47099d6f792a5a763b257fdafecfcd0e8dbaba2b (diff)
downloademacs-b78559b08704bc5de1a5c822a582461c08db9b29.tar.gz
emacs-b78559b08704bc5de1a5c822a582461c08db9b29.zip
(search-upper-case): Make `no-yanks' the default.
(isearch-no-upper-case-p): New arg REGEXP-FLAG. (isearch-search): Pass new arg. (isearch-member-equal): Deleted. (isearch-overlay): New variable. (isearch-highlight, isearch-dehighlight): Rewritten to use overlays.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/isearch.el189
1 files changed, 24 insertions, 165 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 6a3979cc586..ee46727d5aa 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1,10 +1,10 @@
1;;; isearch.el --- incremental search minor mode. 1;;; isearch.el --- incremental search minor mode.
2 2
3;; Copyright (C) 1992 Free Software Foundation, Inc. 3;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
4 4
5;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> 5;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
6 6
7;; |$Date: 1993/06/01 04:52:28 $|$Revision: 1.39 $ 7;; |$Date: 1993/06/04 06:40:45 $|$Revision: 1.40 $
8 8
9;; This file is not yet part of GNU Emacs, but it is based almost 9;; This file is not yet part of GNU Emacs, but it is based almost
10;; entirely on isearch.el which is part of GNU Emacs. 10;; entirely on isearch.el which is part of GNU Emacs.
@@ -157,7 +157,7 @@ that the search has reached.")
157;;;======================================================================== 157;;;========================================================================
158;;; Some additional options and constants. 158;;; Some additional options and constants.
159 159
160(defvar search-upper-case t 160(defvar search-upper-case 'not-yanks
161 "*If non-nil, upper case chars disable case fold searching. 161 "*If non-nil, upper case chars disable case fold searching.
162That is, upper and lower case chars must match exactly. 162That is, upper and lower case chars must match exactly.
163This applies no matter where the chars come from, but does not 163This applies no matter where the chars come from, but does not
@@ -177,9 +177,7 @@ You might want to use something like \"[ \\t\\r\\n]+\" instead.")
177;; currently a clean thing to do. Once highlighting is made clean, 177;; currently a clean thing to do. Once highlighting is made clean,
178;; this feature can be re-enabled and advertised. 178;; this feature can be re-enabled and advertised.
179(defvar search-highlight nil 179(defvar search-highlight nil
180 "Whether isearch and query-replace should highlight the text which 180 "*Non-nil means incremental search highlights the current match.")
181currently matches the search-string.")
182
183 181
184(defvar isearch-mode-hook nil 182(defvar isearch-mode-hook nil
185 "Function(s) to call after starting up an incremental search.") 183 "Function(s) to call after starting up an incremental search.")
@@ -1285,7 +1283,8 @@ If there is no completion possible, say so and continue searching."
1285 ;; Do the search with the current search string. 1283 ;; Do the search with the current search string.
1286 (isearch-message nil t) 1284 (isearch-message nil t)
1287 (if (and isearch-case-fold-search search-upper-case) 1285 (if (and isearch-case-fold-search search-upper-case)
1288 (setq isearch-case-fold-search (isearch-no-upper-case-p isearch-string))) 1286 (setq isearch-case-fold-search
1287 (isearch-no-upper-case-p isearch-string isearch-regexp)))
1289 (condition-case lossage 1288 (condition-case lossage
1290 (let ((inhibit-quit nil) 1289 (let ((inhibit-quit nil)
1291 (case-fold-search isearch-case-fold-search)) 1290 (case-fold-search isearch-case-fold-search))
@@ -1330,71 +1329,35 @@ If there is no completion possible, say so and continue searching."
1330;;;======================================================== 1329;;;========================================================
1331;;; Highlighting 1330;;; Highlighting
1332 1331
1333(defun isearch-highlight (begin end)) 1332(defvar isearch-overlay nil)
1334(defun isearch-dehighlight (totally))
1335
1336;; lemacs uses faces
1337'(progn
1338(defvar isearch-extent nil)
1339
1340(or (find-face 'isearch) ;; this face is initialized by x-faces.el
1341 (make-face 'isearch)) ;; since isearch is preloaded
1342 1333
1343(defun isearch-lemacs-highlight (begin end) 1334(defun isearch-highlight (beg end)
1344 (if (null isearch-highlight) 1335 (if (or (null search-highlight) (not (internal-find-face 'isearch nil)))
1345 nil 1336 nil
1346 (if (and (extentp isearch-extent) 1337 (or isearch-overlay (setq isearch-overlay (make-overlay beg end)))
1347 (eq (extent-buffer isearch-extent) (current-buffer))) 1338 (move-overlay isearch-overlay beg end (current-buffer))
1348 (set-extent-endpoints isearch-extent begin end) 1339 (overlay-put isearch-overlay 'face 'isearch)))
1349 (if (and (extentp isearch-extent) 1340
1350 (bufferp (extent-buffer isearch-extent)) 1341(defun isearch-dehighlight (totally)
1351 (buffer-name (extent-buffer isearch-extent))) 1342 (if isearch-overlay
1352 (delete-extent isearch-extent)) 1343 (delete-overlay isearch-overlay)))
1353 (setq isearch-extent (make-extent begin end (current-buffer))))
1354 (set-extent-face isearch-extent 'isearch)))
1355
1356(defun isearch-lemacs-dehighlight (totally)
1357 (if (and isearch-highlight isearch-extent)
1358 (if totally
1359 (let ((inhibit-quit t))
1360 (if (and (extentp isearch-extent)
1361 (bufferp (extent-buffer isearch-extent))
1362 (buffer-name (extent-buffer isearch-extent)))
1363 (delete-extent isearch-extent))
1364 (setq isearch-extent nil))
1365 (if (and (extentp isearch-extent)
1366 (bufferp (extent-buffer isearch-extent))
1367 (buffer-name (extent-buffer isearch-extent)))
1368 (set-extent-face isearch-extent 'default)
1369 (isearch-dehighlight t)))))
1370
1371(defalias 'isearch-highlight (symbol-function 'isearch-lemacs-highlight))
1372(defalias 'isearch-dehighlight (symbol-function 'isearch-lemacs-dehighlight))
1373)
1374 1344
1375;;;=========================================================== 1345;;;===========================================================
1376;;; General utilities 1346;;; General utilities
1377 1347
1378;; (defalias 'isearch-member-equal (symbol-function 'member)) ; for emacs 19
1379
1380(defun isearch-member-equal (item list)
1381 "Return non-nil if ITEM is `equal' to some item in LIST.
1382Actually return the list whose car is that item."
1383 (while (and list (not (equal item (car list))))
1384 (setq list (cdr list)))
1385 list)
1386
1387 1348
1388(defun isearch-no-upper-case-p (string) 1349(defun isearch-no-upper-case-p (string regexp-flag)
1389 "Return t if there are no upper case chars in string. 1350 "Return t if there are no upper case chars in STRING.
1390But upper case chars preceeded by \\ (but not \\\\) do not count since they 1351If REGEXP-FLAG is non-nil, disregard letters preceeded by `\\' (but not `\\\\')
1391have special meaning in a regexp." 1352since they have special meaning in a regexp."
1392 (let ((case-fold-search nil)) 1353 (let ((case-fold-search nil))
1393 (not (string-match "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]" string)))) 1354 (not (string-match (if regexp-flag "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]"
1355 "[A-Z]")
1356 string))))
1394 1357
1395 1358
1396;;;================================================= 1359;;;=================================================
1397;;; Special functions for lemacs events. 1360;; Portability functions to support various Emacs versions.
1398 1361
1399;; To quiet the byte-compiler. 1362;; To quiet the byte-compiler.
1400(defvar unread-command-event) 1363(defvar unread-command-event)
@@ -1432,108 +1395,4 @@ have special meaning in a regexp."
1432 last-command-event 1395 last-command-event
1433 last-command-char)) 1396 last-command-char))
1434 1397
1435
1436
1437
1438;;;========================================================
1439;;; Exiting in lemacs
1440
1441;; This is a large amount of code to support automatic termination of
1442;; isearch-mode when a command (however it is invoked) is not an
1443;; isearch command, or the buffer is switched out from under
1444;; isearch-mode. Only later versions of lemacs have the pre-command-hook.
1445
1446;;(if isearch-pre-command-hook-exists
1447;;(progn
1448
1449;;;; This list must be modified whenever the available commands are modified.
1450;;(mapcar (function (lambda (command)
1451;; (put command 'isearch-command t)))
1452;; '(isearch-printing-char
1453;; isearch-return-char
1454;; isearch-repeat-forward
1455;; isearch-repeat-backward
1456;; isearch-delete-char
1457;; isearch-abort
1458;; isearch-quote-char
1459;; isearch-exit
1460;; isearch-printing-char
1461;; isearch-printing-char
1462;; isearch-yank-word
1463;; isearch-yank-line
1464;; isearch-*-char
1465;; isearch-*-char
1466;; isearch-|-char
1467;; isearch-toggle-regexp
1468;; isearch-edit-string
1469;; isearch-mode-help
1470;; isearch-ring-advance
1471;; isearch-ring-retreat
1472;; isearch-ring-advance-edit
1473;; isearch-ring-retreat-edit
1474;; isearch-whitespace-chars
1475;; isearch-complete
1476;; isearch-complete-edit
1477;; isearch-edit-string
1478;; isearch-toggle-regexp
1479;; ;; The following may not be needed since isearch-mode is off already.
1480;; isearch-forward-exit-minibuffer
1481;; isearch-reverse-exit-minibuffer
1482;; isearch-nonincremental-exit-minibuffer))
1483
1484;;(defun isearch-pre-command-hook ()
1485;; ;;
1486;; ;; For use as the value of `pre-command-hook' when isearch-mode is active.
1487;; ;; If the command about to be executed is not one of the isearch commands,
1488;; ;; then isearch-mode is turned off before that command is executed.
1489;; ;;
1490;; ;; If the command about to be executed is self-insert-command, or is a
1491;; ;; keyboard macro of a single key sequence which is bound to self-insert-
1492;; ;; command, then we add those chars to the search ring instead of inserting
1493;; ;; them in the buffer. In this way, the set of self-searching characters
1494;; ;; need not be exhaustively enumerated, but is derived from other maps.
1495;; ;;
1496;; (isearch-maybe-frob-keyboard-macros)
1497;; (if (and (symbolp this-command)
1498;; (get this-command 'isearch-command))
1499;; nil
1500;; (isearch-done)))
1501
1502;;(defun isearch-maybe-frob-keyboard-macros ()
1503;; ;;
1504;; ;; If the command about to be executed is `self-insert-command' then change
1505;; ;; the command to `isearch-printing-char' instead, meaning add the last-
1506;; ;; typed character to the search string.
1507;; ;;
1508;; ;; If `this-command' is a string or a vector (that is, a keyboard macro)
1509;; ;; and it contains only one command, which is bound to self-insert-command,
1510;; ;; then do the same thing as for self-inserting commands: arrange for that
1511;; ;; character to be added to the search string. If we didn't do this, then
1512;; ;; typing a compose sequence (a la x-compose.el) would terminate the search
1513;; ;; and insert the character, instead of searching for that character.
1514;; ;;
1515;; (cond ((eq this-command 'self-insert-command)
1516;; (setq this-command 'isearch-printing-char))
1517;; ((and (stringp this-command)
1518;; (eq (key-binding this-command) 'self-insert-command))
1519;; (setq last-command-char (aref this-command 0)
1520;; last-command-event (character-to-event last-command-char)
1521;; this-command 'isearch-printing-char))
1522;; ((and (vectorp this-command)
1523;; (eq (key-binding this-command) 'self-insert-command))
1524;; (let* ((desc (aref this-command 0))
1525;; (code (cond ((integerp desc) desc)
1526;; ((symbolp desc) (get desc character-set-property))
1527;; ((consp desc)
1528;; (and (null (cdr desc))
1529;; (get (car desc) character-set-property)))
1530;; (t nil))))
1531;; (if code
1532;; (setq last-command-char code
1533;; last-command-event (character-to-event last-command-char)
1534;; this-command 'isearch-printing-char))))
1535;; ))
1536
1537;;))
1538
1539;;; isearch.el ends here 1398;;; isearch.el ends here