annotate lisp/gutter-items.el @ 438:84b14dcb0985 r21-2-27

Import from CVS: tag r21-2-27
author cvs
date Mon, 13 Aug 2007 11:32:25 +0200
parents a5df635868b2
children 8de8e3f6228a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; gutter-items.el --- Gutter content for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1999 Andy Piper.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: frames, extensions, internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with Xmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;; Some of this is taken from the buffer-menu stuff in menubar-items.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;; and the custom specs in toolbar.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 (defgroup gutter nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 "Input from the gutters."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 (defcustom gutter-visible-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 (specifier-instance default-gutter-visible-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 "Whether the default gutter is globally visible. This option can be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 customized through the options menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 :group 'display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 :set #'(lambda (var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 (set-specifier default-gutter-visible-p val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (setq gutter-visible-p val)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
43 (defvar gutter-buffers-tab nil
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
44 "A tab widget in the gutter for displaying buffers.
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
45 Do not set this. Use `glyph-image-instance' and
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
46 `set-image-instance-property' to change the properties of the tab.")
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
47
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (defcustom default-gutter-position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (default-gutter-position)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 "The location of the default gutter. It can be 'top, 'bottom, 'left or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 'right. This option can be customized through the options menu."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 :group 'display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 :type '(choice (const :tag "top" 'top)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (const :tag "bottom" 'bottom)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (const :tag "left" 'left)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (const :tag "right" 'right))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 :set #'(lambda (var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (set-default-gutter-position val)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
59 (setq default-gutter-position val)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
60 (when gutter-buffers-tab (update-tab-in-gutter))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 ;;; The Buffers tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (defgroup buffers-tab nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 "Customization of `Buffers' tab."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 :group 'gutter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
68 (defvar gutter-buffers-tab-orientation 'top
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
69 "Where the buffers tab currently is. Do not set this.")
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
70
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
71 (defvar gutter-buffers-tab-extent nil)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (defcustom buffers-tab-max-size 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 "*Maximum number of entries which may appear on the \"Buffers\" tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 If this is 10, then only the ten most-recently-selected buffers will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 shown. If this is nil, then all buffers will be shown. Setting this to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 a large number or nil will slow down tab responsiveness."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 :type '(choice (const :tag "Show all" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (integer 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (defcustom buffers-tab-switch-to-buffer-function 'buffers-tab-switch-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 "*The function to call to select a buffer from the buffers tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 `switch-to-buffer' is a good choice, as is `pop-to-buffer'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 :type '(radio (function-item switch-to-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (function-item pop-to-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (function :tag "Other"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (defcustom buffers-tab-omit-function 'buffers-menu-omit-invisible-buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 "*If non-nil, a function specifying the buffers to omit from the buffers tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 This is passed a buffer and should return non-nil if the buffer should be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 omitted. The default value `buffers-tab-omit-invisible-buffers' omits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 buffers that are normally considered \"invisible\" (those whose name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 begins with a space)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 :type '(choice (const :tag "None" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (defcustom buffers-tab-selection-function 'select-buffers-tab-buffers-by-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 "*If non-nil, a function specifying the buffers to select from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 buffers tab. This is passed two buffers and should return non-nil if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 the second buffer should be selected. The default value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 `select-buffers-tab-buffers-by-mode' groups buffers by major mode and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 by `buffers-tab-grouping-regexp'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 :type '(choice (const :tag "None" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
111 (make-face 'buffers-tab "Face for displaying the buffers tab.")
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
112 (set-face-parent 'buffers-tab 'default)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
113
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
114 (defcustom buffers-tab-face 'buffers-tab
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 "*Face to use for displaying the buffers tab."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 :type 'face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (defcustom buffers-tab-grouping-regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 '("^\\(gnus-\\|message-mode\\|mime/viewer-mode\\)"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 "^\\(emacs-lisp-\\|lisp-\\)")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "*If non-nil, a list of regular expressions for buffer grouping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 Each regular expression is applied to the current major-mode symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 name and mode-name, if it matches then any other buffers that match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 the same regular expression be added to the current group."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 :type '(choice (const :tag "None" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 sexp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (defcustom buffers-tab-format-buffer-line-function 'format-buffers-tab-line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 "*The function to call to return a string to represent a buffer in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 buffers tab. The function is passed a buffer and should return a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 string. The default value `format-buffers-tab-line' just returns the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 name of the buffer, optionally truncated to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 `buffers-tab-max-buffer-line-length'. Also check out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 `slow-format-buffers-menu-line' which returns a whole bunch of info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 about a buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 :type 'function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 :group 'buffers-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (defvar buffers-tab-default-buffer-line-length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (make-specifier-and-init 'generic '((global ((default) . 25))) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 "*Maximum length of text which may appear in a \"Buffers\" tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 This is a specifier, use set-specifier to modify it.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (defcustom buffers-tab-max-buffer-line-length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (specifier-instance buffers-tab-default-buffer-line-length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 "*Maximum length of text which may appear in a \"Buffers\" tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 Buffer names over this length will be truncated with elipses.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 If this is 0, then the full buffer name will be shown."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 :type '(choice (const :tag "Show all" 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (integer 25))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 :group 'buffers-tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 :set #'(lambda (var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (set-specifier buffers-tab-default-buffer-line-length val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (setq buffers-tab-max-buffer-line-length val)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (defun buffers-tab-switch-to-buffer (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 "For use as a value for `buffers-tab-switch-to-buffer-function'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (unless (eq (window-buffer) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (if (> (length (windows-of-buffer buffer)) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (select-window (car (windows-of-buffer buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (switch-to-buffer buffer t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (defun select-buffers-tab-buffers-by-mode (buf1 buf2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 "For use as a value of `buffers-tab-selection-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 This selects buffers by major mode `buffers-tab-grouping-regexp'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (let ((mode1 (symbol-name (symbol-value-in-buffer 'major-mode buf1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (mode2 (symbol-name (symbol-value-in-buffer 'major-mode buf2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (modenm1 (symbol-value-in-buffer 'mode-name buf1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (modenm2 (symbol-value-in-buffer 'mode-name buf2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (cond ((or (eq mode1 mode2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (eq modenm1 modenm2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (and (string-match "^[^-]+-" mode1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (string-match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (concat "^" (regexp-quote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (substring mode1 0 (match-end 0))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 mode2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (and buffers-tab-grouping-regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (find-if #'(lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (and (string-match x mode1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (string-match x mode2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (and (string-match x modenm1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (string-match x modenm2))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 buffers-tab-grouping-regexp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (t nil))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (defun format-buffers-tab-line (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 "For use as a value of `buffers-tab-format-buffer-line-function'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 This just returns the buffer's name, optionally truncated."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (let ((len (specifier-instance buffers-tab-default-buffer-line-length)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (if (and (> len 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (> (length (buffer-name buffer)) len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (concat (substring (buffer-name buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 0 (- len 3)) "...")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (buffer-name buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (defsubst build-buffers-tab-internal (buffers)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (let (line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 #'(lambda (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (setq line (funcall buffers-tab-format-buffer-line-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (vector line (list buffers-tab-switch-to-buffer-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (buffer-name buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 buffers)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (defun buffers-tab-items (&optional in-deletion frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 "This is the tab filter for the top-level buffers \"Buffers\" tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 It dynamically creates a list of buffers to use as the contents of the tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 Only the most-recently-used few buffers will be listed on the tab, for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 efficiency reasons. You can control how many buffers will be shown by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 setting `buffers-tab-max-size'. You can control the text of the tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 items by redefining the function `format-buffers-menu-line'."
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
217 (save-match-data
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
218 (let* ((buffers (delete-if buffers-tab-omit-function (buffer-list frame)))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
219 (first-buf (car buffers)))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
220 ;; if we're in deletion ignore the current buffer
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
221 (when in-deletion
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
222 (setq buffers (delq (current-buffer) buffers))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
223 (setq first-buf (car buffers)))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
224 ;; group buffers by mode
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
225 (when buffers-tab-selection-function
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
226 (delete-if-not #'(lambda (buf)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
227 (funcall buffers-tab-selection-function
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
228 first-buf buf)) buffers))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
229 (and (integerp buffers-tab-max-size)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
230 (> buffers-tab-max-size 1)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
231 (> (length buffers) buffers-tab-max-size)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
232 ;; shorten list of buffers
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
233 (setcdr (nthcdr buffers-tab-max-size buffers) nil))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
234 (setq buffers (build-buffers-tab-internal buffers))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
235 buffers)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (defun add-tab-to-gutter ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 "Put a tab control in the gutter area to hold the most recent buffers."
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
239 (setq gutter-buffers-tab-orientation (default-gutter-position))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (let ((gutter-string ""))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
241 (unless gutter-buffers-tab-extent
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
242 (setq gutter-buffers-tab-extent (make-extent 0 0 gutter-string)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (set-extent-begin-glyph
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
244 gutter-buffers-tab-extent
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (setq gutter-buffers-tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (vector 'tab-control :descriptor "Buffers" :face buffers-tab-face
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
248 :orientation gutter-buffers-tab-orientation
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 :properties (list :items (buffers-tab-items))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 ;; This looks better than a 3d border
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (mapcar '(lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (when (valid-image-instantiator-format-p 'tab-control x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 (set-specifier default-gutter-border-width 0 'global x)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
254 (set-specifier top-gutter nil 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
255 (set-specifier bottom-gutter nil 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
256 (set-specifier left-gutter nil 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
257 (set-specifier right-gutter nil 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
258 (set-specifier left-gutter-width 0 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
259 (set-specifier right-gutter-width 0 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
260 (cond ((eq gutter-buffers-tab-orientation 'top)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
261 (set-specifier top-gutter gutter-string 'global x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
262 ((eq gutter-buffers-tab-orientation 'bottom)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
263 (set-specifier bottom-gutter gutter-string 'global x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
264 ((eq gutter-buffers-tab-orientation 'left)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
265 (set-specifier left-gutter gutter-string 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
266 (set-specifier left-gutter-width
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
267 (glyph-width gutter-buffers-tab)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
268 'global x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
269 ((eq gutter-buffers-tab-orientation 'right)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
270 (set-specifier right-gutter gutter-string 'global x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
271 (set-specifier right-gutter-width
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
272 (glyph-width gutter-buffers-tab)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
273 'global x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
274 )))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (console-type-list))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (defun update-tab-in-gutter (&optional frame-or-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 "Update the tab control in the gutter area."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (let ((locale (if (framep frame-or-buffer) frame-or-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (when (specifier-instance default-gutter-visible-p locale)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
281 (unless (and gutter-buffers-tab
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
282 (eq (default-gutter-position)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
283 gutter-buffers-tab-orientation))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (add-tab-to-gutter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (when (valid-image-instantiator-format-p 'tab-control)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (let ((inst (glyph-image-instance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 gutter-buffers-tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (when (framep frame-or-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (last-nonminibuf-window frame-or-buffer)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (set-image-instance-property inst :items
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (buffers-tab-items
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
292 nil locale)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (defun remove-buffer-from-gutter-tab ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 "Remove the current buffer from the tab control in the gutter area."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (when (and (valid-image-instantiator-format-p 'tab-control)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (specifier-instance default-gutter-visible-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (let ((inst (glyph-image-instance gutter-buffers-tab))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (buffers (buffers-tab-items t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (unless buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (setq buffers (build-buffers-tab-internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (get-buffer-create "*scratch*")))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
304 (set-image-instance-property inst :items buffers))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (add-hook 'kill-buffer-hook 'remove-buffer-from-gutter-tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (add-hook 'create-frame-hook 'update-tab-in-gutter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (add-hook 'record-buffer-hook 'update-tab-in-gutter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 ;; progress display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 ;; ripped off from message display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (defvar progress-stack nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 "An alist of label/string pairs representing active progress gauges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 The first element in the list is currently displayed in the gutter area.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Do not modify this directly--use the `progress' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 `display-progress'/`clear-progress' functions.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (defvar progress-glyph-height 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 "Height of the gutter area for progress messages.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (defvar progress-stop-callback 'progress-quit-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 "Function to call to stop the progress operation.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (defun progress-quit-function ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 "Default function to call for the stop button in a progress gauge.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 This just removes the progress gauge and calls quit."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (clear-progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (keyboard-quit))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 ;; private variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (defvar progress-gauge-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (vector 'progress-gauge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 :pixel-height (- progress-glyph-height 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 :pixel-width 250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 :descriptor "Progress")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (defvar progress-text-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (make-glyph [string :data ""]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (defvar progress-layout-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 (vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 'layout :orientation 'vertical :justify 'left
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 :items (list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 progress-text-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 'layout :pixel-height progress-glyph-height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 :orientation 'horizontal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 :items (list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 progress-gauge-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 'button :pixel-height (- progress-glyph-height 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 :descriptor " Stop "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 :callback '(funcall progress-stop-callback)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (defvar progress-abort-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (vector 'layout :orientation 'vertical :justify 'left
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 :items (list progress-text-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (make-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (vector 'layout
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 :pixel-height progress-glyph-height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 :orientation 'horizontal))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (defvar progress-extent-text "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (defvar progress-extent nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (defun progress-displayed-p (&optional return-string frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 "Return a non-nil value if a progress gauge is presently displayed in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 gutter area. If optional argument RETURN-STRING is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 return a string containing the message, otherwise just return t."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (let ((buffer (get-buffer-create " *Gutter Area*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (and (< (point-min buffer) (point-max buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (if return-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (buffer-substring nil nil buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;;; Returns the string which remains in the echo area, or nil if none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 ;;; If label is nil, the whole message stack is cleared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (defun clear-progress (&optional label frame no-restore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 "Remove any progress gauge with the given LABEL from the progress gauge-stack,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 erasing it from the gutter area if it's currently displayed there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 If a message remains at the head of the progress-stack and NO-RESTORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 is nil, it will be displayed. The string which remains in the gutter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 area will be returned, or nil if the progress-stack is now empty.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 If LABEL is nil, the entire progress-stack is cleared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 Unless you need the return value or you need to specify a label,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 you should just use (progress nil)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (remove-progress label frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (let ((inhibit-read-only t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (zmacs-region-stays zmacs-region-stays)) ; preserve from change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (erase-buffer " *Echo Area*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (erase-buffer (get-buffer-create " *Gutter Area*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (if no-restore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 nil ; just preparing to put another msg up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (if progress-stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (let ((oldmsg (cdr (car progress-stack))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (raw-append-progress oldmsg frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 oldmsg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 ;; nothing to display so get rid of the gauge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (set-specifier bottom-gutter-border-width 0 frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (set-specifier bottom-gutter-visible-p nil frame))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (defun remove-progress (&optional label frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ;; If label is nil, we want to remove all matching progress gauges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (while (and progress-stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (or (null label) ; null label means clear whole stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (eq label (car (car progress-stack)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (setq progress-stack (cdr progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (let ((s progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (while (cdr s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (let ((msg (car (cdr s))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (if (eq label (car msg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (setcdr s (cdr (cdr s))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (setq s (cdr s)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (defun append-progress (label message &optional value frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 ;; Add a new entry to the message-stack, or modify an existing one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 (let* ((top (car progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (tmsg (cdr top)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (if (eq label (car top))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (setcdr top message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 (if (eq tmsg message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (set-image-instance-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (glyph-image-instance progress-gauge-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 :percent value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (raw-append-progress message value frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (redisplay-gutter-area)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (when (input-pending-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (dispatch-event (next-command-event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (push (cons label message) progress-stack)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (raw-append-progress message value frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (when (eq value 100)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (sit-for 0.5 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (clear-progress label))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (defun abort-progress (label message &optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 ;; Add a new entry to the message-stack, or modify an existing one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (let* ((top (car progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (inhibit-read-only t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (zmacs-region-stays zmacs-region-stays))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (if (eq label (car top))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (setcdr top message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (push (cons label message) progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (unless (equal message "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (insert-string message (get-buffer-create " *Gutter Area*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 ;; Do what the device is able to cope with.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (if (not (valid-image-instantiator-format-p 'progress-gauge frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (insert-string message " *Echo Area*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (if (not executing-kbd-macro)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (redisplay-echo-area)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 ;; do some funky display here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (unless progress-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (setq progress-extent (make-extent 0 0 progress-extent-text)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 (let ((bglyph (extent-begin-glyph progress-extent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (set-extent-begin-glyph progress-extent progress-abort-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 ;; fixup the gutter specifiers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (set-specifier bottom-gutter progress-extent-text frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (set-specifier bottom-gutter-border-width 2 frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (set-image-instance-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (glyph-image-instance progress-text-glyph) :data message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (set-specifier bottom-gutter-height 'autodetect frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (set-specifier bottom-gutter-visible-p t frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 ;; we have to do this so redisplay is up-to-date and so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 ;; redisplay-gutter-area performs optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (redisplay-gutter-area)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (sit-for 0.5 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (clear-progress label)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (set-extent-begin-glyph progress-extent bglyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 )))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (defun raw-append-progress (message &optional value frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (unless (equal message "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (let ((inhibit-read-only t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (zmacs-region-stays zmacs-region-stays)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (val (or value 0))) ; preserve from change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (insert-string message (get-buffer-create " *Gutter Area*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ;; Do what the device is able to cope with.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (if (not (valid-image-instantiator-format-p 'progress-gauge frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (insert-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (concat message (if (eq val 100) "done.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (make-string (/ val 5) ?.))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 " *Echo Area*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (if (not executing-kbd-macro)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (redisplay-echo-area)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 ;; do some funky display here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (unless progress-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (setq progress-extent (make-extent 0 0 progress-extent-text))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (set-extent-begin-glyph progress-extent progress-layout-glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 ;; fixup the gutter specifiers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (set-specifier bottom-gutter progress-extent-text frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (set-specifier bottom-gutter-border-width 2 frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (set-image-instance-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (glyph-image-instance progress-gauge-glyph) :percent val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (set-image-instance-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (glyph-image-instance progress-text-glyph) :data message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (if (and (eq (specifier-instance bottom-gutter-height frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 'autodetect)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (specifier-instance bottom-gutter-visible-p frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 ;; if the gauge is already visible then just draw the gutter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 ;; checking for user events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (redisplay-gutter-area)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (when (input-pending-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (dispatch-event (next-command-event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 ;; otherwise make the gutter visible and redraw the frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (set-specifier bottom-gutter-height 'autodetect frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (set-specifier bottom-gutter-visible-p t frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 ;; we have to do this so redisplay is up-to-date and so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 ;; redisplay-gutter-area performs optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (redisplay-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 )))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (defun display-progress (label message &optional value frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 "Display a progress gauge and message in the bottom gutter area.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 First argument LABEL is an identifier for this message. MESSAGE is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 the string to display. Use `clear-progress' to remove a labelled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 message."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 (clear-progress label frame t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (if (eq value 'abort)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (abort-progress label message frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 (append-progress label message value frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (defun current-progress (&optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 "Return the current progress gauge in the gutter area, or nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 The FRAME argument is currently unused."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (cdr (car progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 ;;; may eventually be frame-dependent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 (defun current-progress-label (&optional frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 (car (car progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 (defun progress (fmt &optional value &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 "Print a progress gauge and message in the bottom gutter area of the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 The arguments are the same as to `format'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 If the only argument is nil, clear any existing progress gauge."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (if (and (null fmt) (null args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (prog1 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (clear-progress nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (let ((str (apply 'format fmt args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (display-progress 'progress str value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 str)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (defun lprogress (label fmt &optional value &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 "Print a progress gauge and message in the bottom gutter area of the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 First argument LABEL is an identifier for this progress gauge. The rest of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 arguments are the same as to `format'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (if (and (null fmt) (null args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (prog1 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 (clear-progress label nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (let ((str (apply 'format fmt args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 (display-progress label str value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 str)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 (provide 'gutter-items)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 ;;; gutter-items.el ends here.