annotate lisp/gutter-items.el @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents b8cc9ab3f761
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
1 ;;; gutter-items.el --- Gutter content for XEmacs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
4 ;; Copyright (C) 1999, 2000 Andy Piper.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
5
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
7 ;; Keywords: frames, extensions, internal, dumped
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
8
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
10
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
14 ;; any later version.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
15
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
19 ;; General Public License for more details.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
20
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
22 ;; along with Xmacs; see the file COPYING. If not, write to the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
25
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
26 ;; Some of this is taken from the buffer-menu stuff in menubar-items.el
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
27
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
28 ;;; The Buffers tab
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
29
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
30 (defgroup buffers-tab nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
31 "Customization of `Buffers' tab."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
32 :group 'gutter)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
33
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
34 (defvar gutter-buffers-tab nil
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
35 "A tab widget in the gutter for displaying buffers.
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
36 Do not set this. Use `set-glyph-image' to change the properties of the tab.")
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
37
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
38 (defcustom gutter-buffers-tab-visible-p
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
39 (gutter-element-visible-p default-gutter-visible-p 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
40 "Whether the buffers tab is globally visible.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
41 This option should be set through the options menu."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
42 :group 'buffers-tab
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
43 :type 'boolean
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
44 :set #'(lambda (var val)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
45 (set-gutter-element-visible-p default-gutter-visible-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
46 'buffers-tab val)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
47 (setq gutter-buffers-tab-visible-p val)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
48
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
49 (defvar gutter-buffers-tab-orientation 'top
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
50 "Where the buffers tab currently is. Do not set this.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
51
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
52 (defvar gutter-buffers-tab-extent nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
53
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
54 (defcustom buffers-tab-max-size 6
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
55 "*Maximum number of entries which may appear on the \"Buffers\" tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
56 If this is 10, then only the ten most-recently-selected buffers will be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
57 shown. If this is nil, then all buffers will be shown. Setting this to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
58 a large number or nil will slow down tab responsiveness."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
59 :type '(choice (const :tag "Show all" nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
60 (integer 6))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
61 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
62
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
63 (defcustom buffers-tab-switch-to-buffer-function 'buffers-tab-switch-to-buffer
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
64 "*The function to call to select a buffer from the buffers tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
65 `switch-to-buffer' is a good choice, as is `pop-to-buffer'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
66 :type '(radio (function-item switch-to-buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
67 (function-item pop-to-buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
68 (function :tag "Other"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
69 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
70
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
71 (defcustom buffers-tab-omit-function 'buffers-menu-omit-invisible-buffers
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
72 "*If non-nil, a function specifying the buffers to omit from the buffers tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
73 This is passed a buffer and should return non-nil if the buffer should be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
74 omitted. The default value `buffers-tab-omit-invisible-buffers' omits
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
75 buffers that are normally considered \"invisible\" (those whose name
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
76 begins with a space)."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
77 :type '(choice (const :tag "None" nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
78 function)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
79 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
80
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
81 (defcustom buffers-tab-selection-function 'select-buffers-tab-buffers-by-mode
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
82 "*If non-nil, a function specifying the buffers to select from the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
83 buffers tab. This is passed two buffers and should return non-nil if
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
84 the second buffer should be selected. The default value
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
85 `select-buffers-tab-buffers-by-mode' groups buffers by major mode and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
86 by `buffers-tab-grouping-regexp'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
87
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
88 :type '(choice (const :tag "None" nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
89 function)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
90 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
91
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
92 (defcustom buffers-tab-sort-function nil
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
93 "*If non-nil, a function specifying the buffers to select from the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
94 buffers tab. This is passed the buffer list and returns the list in the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
95 order desired for the tab widget. The default value `nil' leaves the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
96 list in `buffer-list' order (usual most-recently-selected-first)."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
97
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
98 :type '(choice (const :tag "None" nil)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
99 function)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
100 :group 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
101
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
102 (make-face 'buffers-tab "Face for displaying the buffers tab.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
103 (set-face-parent 'buffers-tab 'default)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
104
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
105 (defcustom buffers-tab-face 'buffers-tab
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
106 "*Face to use for displaying the buffers tab."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
107 :type 'face
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
108 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
109
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
110 (defcustom buffers-tab-grouping-regexp
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
111 '("^\\(gnus-\\|message-mode\\|mime/viewer-mode\\)"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
112 "^\\(emacs-lisp-\\|lisp-\\)")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
113 "*If non-nil, a list of regular expressions for buffer grouping.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
114 Each regular expression is applied to the current major-mode symbol
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
115 name and mode-name, if it matches then any other buffers that match
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
116 the same regular expression be added to the current group."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
117 :type '(choice (const :tag "None" nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
118 sexp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
119 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
120
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
121 (defcustom buffers-tab-format-buffer-line-function 'format-buffers-tab-line
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
122 "*The function to call to return a string to represent a buffer in the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
123 buffers tab. The function is passed a buffer and should return a
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
124 string. The default value `format-buffers-tab-line' just returns the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
125 name of the buffer, optionally truncated to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
126 `buffers-tab-max-buffer-line-length'. Also check out
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
127 `slow-format-buffers-menu-line' which returns a whole bunch of info
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
128 about a buffer."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
129 :type 'function
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
130 :group 'buffers-tab)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
131
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
132 (defvar buffers-tab-default-buffer-line-length
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
133 (make-specifier-and-init 'generic '((global ((default) . 25))) t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
134 "*Maximum length of text which may appear in a \"Buffers\" tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
135 This is a specifier, use set-specifier to modify it.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
136
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
137 (defcustom buffers-tab-max-buffer-line-length
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
138 (specifier-instance buffers-tab-default-buffer-line-length)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
139 "*Maximum length of text which may appear in a \"Buffers\" tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
140 Buffer names over this length will be truncated with elipses.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
141 If this is 0, then the full buffer name will be shown."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
142 :type '(choice (const :tag "Show all" 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
143 (integer 25))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
144 :group 'buffers-tab
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
145 :set #'(lambda (var val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
146 (set-specifier buffers-tab-default-buffer-line-length val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
147 (setq buffers-tab-max-buffer-line-length val)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
148
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
149 (defun buffers-tab-switch-to-buffer (buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
150 "For use as a value for `buffers-tab-switch-to-buffer-function'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
151 (unless (eq (window-buffer) buffer)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
152 ;; this used to add the norecord flag to both calls below.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
153 ;; this is bogus because it is a pervasive assumption in XEmacs
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
154 ;; that the current buffer is at the front of the buffers list.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
155 ;; for example, select an item and then do M-C-l
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
156 ;; (switch-to-other-buffer). Things get way confused.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
157 ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
158 ;; Andy, if you want to maintain the current look, you must
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
159 ;; *uncouple* the gutter order and buffers order.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
160 (if (> (length (windows-of-buffer buffer)) 0)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
161 (select-window (car (windows-of-buffer buffer)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
162 (switch-to-buffer buffer))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
163
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
164 (defun select-buffers-tab-buffers-by-mode (buf1 buf2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
165 "For use as a value of `buffers-tab-selection-function'.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
166 This selects buffers by major mode `buffers-tab-grouping-regexp'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
167 (let ((mode1 (symbol-name (symbol-value-in-buffer 'major-mode buf1)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
168 (mode2 (symbol-name (symbol-value-in-buffer 'major-mode buf2)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
169 (modenm1 (symbol-value-in-buffer 'mode-name buf1))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
170 (modenm2 (symbol-value-in-buffer 'mode-name buf2)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
171 (cond ((or (eq mode1 mode2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
172 (eq modenm1 modenm2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
173 (and (string-match "^[^-]+-" mode1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
174 (string-match
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
175 (concat "^" (regexp-quote
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
176 (substring mode1 0 (match-end 0))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
177 mode2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
178 (and buffers-tab-grouping-regexp
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
179 (find-if #'(lambda (x)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
180 (or
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
181 (and (string-match x mode1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
182 (string-match x mode2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
183 (and (string-match x modenm1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
184 (string-match x modenm2))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
185 buffers-tab-grouping-regexp)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
186 t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
187 (t nil))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
188
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
189 (defun format-buffers-tab-line (buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
190 "For use as a value of `buffers-tab-format-buffer-line-function'.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
191 This just returns the buffer's name, optionally truncated."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
192 (let ((len (specifier-instance buffers-tab-default-buffer-line-length)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
193 (if (and (> len 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
194 (> (length (buffer-name buffer)) len))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
195 (if (string-match ".*<.>$" (buffer-name buffer))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
196 (concat (substring (buffer-name buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
197 0 (- len 6)) "..."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
198 (substring (buffer-name buffer) -3))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
199 (concat (substring (buffer-name buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
200 0 (- len 3)) "..."))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
201 (buffer-name buffer))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
202
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
203 (defsubst build-buffers-tab-internal (buffers)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
204 (let ((selected t))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
205 (mapcar
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
206 #'(lambda (buffer)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
207 (prog1
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
208 (vector
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
209 (funcall buffers-tab-format-buffer-line-function
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
210 buffer)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
211 (list buffers-tab-switch-to-buffer-function
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
212 (buffer-name buffer))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
213 :selected selected)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
214 (when selected (setq selected nil))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
215 buffers)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
216
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
217 ;;; #### SJT I'd really like this function to have just two hooks: (1) the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
218 ;;; buffer filter list and (2) a sort function list. Both should be lists
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
219 ;;; of functions. Each filter takes two arguments: a buffer and a model
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
220 ;;; buffer. (The model buffer argument allows selecting according to the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
221 ;;; mode or directory of that buffer.) The filter returns t if the buffer
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
222 ;;; should be listed and nil otherwise. Effectively the filter amounts to
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
223 ;;; the conjuction of the filter list. (Optionally the filter could take a
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
224 ;;; frame instead of a buffer or generalize to a locale as in a specifier?)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
225 ;;; The filtering is done this way to preserve the ordering imposed by
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
226 ;;; `buffer-list'. In addition, the in-deletion argument will be used the
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
227 ;;; same way as in the current design.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
228 ;;; The list is checked for length and pruned according to least-recently-
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
229 ;;; selected. (Optionally there could be some kind of sort function here,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
230 ;;; too.)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
231 ;;; Finally the list is sorted to gutter display order, and the tab data
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
232 ;;; structure is created and returned.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
233 ;;; #### Docstring isn't very well expressed.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
234 (defun buffers-tab-items (&optional in-deletion frame force-selection)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
235 "This is the tab filter for the top-level buffers \"Buffers\" tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
236 It dynamically creates a list of buffers to use as the contents of the tab.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
237 Only the most-recently-used few buffers will be listed on the tab, for
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
238 efficiency reasons. You can control how many buffers will be shown by
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
239 setting `buffers-tab-max-size'. You can control the text of the tab
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
240 items by redefining the function `format-buffers-menu-line'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
241 (save-match-data
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
242 (let* ((buffers (delete-if buffers-tab-omit-function (buffer-list frame)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
243 (first-buf (car buffers)))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
244 ;; maybe force the selected window
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
245 (when (and force-selection
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
246 (not in-deletion)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
247 (not (eq first-buf (window-buffer (selected-window frame)))))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
248 (setq buffers (cons (window-buffer (selected-window frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
249 (delq first-buf buffers))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
250 ;; if we're in deletion ignore the current buffer
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
251 (when in-deletion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
252 (setq buffers (delq (current-buffer) buffers))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
253 (setq first-buf (car buffers)))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
254 ;; select buffers in group (default is by mode)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
255 (when buffers-tab-selection-function
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
256 (delete-if-not #'(lambda (buf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
257 (funcall buffers-tab-selection-function
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
258 first-buf buf)) buffers))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
259 ;; maybe shorten list of buffers
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
260 (and (integerp buffers-tab-max-size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
261 (> buffers-tab-max-size 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
262 (> (length buffers) buffers-tab-max-size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
263 (setcdr (nthcdr buffers-tab-max-size buffers) nil))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
264 ;; sort buffers in group (default is most-recently-selected)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
265 (when buffers-tab-sort-function
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
266 (setq buffers (funcall buffers-tab-sort-function buffers)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
267 ;; convert list of buffers to list of structures used by tab widget
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
268 (setq buffers (build-buffers-tab-internal buffers))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
269 buffers)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
270
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
271 (defun add-tab-to-gutter ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
272 "Put a tab control in the gutter area to hold the most recent buffers."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
273 (setq gutter-buffers-tab-orientation (default-gutter-position))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
274 (let ((gutter-string (copy-sequence "\n")))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
275 (unless gutter-buffers-tab-extent
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
276 (setq gutter-buffers-tab-extent (make-extent 0 1 gutter-string)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
277 (set-extent-begin-glyph
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
278 gutter-buffers-tab-extent
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
279 (setq gutter-buffers-tab
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
280 (make-glyph)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
281
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
282 ;; Nuke all existing tabs
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
283 (remove-gutter-element top-gutter 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
284 (remove-gutter-element bottom-gutter 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
285 (remove-gutter-element left-gutter 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
286 (remove-gutter-element right-gutter 'buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
287 ;; Put tabs into all devices that will be able to display them
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
288 (mapcar
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
289 #'(lambda (x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
290 (when (valid-image-instantiator-format-p 'tab-control x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
291 (cond ((eq gutter-buffers-tab-orientation 'top)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
292 ;; This looks better than a 3d border
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
293 (set-specifier top-gutter-border-width 0 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
294 (set-gutter-element top-gutter 'buffers-tab
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
295 gutter-string 'global x))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
296 ((eq gutter-buffers-tab-orientation 'bottom)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
297 (set-specifier bottom-gutter-border-width 0 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
298 (set-gutter-element bottom-gutter 'buffers-tab
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
299 gutter-string 'global x))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
300 ((eq gutter-buffers-tab-orientation 'left)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
301 (set-specifier left-gutter-border-width 0 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
302 (set-gutter-element left-gutter 'buffers-tab
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
303 gutter-string 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
304 (set-specifier left-gutter-width
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
305 (glyph-width gutter-buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
306 'global x))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
307 ((eq gutter-buffers-tab-orientation 'right)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
308 (set-specifier right-gutter-border-width 0 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
309 (set-gutter-element right-gutter 'buffers-tab
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
310 gutter-string 'global x)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
311 (set-specifier right-gutter-width
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
312 (glyph-width gutter-buffers-tab)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
313 'global x))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
314 )))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
315 (console-type-list))))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
316
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
317 (defun update-tab-in-gutter (frame &optional force-selection)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
318 "Update the tab control in the gutter area."
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
319 ;; dedicated frames don't get tabs
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
320 (unless (window-dedicated-p (frame-selected-window frame))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
321 (when (specifier-instance default-gutter-visible-p frame)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
322 (unless (and gutter-buffers-tab
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
323 (eq (default-gutter-position)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
324 gutter-buffers-tab-orientation))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
325 (add-tab-to-gutter))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
326 (when (valid-image-instantiator-format-p 'tab-control frame)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
327 (set-glyph-image
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
328 gutter-buffers-tab
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
329 (vector 'tab-control :descriptor "Buffers" :face buffers-tab-face
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
330 :orientation gutter-buffers-tab-orientation
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
331 (if (or (eq gutter-buffers-tab-orientation 'top)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
332 (eq gutter-buffers-tab-orientation 'bottom))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
333 :pixel-width :pixel-height)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
334 (if (or (eq gutter-buffers-tab-orientation 'top)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
335 (eq gutter-buffers-tab-orientation 'bottom))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
336 '(gutter-pixel-width) '(gutter-pixel-height))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
337 :properties
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
338 (list :items
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
339 (buffers-tab-items nil frame force-selection)))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
340 frame)))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
341
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
342 ;; A myriad of different update hooks all doing slightly different things
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
343 (add-hook 'create-frame-hook
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
344 #'(lambda (frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
345 (when gutter-buffers-tab (update-tab-in-gutter frame t))))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
346 (add-hook 'buffer-list-changed-hook 'update-tab-in-gutter)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
347 (add-hook 'default-gutter-position-changed-hook
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
348 #'(lambda ()
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
349 (when gutter-buffers-tab
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
350 (mapc #'update-tab-in-gutter (frame-list)))))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
351 (add-hook 'gutter-element-visibility-changed-hook
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
352 #'(lambda (prop visible-p)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
353 (when (and (eq prop 'buffers-tab) visible-p)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
354 (mapc #'update-tab-in-gutter (frame-list)))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
355 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
356 ;; progress display
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
357 ;; ripped off from message display
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
358 ;;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
359 (defcustom progress-display-use-echo-area nil
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
360 "*Whether progress gauge display should display in the echo area.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
361 If NIL then progress gauges will be displayed with whatever native widgets
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
362 are available on the current console. If non-NIL then progress display will be
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
363 textual and displayed in the echo area."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
364 :type 'boolean
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
365 :group 'gutter)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
366
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
367 (defvar progress-glyph-height 24
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
368 "Height of the progress gauge glyph.")
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
369
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
370 (defvar progress-display-popup-period 0.5
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
371 "The time that the progress gauge should remain up after completion")
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
372
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
373 ;; private variables
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
374 (defvar progress-text-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
375 (make-glyph [string :data ""]))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
376
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
377 (defvar progress-layout-glyph nil)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
378 (defvar progress-gauge-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
379 (make-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
380 `[progress-gauge
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
381 :pixel-height (eval progress-glyph-height)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
382 :pixel-width 250
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
383 :descriptor "Progress"]))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
384
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
385 (defun set-progress-display-style (style)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
386 "Control the appearance of the progress gauge.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
387 If STYLE is 'large, the default, then the progress-display text is
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
388 displayed above the gauge itself. If STYLE is 'small then the gauge
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
389 and text are arranged side-by-side."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
390 (cond
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
391 ((eq style 'small)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
392 (setq progress-glyph-height 16)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
393 (setq progress-layout-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
394 (make-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
395 `[layout
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
396 :orientation horizontal
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
397 :margin-width 4
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
398 :items (,progress-gauge-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
399 [button
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
400 :pixel-height (eval progress-glyph-height)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
401 ;; 'quit is special and acts "asynchronously".
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
402 :descriptor "Stop" :callback 'quit]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
403 ,progress-text-glyph)])))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
404 (t
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
405 (setq progress-glyph-height 24)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
406 (setq progress-layout-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
407 (make-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
408 `[layout
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
409 :orientation vertical :justify left
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
410 :margin-width 4
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
411 :items (,progress-text-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
412 [layout
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
413 :orientation horizontal
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
414 :items (,progress-gauge-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
415 [button
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
416 :pixel-height (eval progress-glyph-height)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
417 :descriptor " Stop "
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
418 ;; 'quit is special and acts "asynchronously".
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
419 :callback 'quit])])])))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
420
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
421 (defcustom progress-display-style 'large
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
422 "*Control the appearance of the progress gauge.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
423 If 'large, the default, then the progress-display text is displayed
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
424 above the gauge itself. If 'small then the gauge and text are arranged
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
425 side-by-side."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
426 :group 'gutter
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
427 :type '(choice (const :tag "large" large)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
428 (const :tag "small" small))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
429 :set #'(lambda (var val)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
430 (set-progress-display-style val)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
431
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
432 (defvar progress-stack nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
433 "An alist of label/string pairs representing active progress gauges.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
434 The first element in the list is currently displayed in the gutter area.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
435 Do not modify this directly--use the `progress-display' or
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
436 `display-progress-display'/`clear-progress-display' functions.")
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
437
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
438 (defvar progress-abort-glyph
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
439 (make-glyph
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
440 `[layout :orientation vertical :justify left
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
441 :items (,progress-text-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
442 [layout
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
443 :margin-width 4
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
444 :pixel-height progress-glyph-height
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
445 :orientation horizontal])]))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
446
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
447 (defun progress-displayed-p (&optional return-string frame)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
448 "Return a non-nil value if a progress gauge is presently displayed in the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
449 gutter area. If optional argument RETURN-STRING is non-nil,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
450 return a string containing the message, otherwise just return t."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
451 (let ((buffer (get-buffer-create " *Gutter Area*")))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
452 (and (< (point-min buffer) (point-max buffer))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
453 (if return-string
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
454 (buffer-substring nil nil buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
455 t))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
456
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
457 ;;; Returns the string which remains in the echo area, or nil if none.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
458 ;;; If label is nil, the whole message stack is cleared.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
459 (defun clear-progress-display (&optional label frame no-restore)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
460 "Remove any progress gauge with LABEL from the progress gauge-stack,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
461 erasing it from the gutter area if it's currently displayed there.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
462 If a message remains at the head of the progress-stack and NO-RESTORE
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
463 is nil, it will be displayed. The string which remains in the gutter
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
464 area will be returned, or nil if the progress-stack is now empty.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
465 If LABEL is nil, the entire progress-stack is cleared.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
466
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
467 Unless you need the return value or you need to specify a label,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
468 you should just use (progress nil)."
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
469 (if (or (not (valid-image-instantiator-format-p 'progress-gauge frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
470 progress-display-use-echo-area)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
471 (clear-message label frame nil no-restore)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
472 (or frame (setq frame (selected-frame)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
473 (remove-progress-display label frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
474 (let ((inhibit-read-only t)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
475 (zmacs-region-stays zmacs-region-stays)) ; preserve from change
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
476 (erase-buffer (get-buffer-create " *Gutter Area*")))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
477 (if no-restore
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
478 nil ; just preparing to put another msg up
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
479 (if progress-stack
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
480 (let ((oldmsg (cdr (car progress-stack))))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
481 (raw-append-progress-display oldmsg nil frame)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
482 oldmsg)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
483 ;; nothing to display so get rid of the gauge
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
484 (set-specifier bottom-gutter-border-width 0 frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
485 (set-gutter-element-visible-p bottom-gutter-visible-p
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
486 'progress nil frame)))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
487
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
488 (defun progress-display-clear-when-idle (&optional label)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
489 (add-one-shot-hook 'pre-idle-hook
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
490 `(lambda ()
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
491 (clear-progress-display ',label))))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
492
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
493 (defun remove-progress-display (&optional label frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
494 ;; If label is nil, we want to remove all matching progress gauges.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
495 (while (and progress-stack
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
496 (or (null label) ; null label means clear whole stack
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
497 (eq label (car (car progress-stack)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
498 (setq progress-stack (cdr progress-stack)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
499 (let ((s progress-stack))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
500 (while (cdr s)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
501 (let ((msg (car (cdr s))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
502 (if (eq label (car msg))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
503 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
504 (setcdr s (cdr (cdr s))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
505 (setq s (cdr s)))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
506
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
507 (defun progress-display-dispatch-non-command-events ()
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
508 ;; don't allow errors to hose things
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
509 (condition-case t
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
510 ;; (sit-for 0) is too agressive and cause more display than we
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
511 ;; want.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
512 (dispatch-non-command-events)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
513 nil))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
514
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
515 (defun append-progress-display (label message &optional value frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
516 (or frame (setq frame (selected-frame)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
517 ;; Add a new entry to the message-stack, or modify an existing one
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
518 (let* ((top (car progress-stack))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
519 (tmsg (cdr top)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
520 (if (eq label (car top))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
521 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
522 (setcdr top message)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
523 (if (equal tmsg message)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
524 ;; #### use of set-image-instance-property is wrong.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
525 ;; use set-glyph-image instead.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
526 (set-image-instance-property
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
527 (glyph-image-instance progress-gauge-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
528 (frame-selected-window frame))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
529 :value value)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
530 (raw-append-progress-display message value frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
531 (redisplay-gutter-area))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
532 (push (cons label message) progress-stack)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
533 (raw-append-progress-display message value frame))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
534 (progress-display-dispatch-non-command-events)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
535 ;; either get command events or sit waiting for them
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
536 (when (eq value 100)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
537 ; (sit-for progress-display-popup-period nil)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
538 (clear-progress-display label))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
539
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
540 (defun abort-progress-display (label message &optional frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
541 (if (or (not (valid-image-instantiator-format-p 'progress-gauge frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
542 progress-display-use-echo-area)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
543 (display-message label (concat message "aborted.") frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
544 (or frame (setq frame (selected-frame)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
545 ;; Add a new entry to the message-stack, or modify an existing one
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
546 (let* ((top (car progress-stack))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
547 (inhibit-read-only t)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
548 (zmacs-region-stays zmacs-region-stays))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
549 (if (eq label (car top))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
550 (setcdr top message)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
551 (push (cons label message) progress-stack))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
552 (unless (equal message "")
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
553 (insert-string message (get-buffer-create " *Gutter Area*"))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
554 (let* ((gutter-string (copy-sequence "\n"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
555 (ext (make-extent 0 1 gutter-string)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
556 ;; do some funky display here.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
557 (set-extent-begin-glyph ext progress-abort-glyph)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
558 ;; fixup the gutter specifiers
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
559 (set-gutter-element bottom-gutter 'progress gutter-string frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
560 (set-specifier bottom-gutter-border-width 2 frame)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
561 ;; #### use of set-image-instance-property is wrong.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
562 ;; use set-glyph-image instead.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
563 (set-image-instance-property
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
564 (glyph-image-instance progress-text-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
565 (frame-selected-window frame)) :data message)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
566 (set-specifier bottom-gutter-height 'autodetect frame)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
567 (set-gutter-element-visible-p bottom-gutter-visible-p
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
568 'progress t frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
569 ;; we have to do this so redisplay is up-to-date and so
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
570 ;; redisplay-gutter-area performs optimally.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
571 (redisplay-gutter-area)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
572 (sit-for progress-display-popup-period nil)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
573 (clear-progress-display label frame)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
574 (set-extent-begin-glyph ext progress-layout-glyph)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
575 (set-gutter-element bottom-gutter 'progress gutter-string frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
576 )))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
577
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
578 (defun raw-append-progress-display (message &optional value frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
579 (unless (equal message "")
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
580 (let* ((inhibit-read-only t)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
581 (zmacs-region-stays zmacs-region-stays)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
582 (val (or value 0))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
583 (gutter-string (copy-sequence "\n"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
584 (ext (make-extent 0 1 gutter-string)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
585 (insert-string message (get-buffer-create " *Gutter Area*"))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
586 ;; do some funky display here.
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
587 (set-extent-begin-glyph ext progress-layout-glyph)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
588 ;; fixup the gutter specifiers
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
589 (set-gutter-element bottom-gutter 'progress gutter-string frame)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
590 (set-specifier bottom-gutter-border-width 2 frame)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
591 ;; #### use of set-image-instance-property is wrong.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
592 ;; use set-glyph-image instead.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
593 (set-image-instance-property
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
594 (glyph-image-instance progress-gauge-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
595 (frame-selected-window frame))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
596 :value val)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
597 (set-image-instance-property
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
598 (glyph-image-instance progress-text-glyph (frame-selected-window frame))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
599 :data message)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
600 (if (and (eq (specifier-instance bottom-gutter-height frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
601 'autodetect)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
602 (gutter-element-visible-p bottom-gutter-visible-p
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
603 'progress frame))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
604 ;; if the gauge is already visible then just draw the gutter
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
605 ;; checking for user events
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
606 (progn
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
607 (redisplay-gutter-area)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
608 (progress-display-dispatch-non-command-events))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
609 ;; otherwise make the gutter visible and redraw the frame
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
610 (set-specifier bottom-gutter-height 'autodetect frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
611 (set-gutter-element-visible-p bottom-gutter-visible-p
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
612 'progress t frame)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
613 ;; we have to do this so redisplay is up-to-date and so
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
614 ;; redisplay-gutter-area performs optimally. This may also
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
615 ;; make sure the frame geometry looks ok.
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
616 (progress-display-dispatch-non-command-events)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
617 (redisplay-frame frame)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
618 ))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
619
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
620 (defun display-progress-display (label message &optional value frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
621 "Display a progress gauge and message in the bottom gutter area.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
622 First argument LABEL is an identifier for this message. MESSAGE is
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
623 the string to display. Use `clear-progress-display' to remove a labelled
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
624 message."
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
625 (cond ((eq value 'abort)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
626 (abort-progress-display label message frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
627 ((or (not (valid-image-instantiator-format-p 'progress-gauge frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
628 progress-display-use-echo-area)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
629 (display-message label
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
630 (concat message (if (eq value 100) "done."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
631 (make-string (/ value 5) ?.)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
632 frame))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
633 (t
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
634 (append-progress-display label message value frame))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
635
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
636 (defun current-progress-display (&optional frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
637 "Return the current progress gauge in the gutter area, or nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
638 The FRAME argument is currently unused."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
639 (cdr (car progress-stack)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
640
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
641 ;;; may eventually be frame-dependent
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
642 (defun current-progress-display-label (&optional frame)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
643 (car (car progress-stack)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
644
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
645 (defun progress-display (fmt &optional value &rest args)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
646 "Print a progress gauge and message in the bottom gutter area of the frame.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
647 The arguments are the same as to `format'.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
648
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
649 If the only argument is nil, clear any existing progress gauge."
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
650 (save-excursion
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
651 (if (and (null fmt) (null args))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
652 (prog1 nil
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
653 (clear-progress-display nil))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
654 (let ((str (apply 'format fmt args)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
655 (display-progress-display 'progress str value)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
656 str))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
657
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
658 (defun lprogress-display (label fmt &optional value &rest args)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
659 "Print a progress gauge and message in the bottom gutter area of the frame.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
660 First argument LABEL is an identifier for this progress gauge. The rest of the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
661 arguments are the same as to `format'."
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
662 ;; #### sometimes the buffer gets changed temporarily. I don't know
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
663 ;; why this is, so protect against it.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
664 (save-excursion
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
665 (if (and (null fmt) (null args))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
666 (prog1 nil
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
667 (clear-progress-display label nil))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
668 (let ((str (apply 'format fmt args)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
669 (display-progress-display label str value)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
670 str))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
671
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
672 ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
673 ;; Simple search dialog
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
674 ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
675 (defvar search-dialog-direction t)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
676 (defvar search-dialog-text
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
677 (make-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
678 [edit-field :width 15 :descriptor "" :active t :face default]))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
679
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
680 (defun search-dialog-callback (parent image-instance event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
681 (save-selected-frame
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
682 (select-frame parent)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
683 (funcall (if search-dialog-direction
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
684 'search-forward 'search-backward)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
685 (image-instance-property
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
686 (glyph-image-instance search-dialog-text
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
687 (frame-selected-window
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
688 (event-channel event))) :text))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
689 (isearch-highlight (match-beginning 0) (match-end 0))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
690
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
691 (defun make-search-dialog ()
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
692 "Popup a search dialog box."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
693 (interactive)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
694 (let* ((parent (selected-frame)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
695 (set-buffer-dedicated-frame
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
696 (get-buffer-create "Dialog")
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
697 (make-dialog-box
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
698 (make-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
699 `[layout
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
700 :orientation horizontal :justify left
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
701 :height 10 :width 40
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
702 :border [string :data "Search"]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
703 :items
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
704 ([layout :orientation vertical :justify left
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
705 :items
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
706 ([string :data "Search for:"]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
707 [button :descriptor "Match case"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
708 :style toggle
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
709 :selected (not case-fold-search)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
710 :callback (setq case-fold-search
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
711 (not case-fold-search))]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
712 [button :descriptor "Forwards"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
713 :style radio
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
714 :selected search-dialog-direction
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
715 :callback (setq search-dialog-direction t)]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
716 [button :descriptor "Backwards"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
717 :style radio
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
718 :selected (not search-dialog-direction)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
719 :callback (setq search-dialog-direction nil)]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
720 )]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
721 [layout :orientation vertical :justify left
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
722 :items
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
723 (search-dialog-text
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
724 [button :width 10 :descriptor "Find Next"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
725 :callback-ex
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
726 (lambda (image-instance event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
727 (search-dialog-callback ,parent
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
728 image-instance event))]
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
729 [button :width 10 :descriptor "Cancel"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
730 :callback-ex
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
731 (lambda (image-instance event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
732 (isearch-dehighlight)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
733 (delete-frame
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
734 (event-channel event)))])])])
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
735 '(height 10 width 40)))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
736
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
737 (provide 'gutter-items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
738 ;;; gutter-items.el ends here.