annotate lisp/gnus/gmm-utils.el @ 94614:b333cf3be3cc

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1141
author Miles Bader <miles@gnu.org>
date Sun, 04 May 2008 19:46:02 +0000
parents 0088cf1fdefd
children f42ef85caf91
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
79708
1cb31606209f Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78486
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
4
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
5 ;; Author: Reiner Steib <reiner.steib@gmx.de>
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
6 ;; Keywords: news
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
7
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
9
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
78224
24202b793a08 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 76836
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
13 ;; any later version.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
14
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
18 ;; GNU General Public License for more details.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
19
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
23 ;; Boston, MA 02110-1301, USA.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
24
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
25 ;;; Commentary:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
26
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
27 ;; 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
28 ;; 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
29 ;; dependencies on Gnus, Message, or MML.
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
30
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
31 ;;; Code:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
32
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
33 (require 'wid-edit)
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
34
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
35 (defgroup gmm nil
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
36 "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
37 :prefix "gmm-"
73224
36dcde72adad Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70720
diff changeset
38 :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
39 :group 'lisp)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
40
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
41 ;; 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
42
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
43 (defcustom gmm-verbose 7
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
44 "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
45 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
46 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
47 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
48 jabbering all the time."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
49 :type 'integer
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
50 :group 'gmm)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
51
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
52 ;;;###autoload
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
53 (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
54 "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
55 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
56 (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
57 nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
58 ((stringp regexp)
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 ((listp regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
61 (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
62 regexp
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
63 "\\|"))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
64
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78486
diff changeset
65 ;;;###autoload
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
66 (defun gmm-message (level &rest args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
67 "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
68
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
69 Guideline for numbers:
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
70 1 - error messages
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
71 3 - non-serious error messages
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
72 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
73 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
74 9 - messages inside loops."
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
75 (if (<= level gmm-verbose)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
76 (apply 'message args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
77 ;; 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
78 ;; 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
79 ;; from `message'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
80 (apply 'format args)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
81
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
82 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
83 (defun gmm-error (level &rest args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
84 "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
85 ARGS are passed to `message'."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
86 (when (<= (floor level) gmm-verbose)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
87 (apply 'message args)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
88 (ding)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
89 (let (duration)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
90 (when (and (floatp level)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
91 (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
92 (sit-for duration))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
93 nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
94
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
95 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
96 (defun gmm-widget-p (symbol)
78486
f0a07da7dd45 Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78224
diff changeset
97 "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
98 (get symbol 'widget-type))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
99
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
100 ;; 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
101 (define-widget 'gmm-lazy 'default
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
102 "Base widget for recursive datastructures.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
103
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
104 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
105 :format "%{%t%}: %v"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
106 :convert-widget 'widget-value-convert-widget
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
107 :value-create (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
108 (let ((value (widget-get widget :value))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
109 (type (widget-get widget :type)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
110 (widget-put widget :children
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
111 (list (widget-create-child-value
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
112 widget (widget-convert type) value)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
113 :value-delete 'widget-children-value-delete
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
114 :value-get (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
115 (widget-value (car (widget-get widget :children))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
116 :value-inline (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
117 (widget-apply (car (widget-get widget :children))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
118 :value-inline))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
119 :default-get (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
120 (widget-default-get
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
121 (widget-convert (widget-get widget :type))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
122 :match (lambda (widget value)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
123 (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
124 :match value))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
125 :validate (lambda (widget)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
126 (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
127
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
128 ;; 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
129 ;; 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
130 ;; interface.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
131
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
132 ;; 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
133 ;; 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
134 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
135 ;; (:none command-without-modifier
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
136 ;; :shift command-with-shift-pressed
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
137 ;; :control command-with-ctrl-pressed
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
138 ;; :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
139 ;; ;; 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
140 ;; :mouse-2 command-on-mouse-2-press
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
141 ;; :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
142 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
143 ;; 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
144 ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
145 ;; 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
146
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
147 (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
148 "Tool bar list item."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
149 :tag "Tool bar item"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
150 :type '(choice
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
151 (list :tag "Command and Icon"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
152 (function :tag "Command")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
153 (string :tag "Icon file")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
154 (choice
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
155 (const :tag "Default map" nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
156 ;; 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
157 (const :tag "No menu" t)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
158 (sexp :tag "Other map"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
159 (plist :inline t :tag "Properties"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
160 (list :tag "Separator"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
161 (const :tag "No command" gmm-ignore)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
162 (string :tag "Icon file")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
163 (const :tag "No map")
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
164 (plist :inline t :tag "Properties"))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
165
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
166 (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
167 "Tool bar zap list."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
168 :tag "Tool bar zap list"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
169 :type '(choice (const :tag "Zap all" t)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
170 (const :tag "Keep all" nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
171 (list
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
172 ;; :value
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
173 ;; Work around (bug in customize?), see
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
174 ;; <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
175 ;; (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
176 ;; print-buffer customize help)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
177 (set :inline t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
178 (const new-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
179 (const open-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
180 (const dired)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
181 (const kill-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
182 (const save-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
183 (const write-file)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
184 (const undo)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
185 (const cut)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
186 (const copy)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
187 (const paste)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
188 (const search-forward)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
189 (const print-buffer)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
190 (const customize)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
191 (const help))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
192 (repeat :inline t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
193 :tag "Other"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
194 (symbol :tag "Icon item")))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
195
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
196 ;; (defun gmm-color-cells (&optional display)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
197 ;; "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
198 ;; Compatibility function."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
199 ;; ;; `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
200 ;; ;; > 8 in Emacs 21.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
201 ;; ;;
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
202 ;; ;; Feel free to add proper XEmacs support.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
203 ;; (let* ((cells (and (fboundp 'display-color-cells)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
204 ;; (display-color-cells display)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
205 ;; (plane (and (fboundp 'x-display-planes)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
206 ;; (ash 1 (x-display-planes))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
207 ;; (none -1))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
208 ;; (max (if (integerp cells) cells none)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
209 ;; (if (integerp plane) plane none))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
210
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
211 (defcustom gmm-tool-bar-style
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
212 (if (and (boundp 'tool-bar-mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
213 tool-bar-mode
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
214 (and (fboundp 'display-visual-class)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
215 (not (memq (display-visual-class)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
216 (list 'static-gray 'gray-scale
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
217 'static-color 'pseudo-color)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
218 'gnome
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
219 'retro)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
220 "Prefered tool bar style."
75149
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
221 :type '(choice (const :tag "GNOME style" gnome)
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
222 (const :tag "Retro look" retro))
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
223 :group 'gmm)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
224
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
225 (defvar tool-bar-map)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
226
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
227 ;;;###autoload
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
228 (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
229 "Make a tool bar from ICON-LIST.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
230
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
231 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
232 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
233 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
234 <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
235 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
236 function `tool-bar-local-item'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
237
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
238 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
239 `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
240 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
241 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
242 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
243
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
244 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
245 (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
246 ;; could use some other local variable.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
247 (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
248 (make-sparse-keymap)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
249 (copy-keymap tool-bar-map))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
250 (when (listp zap-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
251 ;; 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
252 (dolist (key zap-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
253 (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
254 (mapc (lambda (el)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
255 (let ((command (car el))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
256 (icon (nth 1 el))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
257 (fmap (or (nth 2 el) default-map))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
258 (props (cdr (cdr (cdr el)))) )
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
259 ;; command may stem from different from-maps:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
260 (cond ((eq command 'gmm-ignore)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
261 ;; 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
262 ;; widget. Suppress tooltip by adding `:enable nil'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
263 (if (fboundp 'tool-bar-local-item)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
264 (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
265 tool-bar-map :enable nil props)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
266 ;; (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
267 ;; (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
268 (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
269 ((equal fmap t) ;; Not a menu command
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
270 (if (fboundp 'tool-bar-local-item)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
271 (apply 'tool-bar-local-item
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
272 icon command
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
273 (intern icon) ;; reuse icon or fmap here?
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
274 tool-bar-map props)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
275 ;; Emacs 21 compatibility:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
276 (apply 'tool-bar-add-item
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
277 icon command
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
278 (intern icon)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
279 props)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
280 (t ;; A menu command
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
281 (if (fboundp 'tool-bar-local-item-from-menu)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
282 (apply 'tool-bar-local-item-from-menu
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
283 ;; (apply 'tool-bar-local-item icon def key
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
284 ;; tool-bar-map props)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
285 command icon tool-bar-map (symbol-value fmap)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
286 props)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
287 ;; Emacs 21 compatibility:
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
288 (apply 'tool-bar-add-item-from-menu
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
289 command icon (symbol-value fmap)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
290 props))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
291 t))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
292 (if (symbolp icon-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
293 (eval icon-list)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
294 icon-list))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
295 tool-bar-map))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
296
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
297 (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
298 "Create function NAME.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
299 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
300 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
301 (let ((defined-p (fboundp function)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
302 (if defined-p
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
303 `(defalias ',name ',function)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
304 `(defun ,name ,arg-list ,@body))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
305
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
306 (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
307 image-search-load-path (file &optional path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
308 "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
309 This function returns nil on those systems."
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
310 nil)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
311
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
312 ;; 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
313
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
314 (defun-gmm gmm-image-load-path-for-library
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
315 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
316 "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
317
70720
414922f8ea46 (wid-edit): Require.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70051
diff changeset
318 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
319 \"`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
320 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
321 \"../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
322 in \"`data-directory'/images\".
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
323
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
324 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
325 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
326 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
327 `load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
328
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
329 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
330 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
331 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
332
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
333 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
334 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
335 `image-load-path':
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
336
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
337 ;; Shush compiler.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
338 (defvar image-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
339
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
340 (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
341 (image-load-path (cons (car load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
342 (when (boundp 'image-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
343 image-load-path))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
344 (mh-tool-bar-folder-buttons-init))"
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
345 (unless library (error "No library specified"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
346 (unless image (error "No image specified"))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
347 (let (image-directory image-directory-load-path)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
348 ;; 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
349 (let ((img image)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
350 (dir (or
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
351 ;; Images in image-load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
352 (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
353 ;; Images in load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
354 (locate-library image)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
355 parent)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
356 ;; 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
357 ;; example, mail/attach.pbm), adjust `image-directory'
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
358 ;; accordingly.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
359 (when dir
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
360 (setq dir (file-name-directory dir))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
361 (while (setq parent (file-name-directory img))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
362 (setq img (directory-file-name parent)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
363 dir (expand-file-name "../" dir))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
364 (setq image-directory-load-path dir))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
365
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
366 ;; 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
367 ;; 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
368 ;; relative setting if possible; otherwise, use
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
369 ;; `image-directory-load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
370 (cond
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
371 ;; User-modified image-load-path?
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
372 ((and image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
373 (not (equal image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
374 (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
375 (expand-file-name "images" data-directory)))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
376 (setq image-directory image-directory-load-path))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
377 ;; Try relative setting.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
378 ((let (library-name d1ei d2ei)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
379 ;; First, find library in the load-path.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
380 (setq library-name (locate-library library))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
381 (if (not library-name)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
382 (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
383 ;; 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
384 (setq
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
385 ;; Go down 2 levels.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
386 d2ei (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
387 (expand-file-name
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
388 (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
389 ;; Go down 1 level.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
390 d1ei (file-name-as-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
391 (expand-file-name
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
392 (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
393 (setq image-directory
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
394 ;; 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
395 (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
396 ((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
397 ;; Use Emacs' image directory.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
398 (image-directory-load-path
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
399 (setq image-directory image-directory-load-path))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
400 (no-error
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
401 (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
402 (t
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
403 (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
404
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
405 ;; Return an augmented `path' or `load-path'.
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
406 (nconc (list image-directory)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
407 (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
408
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
409 (defun gmm-customize-mode (&optional mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
410 "Customize customization group for MODE.
94552
0088cf1fdefd (gmm, gmm-verbose, gmm-lazy, gmm-customize-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
411 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
412 (interactive)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
413 (customize-group
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
414 (or mode
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
415 (intern (let ((mode (symbol-name major-mode)))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
416 (string-match "^\\(.+\\)-mode$" mode)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
417 (match-string 1 mode))))))
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
418
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
419 (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
420 lockname mustbenew)
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
421 "Compatibility function for `write-region'.
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
422
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
423 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
424 coding-system."
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
425 (if (and mustbenew
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
426 (or (featurep 'xemacs)
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
427 (= emacs-major-version 20)))
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
428 (if (file-exists-p filename)
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
429 (signal 'file-already-exists
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
430 (list "File exists" filename))
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
431 (write-region start end filename append visit lockname))
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
432 (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
433
70051
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
434 (provide 'gmm-utils)
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
435
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
436 ;; arch-tag: e0b60920-2ce6-40c1-bfc0-cadbbe26b602
700b1f9b81e2 [ Merge Gnome tool bars from Gnus trunk ]
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff changeset
437 ;;; gmm-utils.el ends here