~ubuntu-branches/debian/lenny/ecb/lenny

« back to all changes in this revision

Viewing changes to ecb-help.el

  • Committer: Bazaar Package Importer
  • Author(s): Joerg Jaspert
  • Date: 2004-02-16 23:16:24 UTC
  • Revision ID: james.westby@ubuntu.com-20040216231624-brlrnyp41twx033r
Tags: upstream-2.21
ImportĀ upstreamĀ versionĀ 2.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;; ecb-help.el --- online help for ECB and bug reporting
 
2
 
 
3
;; Copyright (C) 2000 - 2003 Jesper Nordenberg,
 
4
;;                           Klaus Berndl,
 
5
;;                           Kevin A. Burton,
 
6
;;                           Free Software Foundation, Inc.
 
7
 
 
8
;; Author: Jesper Nordenberg <mayhem@home.se>
 
9
;;         Klaus Berndl <klaus.berndl@sdm.de>
 
10
;;         Kevin A. Burton <burton@openprivacy.org>
 
11
;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
 
12
;;             Kevin A. Burton <burton@openprivacy.org>
 
13
;; Keywords: browser, code, programming, tools
 
14
;; Created: 2001
 
15
 
 
16
;; This program is free software; you can redistribute it and/or modify it under
 
17
;; the terms of the GNU General Public License as published by the Free Software
 
18
;; Foundation; either version 2, or (at your option) any later version.
 
19
 
 
20
;; This program is distributed in the hope that it will be useful, but WITHOUT
 
21
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
22
;; FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
23
;; details.
 
24
 
 
25
;; You should have received a copy of the GNU General Public License along with
 
26
;; GNU Emacs; see the file COPYING.  If not, write to the Free Software
 
27
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
28
 
 
29
;; $Id: ecb-help.el,v 1.103 2004/01/21 17:17:46 berndl Exp $
 
30
 
 
31
;;; Commentary:
 
32
;;
 
33
;; Contains all online-help for ECB (stolen something from recentf.el)
 
34
 
 
35
;;; History
 
36
;;
 
37
;; For the ChangeLog of this file see the CVS-repository. For a complete
 
38
;; history of the ECB-package see the file NEWS.
 
39
 
 
40
;;; Code
 
