annotate lisp/gnus/gmm-utils.el @ 112284:61f7601898b1

Refill some copyright headers.
author Glenn Morris <rgm@gnu.org>
date Sat, 15 Jan 2011 18:21:30 -0800
parents 417b1e4d63cd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
1 ;;; gmm-utils.el --- Utility functions for Gnus, Message and MML
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
2
112284
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
4 ;; Free Software Foundation, Inc.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
5
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
6 ;; Author: Reiner Steib <reiner.steib@gmx.de>
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
7 ;; Keywords: news
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
8
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
10
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94552
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94552
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94552
diff changeset
14 ;; (at your option) any later version.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
15
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94552
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
19 ;; GNU General Public License for more details.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
20
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94552
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
23
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
24 ;;; Commentary:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
25
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
26 ;; This library provides self-contained utility functions. The functions are
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
27 ;; used in Gnus, Message and MML, but within this library there are no
76836
9feeb7a817c0 * nnmail.el (nnmail-spool-file): Mark as obsolete.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 75347
diff changeset
28 ;; dependencies on Gnus, Message, or MML.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
29
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
30 ;;; Code:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
31
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
32 (defgroup gmm nil
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
33 "Utility functions for Gnus, Message and MML."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
34 :prefix "gmm-"
73224
36dcde72adad Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70720
diff changeset
35 :version "22.1" ;; Gnus 5.10.9
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
36 :group 'lisp)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
37
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
38 ;; Helper functions from `gnus-utils.el': gmm-verbose, gmm-message, gmm-error
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
39
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
40 (defcustom gmm-verbose 7
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
41 "Integer that says how verbose gmm should be.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
42 The higher the number, the more messages will flash to say what
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
43 it did. At zero, it will be totally mute; at five, it will
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
44 display most important messages; and at ten, it will keep on
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
45 jabbering all the time."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
46 :type 'integer
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
47 :group 'gmm)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
48
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
49 ;;;###autoload
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
50 (defun gmm-regexp-concat (regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
51 "Potentially concat a list of regexps into a single one.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
52 The concatenation is done with logical ORs."
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
53 (cond ((null regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
54 nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
55 ((stringp regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
56 regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
57 ((listp regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
58 (mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
59 regexp
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
60 "\\|"))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
61
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
62 ;;;###autoload
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
63 (defun gmm-message (level &rest args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
64 "If LEVEL is lower than `gmm-verbose' print ARGS using `message'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
65
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
66 Guideline for numbers:
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
67 1 - error messages
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
68 3 - non-serious error messages
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
69 5 - messages for things that take a long time
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
70 7 - not very important messages on stuff
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
71 9 - messages inside loops."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
72 (if (<= level gmm-verbose)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
73 (apply 'message args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
74 ;; We have to do this format thingy here even if the result isn't
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
75 ;; shown - the return value has to be the same as the return value
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
76 ;; from `message'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
77 (apply 'format args)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
78
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
79 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
80 (defun gmm-error (level &rest args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
81 "Beep an error if LEVEL is equal to or less than `gmm-verbose'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
82 ARGS are passed to `message'."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
83 (when (<= (floor level) gmm-verbose)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
84 (apply 'message args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
85 (ding)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
86 (let (duration)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
87 (when (and (floatp level)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
88 (not (zerop (setq duration (* 10 (- level (floor level)))))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
89 (sit-for duration))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
90 nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
91
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
92 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
93 (defun gmm-widget-p (symbol)
78486
f0a07da7dd45 Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78224
diff changeset
94 "Non-nil if SYMBOL is a widget."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
95 (get symbol 'widget-type))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
96
107427
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
97 (autoload 'widget-create-child-value "wid-edit")
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
98 (autoload 'widget-convert "wid-edit")
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
99 (autoload 'widget-default-get "wid-edit")
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
100
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
101 ;; Copy of the `nnmail-lazy' code from `nnmail.el':
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
102 (define-widget 'gmm-lazy 'default
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
103 "Base widget for recursive datastructures.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
104
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
105 This is a copy of the `lazy' widget in Emacs 22.1 provided for compatibility."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
106 :format "%{%t%}: %v"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
107 :convert-widget 'widget-value-convert-widget
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
108 :value-create (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
109 (let ((value (widget-get widget :value))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
110 (type (widget-get widget :type)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
111 (widget-put widget :children
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
112 (list (widget-create-child-value
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
113 widget (widget-convert type) value)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
114 :value-delete 'widget-children-value-delete
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
115 :value-get (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
116 (widget-value (car (widget-get widget :children))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
117 :value-inline (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
118 (widget-apply (car (widget-get widget :children))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
119 :value-inline))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
120 :default-get (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
121 (widget-default-get
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
122 (widget-convert (widget-get widget :type))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
123 :match (lambda (widget value)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
124 (widget-apply (widget-convert (widget-get widget :type))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
125 :match value))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
126 :validate (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
127 (widget-apply (car (widget-get widget :children)) :validate)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
128
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
129 ;; Note: The format of `gmm-tool-bar-item' may change if some future Emacs
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
130 ;; version will provide customizable tool bar buttons using a different
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
131 ;; interface.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
132
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
133 ;; TODO: Extend API so that the "Command" entry can be a function or a plist.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
134 ;; In case of a list it should have the format...
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
135 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
136 ;; (:none command-without-modifier
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
137 ;; :shift command-with-shift-pressed
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
138 ;; :control command-with-ctrl-pressed
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
139 ;; :control-shift command-with-control-and-shift-pressed
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
140 ;; ;; mouse-2 and mouse-3 can't be used in Emacs yet.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
141 ;; :mouse-2 command-on-mouse-2-press
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
142 ;; :mouse-3 command-on-mouse-3-press) ;; typically a menu of related commands
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
143 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
144 ;; Combinations of mouse-[23] plus shift and/or controll might be overkill.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
145 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
146 ;; Then use (plist-get rs-command :none), (plist-get rs-command :shift)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
147
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
148 (define-widget 'gmm-tool-bar-item (if (gmm-widget-p 'lazy) 'lazy 'gmm-lazy)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
149 "Tool bar list item."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
150 :tag "Tool bar item"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
151 :type '(choice
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
152 (list :tag "Command and Icon"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
153 (function :tag "Command")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
154 (string :tag "Icon file")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
155 (choice
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
156 (const :tag "Default map" nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
157 ;; Note: Usually we need non-nil attributes if map is t.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
158 (const :tag "No menu" t)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
159 (sexp :tag "Other map"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
160 (plist :inline t :tag "Properties"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
161 (list :tag "Separator"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
162 (const :tag "No command" gmm-ignore)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
163 (string :tag "Icon file")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
164 (const :tag "No map")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
165 (plist :inline t :tag "Properties"))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
166
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
167 (define-widget 'gmm-tool-bar-zap-list (if (gmm-widget-p 'lazy) 'lazy 'gmm-lazy)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
168 "Tool bar zap list."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
169 :tag "Tool bar zap list"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
170 :type '(choice (const :tag "Zap all" t)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
171 (const :tag "Keep all" nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
172 (list
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
173 ;; :value
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
174 ;; Work around (bug in customize?), see
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
175 ;; <news:v9is48jrj1.fsf@marauder.physik.uni-ulm.de>
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
176 ;; (new-file open-file dired kill-buffer write-file
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
177 ;; print-buffer customize help)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
178 (set :inline t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
179 (const new-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
180 (const open-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
181 (const dired)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
182 (const kill-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
183 (const save-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
184 (const write-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
185 (const undo)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
186 (const cut)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
187 (const copy)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
188 (const paste)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
189 (const search-forward)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
190 (const print-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
191 (const customize)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
192 (const help))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
193 (repeat :inline t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
194 :tag "Other"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
195 (symbol :tag "Icon item")))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
196
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
197 ;; (defun gmm-color-cells (&optional display)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
198 ;; "Return the number of color cells supported by DISPLAY.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
199 ;; Compatibility function."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
200 ;; ;; `display-color-cells' doesn't return more than 256 even if color depth is
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
201 ;; ;; > 8 in Emacs 21.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
202 ;; ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
203 ;; ;; Feel free to add proper XEmacs support.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
204 ;; (let* ((cells (and (fboundp 'display-color-cells)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
205 ;; (display-color-cells display)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
206 ;; (plane (and (fboundp 'x-display-planes)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
207 ;; (ash 1 (x-display-planes))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
208 ;; (none -1))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
209 ;; (max (if (integerp cells) cells none)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
210 ;; (if (integerp plane) plane none))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
211
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
212 (defcustom gmm-tool-bar-style
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
213 (if (and (boundp 'tool-bar-mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
214 tool-bar-mode
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
215 (and (fboundp 'display-visual-class)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
216 (not (memq (display-visual-class)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
217 (list 'static-gray 'gray-scale
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
218 'static-color 'pseudo-color)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
219 'gnome
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
220 'retro)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
221 "Prefered tool bar style."
75149
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
222 :type '(choice (const :tag "GNOME style" gnome)
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
223 (const :tag "Retro look" retro))
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
224 :group 'gmm)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
225
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
226 (defvar tool-bar-map)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
227
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
228 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
229 (defun gmm-tool-bar-from-list (icon-list zap-list default-map)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
230 "Make a tool bar from ICON-LIST.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
231
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
232 Within each entry of ICON-LIST, the first element is a menu
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
233 command, the second element is an icon file name and the third
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
234 element is a test function. You can use \\[describe-key]
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
235 <menu-entry> to find out the name of a menu command. The fourth
76836
9feeb7a817c0 * nnmail.el (nnmail-spool-file): Mark as obsolete.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 75347
diff changeset
236 and all following elements are passed as the PROPS argument to the
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
237 function `tool-bar-local-item'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
238
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
239 If ZAP-LIST is a list, remove those item from the default
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
240 `tool-bar-map'. If it is t, start with a new sparse map. You
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
241 can use \\[describe-key] <icon> to find out the name of an icon
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
242 item. When \\[describe-key] <icon> shows \"<tool-bar> <new-file>
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
243 runs the command find-file\", then use `new-file' in ZAP-LIST.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
244
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
245 DEFAULT-MAP specifies the default key map for ICON-LIST."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
246 (let (;; For Emacs 21, we must let-bind `tool-bar-map'. In Emacs 22, we
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
247 ;; could use some other local variable.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
248 (tool-bar-map (if (eq zap-list t)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
249 (make-sparse-keymap)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
250 (copy-keymap tool-bar-map))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
251 (when (listp zap-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
252 ;; Zap some items which aren't relevant for this mode and take up space.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
253 (dolist (key zap-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
254 (define-key tool-bar-map (vector key) nil)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
255 (mapc (lambda (el)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
256 (let ((command (car el))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
257 (icon (nth 1 el))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
258 (fmap (or (nth 2 el) default-map))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
259 (props (cdr (cdr (cdr el)))) )
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
260 ;; command may stem from different from-maps:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
261 (cond ((eq command 'gmm-ignore)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
262 ;; The dummy `gmm-ignore', see `gmm-tool-bar-item'
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
263 ;; widget. Suppress tooltip by adding `:enable nil'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
264 (if (fboundp 'tool-bar-local-item)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
265 (apply 'tool-bar-local-item icon nil nil
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
266 tool-bar-map :enable nil props)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
267 ;; (tool-bar-local-item ICON DEF KEY MAP &rest PROPS)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
268 ;; (tool-bar-add-item ICON DEF KEY &rest PROPS)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
269 (apply 'tool-bar-add-item icon nil nil :enable nil props)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
270 ((equal fmap t) ;; Not a menu command
110542
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
271 (apply 'tool-bar-local-item
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
272 icon command
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
273 (intern icon) ;; reuse icon or fmap here?
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
274 tool-bar-map props))
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
275 (t ;; A menu command
110542
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
276 (apply 'tool-bar-local-item-from-menu
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
277 ;; (apply 'tool-bar-local-item icon def key
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
278 ;; tool-bar-map props)
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
279 command icon tool-bar-map (symbol-value fmap)
93f2c2c37f24 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
280 props)))
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
281 t))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
282 (if (symbolp icon-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
283 (eval icon-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
284 icon-list))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
285 tool-bar-map))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
286
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
287 (defmacro defun-gmm (name function arg-list &rest body)
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
288 "Create function NAME.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
289 If FUNCTION exists, then NAME becomes an alias for FUNCTION.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
290 Otherwise, create function NAME with ARG-LIST and BODY."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
291 (let ((defined-p (fboundp function)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
292 (if defined-p
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
293 `(defalias ',name ',function)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
294 `(defun ,name ,arg-list ,@body))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
295
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
296 (defun-gmm gmm-image-search-load-path
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
297 image-search-load-path (file &optional path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
298 "Emacs 21 and XEmacs don't have `image-search-load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
299 This function returns nil on those systems."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
300 nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
301
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
302 ;; Cf. `mh-image-load-path-for-library' in `mh-compat.el'.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
303
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
304 (defun-gmm gmm-image-load-path-for-library
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
305 image-load-path-for-library (library image &optional path no-error)
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
306 "Return a suitable search path for images used by LIBRARY.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
307
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
308 It searches for IMAGE in `image-load-path' (excluding
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
309 \"`data-directory'/images\") and `load-path', followed by a path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
310 suitable for LIBRARY, which includes \"../../etc/images\" and
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
311 \"../etc/images\" relative to the library file itself, and then
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
312 in \"`data-directory'/images\".
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
313
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
314 Then this function returns a list of directories which contains
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
315 first the directory in which IMAGE was found, followed by the
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
316 value of `load-path'. If PATH is given, it is used instead of
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
317 `load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
318
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
319 If NO-ERROR is non-nil and a suitable path can't be found, don't
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
320 signal an error. Instead, return a list of directories as before,
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
321 except that nil appears in place of the image directory.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
322
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
323 Here is an example that uses a common idiom to provide
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
324 compatibility with versions of Emacs that lack the variable
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
325 `image-load-path':
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
326
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
327 ;; Shush compiler.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
328 (defvar image-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
329
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
330 (let* ((load-path (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
331 (image-load-path (cons (car load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
332 (when (boundp 'image-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
333 image-load-path))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
334 (mh-tool-bar-folder-buttons-init))"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
335 (unless library (error "No library specified"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
336 (unless image (error "No image specified"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
337 (let (image-directory image-directory-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
338 ;; Check for images in image-load-path or load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
339 (let ((img image)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
340 (dir (or
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
341 ;; Images in image-load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
342 (gmm-image-search-load-path image) ;; "gmm-" prefix!
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
343 ;; Images in load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
344 (locate-library image)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
345 parent)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
346 ;; Since the image might be in a nested directory (for
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
347 ;; example, mail/attach.pbm), adjust `image-directory'
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
348 ;; accordingly.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
349 (when dir
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
350 (setq dir (file-name-directory dir))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
351 (while (setq parent (file-name-directory img))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
352 (setq img (directory-file-name parent)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
353 dir (expand-file-name "../" dir))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
354 (setq image-directory-load-path dir))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
355
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
356 ;; If `image-directory-load-path' isn't Emacs' image directory,
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
357 ;; it's probably a user preference, so use it. Then use a
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
358 ;; relative setting if possible; otherwise, use
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
359 ;; `image-directory-load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
360 (cond
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
361 ;; User-modified image-load-path?
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
362 ((and image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
363 (not (equal image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
364 (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
365 (expand-file-name "images" data-directory)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
366 (setq image-directory image-directory-load-path))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
367 ;; Try relative setting.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
368 ((let (library-name d1ei d2ei)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
369 ;; First, find library in the load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
370 (setq library-name (locate-library library))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
371 (if (not library-name)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
372 (error "Cannot find library %s in load-path" library))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
373 ;; And then set image-directory relative to that.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
374 (setq
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
375 ;; Go down 2 levels.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
376 d2ei (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
377 (expand-file-name
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
378 (concat (file-name-directory library-name) "../../etc/images")))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
379 ;; Go down 1 level.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
380 d1ei (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
381 (expand-file-name
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
382 (concat (file-name-directory library-name) "../etc/images"))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
383 (setq image-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
384 ;; Set it to nil if image is not found.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
385 (cond ((file-exists-p (expand-file-name image d2ei)) d2ei)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
386 ((file-exists-p (expand-file-name image d1ei)) d1ei)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
387 ;; Use Emacs' image directory.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
388 (image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
389 (setq image-directory image-directory-load-path))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
390 (no-error
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
391 (message "Could not find image %s for library %s" image library))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
392 (t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
393 (error "Could not find image %s for library %s" image library)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
394
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
395 ;; Return an augmented `path' or `load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
396 (nconc (list image-directory)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
397 (delete image-directory (copy-sequence (or path load-path))))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
398
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
399 (defun gmm-customize-mode (&optional mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
400 "Customize customization group for MODE.
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
401 If mode is nil, use `major-mode' of the current buffer."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
402 (interactive)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
403 (customize-group
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
404 (or mode
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
405 (intern (let ((mode (symbol-name major-mode)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
406 (string-match "^\\(.+\\)-mode$" mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
407 (match-string 1 mode))))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
408
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
409 (defun gmm-write-region (start end filename &optional append visit
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
410 lockname mustbenew)
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
411 "Compatibility function for `write-region'.
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
412
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
413 In XEmacs, the seventh argument of `write-region' specifies the
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
414 coding-system."
110715
d424d0c7a36c * lisp/gnus/gmm-utils.el (gmm-write-region): Drop Emacs 20 compat cruft.
Glenn Morris <rgm@gnu.org>
parents: 110542
diff changeset
415 (if (and mustbenew (featurep 'xemacs))
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
416 (if (file-exists-p filename)
110715
d424d0c7a36c * lisp/gnus/gmm-utils.el (gmm-write-region): Drop Emacs 20 compat cruft.
Glenn Morris <rgm@gnu.org>
parents: 110542
diff changeset
417 (signal 'file-already-exists (list "File exists" filename))
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
418 (write-region start end filename append visit lockname))
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
419 (write-region start end filename append visit lockname mustbenew)))
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
420
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
421 (provide 'gmm-utils)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
422
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
423 ;;; gmm-utils.el ends here