annotate lisp/vm/vm-search19.el @ 152:4c132ee2d62b

Added tag r20-3b2 for changeset 59463afc5666
author cvs
date Mon, 13 Aug 2007 09:37:21 +0200
parents 131b0175ea99
children 2d532a89d707
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Incremental search through a mail folder (for Lucid and FSF Emacs 19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1994 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-isearch-forward (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Incrementally search forward through the current folder's messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Usage is identical to the standard Emacs incremental search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 When the search terminates the message containing point will be selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 If the variable vm-search-using-regexps is non-nil, regular expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 are understood; nil means the search will be for the input string taken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 literally. Specifying a prefix ARG interactively toggles the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 vm-search-using-regexps for this search."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (let ((vm-search-using-regexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (if arg (not vm-search-using-regexps) vm-search-using-regexps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (vm-isearch t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defun vm-isearch-backward (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "Incrementally search backward through the current folder's messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Usage is identical to the standard Emacs incremental search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 When the search terminates the message containing point will be selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 If the variable vm-search-using-regexps is non-nil, regular expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 are understood; nil means the search will be for the input string taken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 literally. Specifying a prefix ARG interactively toggles the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 vm-search-using-regexps for this search."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (let ((vm-search-using-regexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if arg (not vm-search-using-regexps) vm-search-using-regexps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (vm-isearch nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defun vm-isearch (forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (vm-display (current-buffer) t '(vm-isearch-forward vm-isearch-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (list this-command 'searching-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((clip-head (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (clip-tail (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (old-vm-message-pointer vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (progn (select-window (vm-get-visible-buffer-window (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (add-hook 'pre-command-hook 'vm-isearch-widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; order is significant, we want to narrow after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; the update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (add-hook 'post-command-hook 'vm-isearch-narrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (add-hook 'post-command-hook 'vm-isearch-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (isearch-mode forward vm-search-using-regexps nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (vm-isearch-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (if (not (eq vm-message-pointer old-vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (vm-record-and-change-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 old-vm-message-pointer vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; vm-show-current-message only adjusts (point-max),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; it doesn't change (point-min).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (< (point) (vm-vheaders-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (vm-start-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (vm-vheaders-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (vm-text-end-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (vm-display nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 '(vm-isearch-forward vm-isearch-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 '(reading-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; turn the unwinds into a noop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq old-vm-message-pointer vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq clip-head (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (setq clip-tail (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (remove-hook 'pre-command-hook 'vm-isearch-widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (remove-hook 'post-command-hook 'vm-isearch-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (remove-hook 'post-command-hook 'vm-isearch-narrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (narrow-to-region clip-head clip-tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (setq vm-message-pointer old-vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun vm-isearch-widen ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (widen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defun vm-isearch-narrow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (if (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (< (point) (vm-vheaders-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (vm-start-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (vm-vheaders-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (vm-text-end-of (car vm-message-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun vm-isearch-update ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if (and (>= (point) (vm-start-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (<= (point) (vm-end-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (and (>= point (vm-start-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (<= point (vm-end-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq vm-message-pointer mp mp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq mp (cdr mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (setq vm-need-summary-pointer-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (vm-update-summary-and-mode-line)))))