annotate lisp/gutter-items.el @ 398:74fd4e045ea6 r21-2-29

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