annotate lisp/gutter-items.el @ 404:2f8bb876ab1d r21-2-32

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