41
 
 
42
(eval-when-compile
 
43
  (require 'silentcomp))
 
44
 
 
45
(require 'ecb-layout)
 
46
(require 'ecb-util)
 
47
 
 
48
;; XEmacs and Emacs 20.X
 
49
(silentcomp-defvar browse-url-new-window-p)
 
50
(silentcomp-defun browse-url)
 
51
;; Emacs 21
 
52
(silentcomp-defvar browse-url-new-window-flag)
 
53
;; JDE
 
54
(silentcomp-defvar jde-version)
 
55
;; mail and reporter
 
56
(silentcomp-defun mail-subject)
 
57
(silentcomp-defun mail-text)
 
58
(silentcomp-defun reporter-submit-bug-report)
 
59
 
 
60
(defconst ecb-help-info-start-file "ecb.info")
 
61
(defconst ecb-help-html-start-file "ecb.html")
 
62
(defconst ecb-help-info-subdir "./info-help/")
 
63
(defconst ecb-help-html-subdir "./html-help/")
 
64
 
 
65
(defgroup ecb-help nil
 
66
  "Settings for the ECB online help"
 
67
  :group 'ecb)
 
68
 
 
69
(defcustom ecb-show-help-format 'info
 
70
  "*The format `ecb-show-help' shows its online help.
 
71
Allowed values are 'info \(for the Info format) and 'html \(for HTML format).
 
72
If the value is 'html then `browse-url-browser-function' says which browser is
 
73
used.
 
74
 
 
75
Note: If you got ECB as a standard XEmacs-package maybe the
 
76
HTML-online-documentation is not included."
 
77
  :group 'ecb-help
 
78
  :group 'ecb-most-important
 
79
  :type '(choice :tag "Online-help format" :menu-tag "Online-help format"
 
80
                 (const :tag "Info" :value info)
 
81
                 (const :tag "Html" :value html)))
 
82
 
 
83
 
 
84
(defcustom ecb-help-info-path (concat
 
85
                               (if ecb-running-xemacs
 
86
                                   (if (file-exists-p
 
87
                                        (concat ecb-ecb-dir
 
88
                                                ecb-help-info-subdir
 
89
                                                ecb-help-info-start-file))
 
90
                                       ecb-help-info-subdir
 
91
                                     "../../info/")
 
92
                                 ecb-help-info-subdir)
 
93
                               ecb-help-info-start-file)
 
94
  "*Path where the ECB online help in info format resides.
 
95
This must be the location of the file \"ecb.info\" which comes with the ECB
 
96
distribution. If is installed by unpacking the archive available on the ECB
 
97
web-site then this is the subdir `ecb-help-info-subdir' of the installation
 
98
directory of ECB. If it is installed as XEmacs-package \(e.g. via the package
 
99
manager of XEmacs) then this is probably the directory \"../../info/\"
 
100
\(relativ to the Elisp directory of ECB).
 
101
 
 
102
The path can either be an absolute path or a path relative to the directory
 
103
where the Elisp files of ECB are.
 
104
 
 
105
Normally there should be no need to change this option!"
 
106
  :group 'ecb-help
 
107
  :type 'file)
 
108
 
 
109
(defcustom ecb-help-html-path
 
110
  (if (not ecb-running-xemacs)
 
111
      (concat ecb-help-html-subdir ecb-help-html-start-file)
 
112
    (cond ((file-exists-p
 
113
            (concat ecb-ecb-dir
 
114
                    ecb-help-html-subdir
 
115
                    ecb-help-html-start-file))
 
116
           (concat ecb-help-html-subdir ecb-help-html-start-file))
 
117
          ((file-exists-p
 
118
            (concat ecb-ecb-dir
 
119
                    "../../html/"
 
120
                    ecb-help-html-start-file))
 
121
           (concat "../../html/" ecb-help-html-start-file))
 
122
          ((file-exists-p
 
123
            (concat ecb-ecb-dir
 
124
                    "../../html/ecb/index.html"))
 
125
           "../../html/ecb/index.html")
 
126
          (t
 
127
           (concat "../../etc/ecb/html/" ecb-help-html-start-file))))
 
128
  "*Path where the ECB online help in HTML format resides.
 
129
This must be the location of the file \"index.html\" which comes with the ECB
 
130
distribution. If is installed by unpacking the archive available on the ECB
 
131
web-site then this is the subdir `ecb-help-html-subdir' of the installation
 
132
directory of ECB. If it is installed as XEmacs-package \(e.g. via the package
 
133
manager of XEmacs) then this is probably either the directory \"../../html/\" or
 
134
\"../../etc/ecb/html/\" \(both relative to the Elisp directory of ECB).
 
135
 
 
136
The path can either be an absolute path or a path relative to the directory
 
137
where the Elisp files of ECB are.
 
138
 
 
139
Normally there should be no need to change this option!"
 
140
  :group 'ecb-help
 
141
  :type 'file)
 
142
 
 
143
 
 
144
(defun ecb-info (info-file &optional no-file-not-exist-err)
 
145
  "Starts `info' with INFO-FILE. If INFO-FILE does not exists then nil is
 
146
returned otherwise true. If NO-FILE-NOT-EXIST-ERR is not nil then just nil is
 
147
returned if INFO-FILE does not exist otherwise an error is reported."
 
148
  (if (file-exists-p info-file)
 
149
      (prog1 t
 
150
        (info info-file))
 
151
    (unless no-file-not-exist-err
 
152
      (ecb-error "Info file %s does not exists!" info-file))
 
153
    nil))
 
154
 
 
155
(defun ecb-browse-html-file (html-file &optional no-file-not-exist-err)
 
156
  "Opens HTML-FILE in the standard-webbrowser with `browse-url'. If INFO-FILE
 
157
does not exists then nil is returned otherwise true. If NO-FILE-NOT-EXIST-ERR
 
158
is not nil then just nil is returned if HTML-FILE does not exist otherwise an
 
159
error is reported."
 
160
  (if (file-exists-p html-file)
 
161
      (prog1 t
 
162
        (if (and (locate-library "browse-url")
 
163
                 (require 'browse-url)
 
164
                 (fboundp 'browse-url))
 
165
            (browse-url (concat "file://" html-file)
 
166
                        (if (boundp 'browse-url-new-window-flag)
 
167
                            browse-url-new-window-flag
 
168
                          browse-url-new-window-p))
 
169
          (ecb-error "Function 'browse-url needed for displaying HTML!")))
 
170
    (unless no-file-not-exist-err
 
171
      (ecb-error "HTML file %s does not exists!" html-file))
 
172
    nil))
 
173
 
 
174
;;;###autoload
 
175
(defun ecb-show-help (&optional format)
 
176
  "Shows the online help of ECB in Info or HTML-format.
 
177
The format depends on the setting in `ecb-show-help-format'. If called with
 
178
prefix argument, i.e. if FORMAT is not nil then the user is prompted to choose
 
179
the format of the help \(Info or Html).
 
180
 
 
181
If an error about not finding the needed help-file occurs please take a look
 
182
at the options `ecb-help-info-start-file' and `ecb-help-html-start-file'!
 
183
 
 
184
Note: If you got ECB as a standard XEmacs-package maybe the
 
185
HTML-online-documentation is not included."
 
186
  (interactive "P")
 
187
  (let ((f (if format
 
188
               (intern (ecb-query-string "Choose format of online-help:"
 
189
                                         (if (equal 'ecb-show-help-format
 
190
                                                    'html)
 
191
                                             '("info" "html")
 
192
                                           '("html" "info"))))
 
193
             ecb-show-help-format))
 
194
        (info-path-abs (expand-file-name
 
195
                        (if (or (string-match "^\\." ecb-help-info-path)
 
196
                                (string-match (concat "^"
 
197
                                                      (regexp-quote
 
198
                                                       ecb-help-info-start-file))
 
199
                                              ecb-help-info-path))
 
200
                            (concat ecb-ecb-dir ecb-help-info-path)
 
201
                          ecb-help-info-path)))
 
202
        (html-path-abs (ecb-fix-filename
 
203
                        (if (or (string-match "^\\." ecb-help-html-path)
 
204
                                (string-match (concat "^"
 
205
                                                      (regexp-quote
 
206
                                                       ecb-help-html-start-file))
 
207
                                              ecb-help-html-path))
 
208
                            (concat ecb-ecb-dir ecb-help-html-path)
 
209
                          ecb-help-html-path))))
 
210
    (if (equal f 'info)
 
211
        (ecb-info info-path-abs)
 
212
      (message "Opening ECB online-help in a web-browser...")
 
213
      (ecb-browse-html-file html-path-abs))))
 
214
 
 
215
 
 
216
;;
 
217
;; Problem reporting functions stolen from JDEE
 
218
;;
 
219
(defvar ecb-problem-report-mail-address "ecb-list@lists.sourceforge.net" )
 
220
 
 
221
(defconst ecb-problem-report-message
 
222
  "Please enter the details of your bug report here")
 
223
 
 
224
(defun ecb-submit-problem-report()
 
225
  "Submit a problem report for the ECB to the ECB mailing-list.
 
226
This command generates in the edit-window a problem-report which contains
 
227
already the current values of all ECB options, the current backtrace-buffer if
 
228
there is any and the current message-buffer. You will be asked for a
 
229
problem-report subject and then you must insert a description of the problem.
 
230
Please describe the problem as detailed as possible!"
 
231
  (interactive)
 
232
  (when (or ecb-minor-mode
 
233
            (y-or-n-p "ECB should be active when submitting a problem-report. Force report? "))
 
234
    (if (and (equal ecb-frame (selected-frame))
 
235
             (not (ecb-point-in-edit-window)))
 
236
        (ecb-select-edit-window))
 
237
    (if (not (locate-library "reporter"))
 
238
        (ecb-error "You need the reporter.el package to submit a bugreport for ECB!")
 
239
      (require 'reporter)
 
240
      (progn
 
241
        (message "Preparing problem report...")
 
242
        ;;prepare the basic buffer
 
243
        (reporter-submit-bug-report
 
244
         ecb-problem-report-mail-address
 
245
         (format "ECB: %s, semantic: %s, eieio: %s, speedbar: %s, JDEE: %s"
 
246
                 ecb-version
 
247
                 semantic-version
 
248
                 eieio-version
 
249
                 speedbar-version
 
250
                 (if (boundp 'jde-version)
 
251
                     jde-version
 
252
                   "No JDEE"))
 
253
         (ecb-problem-report-list-all-variables)
 
254
         nil
 
255
         'ecb-problem-report-post-hook
 
256
         ecb-problem-report-message)
 
257
        (if (equal ecb-frame (selected-frame))
 
258
            (ecb-redraw-layout))
 
259
        (mail-subject)
 
260
        (insert (read-string "Problem report subject: "
 
261
                             (format "ECB-%s -- " ecb-version)))
 
262
        (mail-text)
 
263
        (search-forward ecb-problem-report-message)
 
264
        (end-of-line)
 
265
        (message "Preparing bug report...done")))))
 
266
 
 
267
(defun ecb-problem-report-post-hook()
 
268
  "Function run the reporter package done its work. It looks for a message- and
 
269
a backtrace-buffer and inserts the contents of that."
 
270
  (save-excursion
 
271
    (beginning-of-buffer)
 
272
    ;; if the mail-packages has already inserted a signature we must not go to
 
273
    ;; the buffer-end but just before the signature
 
274
    (if (re-search-forward "^--[ \t]*$" nil t)
 
275
        (progn
 
276
          (beginning-of-line)
 
277
          (insert "\n\n\n")
 
278
          (forward-line -2))
 
279
      (goto-char (point-max))
 
280
      (insert "\n\n"))
 
281
    ;; ecb-faces
 
282
    (let ((ecb-face-list (delq nil (mapcar (function
 
283
                                            (lambda (f)
 
284
                                              (if (string-match "^ecb-"
 
285
                                                                (symbol-name f))
 
286
                                                  f
 
287
                                                nil)))
 
288
                                           (face-list)))))
 
289
      (insert "\n\n-----------------------------------------------------\n")
 
290
      (insert "The attributes of the ECB-faces are:\n\n")
 
291
      (dolist (f ecb-face-list)
 
292
        (when f
 
293
          (insert (format "%s: %s\n"
 
294
                          (symbol-name f)
 
295
                          (funcall (if ecb-running-xemacs
 
296
                                       'face-custom-attributes-get
 
297
                                     'custom-face-attributes-get)
 
298
                                   f ecb-frame)))))
 
299
      (insert "\n-----------------------------------------------------\n\n"))
 
300
    (let* ((messages-buffer 
 
301
            (get-buffer
 
302
             (if ecb-running-xemacs " *Message-Log*" "*Messages*")))
 
303
           (backtrace-buffer (get-buffer "*Backtrace*")))
 
304
 
 
305
      ;;insert the contents of the backtrace buffer if it is there. 
 
306
      (insert "\n\n-----------------------------------------------------\n")
 
307
      (if backtrace-buffer
 
308
          (progn
 
309
            (insert "The contents of the *Backtrace* buffer were\n\n")
 
310
            (insert-buffer backtrace-buffer)
 
311
            ;; we must force the mark
 
312
            (goto-char (mark t))
 
313
            (insert "\nEnd Insert *Backtrace* buffer" ))
 
314
        (insert "There was no *Backtrace* buffer" ))
 
315
      (insert "\n-----------------------------------------------------\n\n")
 
316
 
 
317
      ;;insert the contents of the messages buffer if it is there. 
 
318
      (insert "-----------------------------------------------------\n")
 
319
      (if messages-buffer
 
320
          (progn
 
321
            (insert "The contents of the *Messages* buffer were\n\n")
 
322
            (insert-buffer messages-buffer)
 
323
            (goto-char (mark t))
 
324
            (insert "\nEnd Insert *Messages* buffer" ))
 
325
        (insert "There was no *Messages* buffer" ))
 
326
      (insert  "\n-----------------------------------------------------\n\n"))))
 
327
 
 
328
 
 
329
(defun ecb-problem-report-list-all-variables()
 
330
  "List all variables starting with `ecb-' and some other variables which
 
331
could be interesting for support."
 
332
  (let ((emacs-vars (sort (delete nil
 
333
                                  `(pre-command-hook
 
334
                                    post-command-hook
 
335
                                    after-save-hook
 
336
                                    help-mode-hook
 
337
                                    compilation-mode-hook
 
338
                                    truncate-partial-width-windows
 
339
                                    truncate-lines
 
340
                                    ,(if (boundp 'compilation-window-height)
 
341
                                         'compilation-window-height)
 
342
                                    ,(if (boundp 'temp-buffer-max-height)
 
343
                                         'temp-buffer-max-height)
 
344
                                    auto-mode-alist
 
345
                                    ,(if (boundp 'c-mode-hook)
 
346
                                         'c-mode-hook)
 
347
                                    ,(if (boundp 'c++-mode-hook)
 
348
                                         'c++-mode-hook)
 
349
                                    ,(if (boundp 'c-mode-common-hook)
 
350
                                         'c-mode-common-hook)
 
351
                                    ,(if (boundp 'java-mode-hook)
 
352
                                         'java-mode-hook)
 
353
                                    ,(if (boundp 'jde-mode-hook)
 
354
                                         'jde-mode-hook)
 
355
                                    system-type
 
356
                                    window-system
 
357
                                    max-specpdl-size
 
358
                                    max-lisp-eval-depth
 
359
                                    ,(if (boundp 'ediff-quit-hook)
 
360
                                         'ediff-quit-hook)))
 
361
                          (function (lambda (l r)
 
362
                                      (string< (symbol-name l)
 
363
                                               (symbol-name r))))))
 
364
        (semantic-vars (sort (delete nil
 
365
                                     `(semantic-after-toplevel-cache-change-hook
 
366
                                       semantic-after-partial-cache-change-hook
 
367
                                       ,(if (boundp 'semantic-format-face-alist)
 
368
                                            'semantic-format-face-alist
 
369
                                          'semantic-face-alist)
 
370
                                       semantic-uml-colon-string
 
371
                                       semantic-orphaned-member-metaparent-type))
 
372
                             (function (lambda (l r)
 
373
                                         (string< (symbol-name l)
 
374
                                                  (symbol-name r))))))
 
375
        (speedbar-vars (sort '(speedbar-dynamic-tags-function-list
 
376
                               speedbar-tag-hierarchy-method
 
377
                               speedbar-tag-group-name-minimum-length
 
378
                               speedbar-tag-split-minimum-length
 
379
                               speedbar-tag-regroup-maximum-length
 
380
                               speedbar-fetch-etags-command
 
381
                               speedbar-fetch-etags-arguments
 
382
                               speedbar-fetch-etags-parse-list)
 
383
                             (function (lambda (l r)
 
384
                                         (string< (symbol-name l)
 
385
                                                  (symbol-name r))))))
 
386
        (ecb-options (mapcar
 
387
                      'intern
 
388
                      (sort
 
389
                       (let (completion-ignore-case)
 
390
                         (all-completions "ecb-" obarray 'user-variable-p))
 
391
                       'string-lessp)))
 
392
        (ecb-internal-vars (sort '(ecb-path-selected-directory
 
393
                                   ecb-path-selected-source
 
394
                                   ecb-use-semantic-grouping
 
395
                                   ecb-idle-timer-alist
 
396
                                   ecb-post-command-hooks
 
397
                                   ecb-max-specpdl-size-old
 
398
                                   ecb-max-lisp-eval-depth-old
 
399
                                   ecb-minor-mode
 
400
                                   ecb-last-window-config-before-deactivation
 
401
                                   ecb-edit-area-creators
 
402
                                   ecb-windows-hidden
 
403
                                   ecb-toggle-layout-state
 
404
                                   ecb-current-maximized-ecb-buffer-name
 
405
                                   ecb-tree-buffers-of-current-layout)
 
406
                                 (function (lambda (l r)
 
407
                                             (string< (symbol-name l)
 
408
                                                      (symbol-name r)))))))
 
409
    (append emacs-vars semantic-vars speedbar-vars
 
410
            ecb-internal-vars ecb-options)))
 
411
 
 
412
 
 
413
(silentcomp-provide 'ecb-help)
 
414
 
 
415
;; ecb-help.el ends here