Source

ecb / ecb-help.el

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
;;; ecb-help.el --- online help for ECB and bug reporting

;; Copyright (C) 2000 - 2003 Jesper Nordenberg,
;;                           Klaus Berndl,
;;                           Kevin A. Burton,
;;                           Free Software Foundation, Inc.

;; Author: Jesper Nordenberg <mayhem@home.se>
;;         Klaus Berndl <klaus.berndl@sdm.de>
;;         Kevin A. Burton <burton@openprivacy.org>
;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
;;             Kevin A. Burton <burton@openprivacy.org>
;; Keywords: browser, code, programming, tools
;; Created: 2001

;; This program is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free Software
;; Foundation; either version 2, or (at your option) any later version.

;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
;; details.

;; You should have received a copy of the GNU General Public License along with
;; GNU Emacs; see the file COPYING.  If not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

;; $Id$

;;; Commentary:
;;
;; Contains all online-help for ECB (stolen something from recentf.el)

;;; History
;;
;; For the ChangeLog of this file see the CVS-repository. For a complete
;; history of the ECB-package see the file NEWS.

;;; Code

(eval-when-compile
  (require 'silentcomp))

(require 'ecb-layout)
(require 'ecb-util)

;; XEmacs and Emacs 20.X
(silentcomp-defvar browse-url-new-window-p)
(silentcomp-defun browse-url)
;; Emacs 21
(silentcomp-defvar browse-url-new-window-flag)
;; JDE
(silentcomp-defvar jde-version)
;; mail and reporter
(silentcomp-defun mail-subject)
(silentcomp-defun mail-text)
(silentcomp-defun reporter-submit-bug-report)

(defconst ecb-help-info-start-file "ecb.info")
(defconst ecb-help-html-start-file "ecb.html")
(defconst ecb-help-info-subdir "./info-help/")
(defconst ecb-help-html-subdir "./html-help/")

(defgroup ecb-help nil
  "Settings for the ECB online help"
  :group 'ecb)

(defcustom ecb-show-help-format 'info
  "*The format `ecb-show-help' shows its online help.
Allowed values are 'info \(for the Info format) and 'html \(for HTML format).
If the value is 'html then `browse-url-browser-function' says which browser is
used.

Note: If you got ECB as a standard XEmacs-package maybe the
HTML-online-documentation is not included."
  :group 'ecb-help
  :group 'ecb-most-important
  :type '(choice :tag "Online-help format" :menu-tag "Online-help format"
                 (const :tag "Info" :value info)
                 (const :tag "Html" :value html)))


(defcustom ecb-help-info-path (concat
                               (if ecb-running-xemacs
                                   (if (file-exists-p
                                        (concat ecb-ecb-dir
                                                ecb-help-info-subdir
                                                ecb-help-info-start-file))
                                       ecb-help-info-subdir
                                     "../../info/")
                                 ecb-help-info-subdir)
                               ecb-help-info-start-file)
  "*Path where the ECB online help in info format resides.
This must be the location of the file \"ecb.info\" which comes with the ECB
distribution. If is installed by unpacking the archive available on the ECB
web-site then this is the subdir `ecb-help-info-subdir' of the installation
directory of ECB. If it is installed as XEmacs-package \(e.g. via the package
manager of XEmacs) then this is probably the directory \"../../info/\"
\(relativ to the Elisp directory of ECB).

The path can either be an absolute path or a path relative to the directory
where the Elisp files of ECB are.

Normally there should be no need to change this option!"
  :group 'ecb-help
  :type 'file)

(defcustom ecb-help-html-path
  (if (not ecb-running-xemacs)
      (concat ecb-help-html-subdir ecb-help-html-start-file)
    (cond ((file-exists-p
            (concat ecb-ecb-dir
                    ecb-help-html-subdir
                    ecb-help-html-start-file))
           (concat ecb-help-html-subdir ecb-help-html-start-file))
          ((file-exists-p
            (concat ecb-ecb-dir
                    "../../html/"
                    ecb-help-html-start-file))
           (concat "../../html/" ecb-help-html-start-file))
          ((file-exists-p
            (concat ecb-ecb-dir
                    "../../html/ecb/index.html"))
           "../../html/ecb/index.html")
          (t
           (concat "../../etc/ecb/html/" ecb-help-html-start-file))))
  "*Path where the ECB online help in HTML format resides.
This must be the location of the file \"index.html\" which comes with the ECB
distribution. If is installed by unpacking the archive available on the ECB
web-site then this is the subdir `ecb-help-html-subdir' of the installation
directory of ECB. If it is installed as XEmacs-package \(e.g. via the package
manager of XEmacs) then this is probably either the directory \"../../html/\" or
\"../../etc/ecb/html/\" \(both relative to the Elisp directory of ECB).

The path can either be an absolute path or a path relative to the directory
where the Elisp files of ECB are.

Normally there should be no need to change this option!"
  :group 'ecb-help
  :type 'file)


(defun ecb-info (info-file &optional no-file-not-exist-err)
  "Starts `info' with INFO-FILE. If INFO-FILE does not exists then nil is
returned otherwise true. If NO-FILE-NOT-EXIST-ERR is not nil then just nil is
returned if INFO-FILE does not exist otherwise an error is reported."
  (if (file-exists-p info-file)
      (prog1 t
        (info info-file))
    (unless no-file-not-exist-err
      (ecb-error "Info file %s does not exists!" info-file))
    nil))

(defun ecb-browse-html-file (html-file &optional no-file-not-exist-err)
  "Opens HTML-FILE in the standard-webbrowser with `browse-url'. If INFO-FILE
does not exists then nil is returned otherwise true. If NO-FILE-NOT-EXIST-ERR
is not nil then just nil is returned if HTML-FILE does not exist otherwise an
error is reported."
  (if (file-exists-p html-file)
      (prog1 t
        (if (and (locate-library "browse-url")
                 (require 'browse-url)
                 (fboundp 'browse-url))
            (browse-url (concat "file://" html-file)
                        (if (boundp 'browse-url-new-window-flag)
                            browse-url-new-window-flag
                          browse-url-new-window-p))
          (ecb-error "Function 'browse-url needed for displaying HTML!")))
    (unless no-file-not-exist-err
      (ecb-error "HTML file %s does not exists!" html-file))
    nil))

;;;###autoload
(defun ecb-show-help (&optional format)
  "Shows the online help of ECB in Info or HTML-format.
The format depends on the setting in `ecb-show-help-format'. If called with
prefix argument, i.e. if FORMAT is not nil then the user is prompted to choose
the format of the help \(Info or Html).

If an error about not finding the needed help-file occurs please take a look
at the options `ecb-help-info-start-file' and `ecb-help-html-start-file'!

Note: If you got ECB as a standard XEmacs-package maybe the
HTML-online-documentation is not included."
  (interactive "P")
  (let ((f (if format
               (intern (ecb-query-string "Choose format of online-help:"
                                         (if (equal 'ecb-show-help-format
                                                    'html)
                                             '("info" "html")
                                           '("html" "info"))))
             ecb-show-help-format))
        (info-path-abs (expand-file-name
                        (if (or (string-match "^\\." ecb-help-info-path)
                                (string-match (concat "^"
                                                      (regexp-quote
                                                       ecb-help-info-start-file))
                                              ecb-help-info-path))
                            (concat ecb-ecb-dir ecb-help-info-path)
                          ecb-help-info-path)))
        (html-path-abs (ecb-fix-filename
                        (if (or (string-match "^\\." ecb-help-html-path)
                                (string-match (concat "^"
                                                      (regexp-quote
                                                       ecb-help-html-start-file))
                                              ecb-help-html-path))
                            (concat ecb-ecb-dir ecb-help-html-path)
                          ecb-help-html-path))))
    (if (equal f 'info)
        (ecb-info info-path-abs)
      (message "Opening ECB online-help in a web-browser...")
      (ecb-browse-html-file html-path-abs))))


;;
;; Problem reporting functions stolen from JDEE
;;
(defvar ecb-problem-report-mail-address "ecb-list@lists.sourceforge.net" )

(defconst ecb-problem-report-message
  "Please enter the details of your bug report here")

(defun ecb-submit-problem-report()
  "Submit a problem report for the ECB to the ECB mailing-list.
This command generates in the edit-window a problem-report which contains
already the current values of all ECB options, the current backtrace-buffer if
there is any and the current message-buffer. You will be asked for a
problem-report subject and then you must insert a description of the problem.
Please describe the problem as detailed as possible!"
  (interactive)
  (when (or ecb-minor-mode
            (y-or-n-p "ECB should be active when submitting a problem-report. Force report? "))
    (if (and (equal ecb-frame (selected-frame))
             (not (ecb-point-in-edit-window)))
        (ecb-select-edit-window))
    (if (not (locate-library "reporter"))
        (ecb-error "You need the reporter.el package to submit a bugreport for ECB!")
      (require 'reporter)
      (progn
        (message "Preparing problem report...")
        ;;prepare the basic buffer
        (reporter-submit-bug-report
         ecb-problem-report-mail-address
         (format "ECB: %s, semantic: %s, eieio: %s, speedbar: %s, JDEE: %s"
                 ecb-version
                 semantic-version
                 eieio-version
                 speedbar-version
                 (if (boundp 'jde-version)
                     jde-version
                   "No JDEE"))
         (ecb-problem-report-list-all-variables)
         nil
         'ecb-problem-report-post-hook
         ecb-problem-report-message)
        (if (equal ecb-frame (selected-frame))
            (ecb-redraw-layout))
        (mail-subject)
        (insert (read-string "Problem report subject: "
                             (format "ECB-%s -- " ecb-version)))
        (mail-text)
        (search-forward ecb-problem-report-message)
        (end-of-line)
        (message "Preparing bug report...done")))))

(defun ecb-problem-report-post-hook()
  "Function run the reporter package done its work. It looks for a message- and
a backtrace-buffer and inserts the contents of that."
  (save-excursion
    (beginning-of-buffer)
    ;; if the mail-packages has already inserted a signature we must not go to
    ;; the buffer-end but just before the signature
    (if (re-search-forward "^--[ \t]*$" nil t)
        (progn
          (beginning-of-line)
          (insert "\n\n\n")
          (forward-line -2))
      (goto-char (point-max))
      (insert "\n\n"))
    ;; ecb-faces
    (let ((ecb-face-list (delq nil (mapcar (function
                                            (lambda (f)
                                              (if (string-match "^ecb-"
                                                                (symbol-name f))
                                                  f
                                                nil)))
                                           (face-list)))))
      (insert "\n\n-----------------------------------------------------\n")
      (insert "The attributes of the ECB-faces are:\n\n")
      (dolist (f ecb-face-list)
        (when f
          (insert (format "%s: %s\n"
                          (symbol-name f)
                          (funcall (if ecb-running-xemacs
                                       'face-custom-attributes-get
                                     'custom-face-attributes-get)
                                   f ecb-frame)))))
      (insert "\n-----------------------------------------------------\n\n"))
    (let* ((messages-buffer 
	    (get-buffer
	     (if ecb-running-xemacs " *Message-Log*" "*Messages*")))
	   (backtrace-buffer (get-buffer "*Backtrace*")))

      ;;insert the contents of the backtrace buffer if it is there. 
      (insert "\n\n-----------------------------------------------------\n")
      (if backtrace-buffer
          (progn
            (insert "The contents of the *Backtrace* buffer were\n\n")
	    (insert-buffer backtrace-buffer)
            ;; we must force the mark
	    (goto-char (mark t))
            (insert "\nEnd Insert *Backtrace* buffer" ))
        (insert "There was no *Backtrace* buffer" ))
      (insert "\n-----------------------------------------------------\n\n")

      ;;insert the contents of the messages buffer if it is there. 
      (insert "-----------------------------------------------------\n")
      (if messages-buffer
          (progn
            (insert "The contents of the *Messages* buffer were\n\n")
	    (insert-buffer messages-buffer)
	    (goto-char (mark t))
            (insert "\nEnd Insert *Messages* buffer" ))
        (insert "There was no *Messages* buffer" ))
      (insert  "\n-----------------------------------------------------\n\n"))))


(defun ecb-problem-report-list-all-variables()
  "List all variables starting with `ecb-' and some other variables which
could be interesting for support."
  (let ((emacs-vars (sort (delete nil
                                  `(pre-command-hook
                                    post-command-hook
                                    after-save-hook
                                    help-mode-hook
                                    compilation-mode-hook
                                    truncate-partial-width-windows
                                    truncate-lines
                                    ,(if (boundp 'compilation-window-height)
                                         'compilation-window-height)
                                    ,(if (boundp 'temp-buffer-max-height)
                                         'temp-buffer-max-height)
                                    auto-mode-alist
                                    ,(if (boundp 'c-mode-hook)
                                         'c-mode-hook)
                                    ,(if (boundp 'c++-mode-hook)
                                         'c++-mode-hook)
                                    ,(if (boundp 'c-mode-common-hook)
                                         'c-mode-common-hook)
                                    ,(if (boundp 'java-mode-hook)
                                         'java-mode-hook)
                                    ,(if (boundp 'jde-mode-hook)
                                         'jde-mode-hook)
                                    system-type
                                    window-system
                                    max-specpdl-size
                                    max-lisp-eval-depth
                                    ,(if (boundp 'ediff-quit-hook)
                                         'ediff-quit-hook)))
                          (function (lambda (l r)
                                      (string< (symbol-name l)
                                               (symbol-name r))))))
        (semantic-vars (sort (delete nil
                                     `(semantic-after-toplevel-cache-change-hook
                                       semantic-after-partial-cache-change-hook
                                       ,(if (boundp 'semantic-format-face-alist)
                                            'semantic-format-face-alist
                                          'semantic-face-alist)
                                       semantic-uml-colon-string
                                       semantic-orphaned-member-metaparent-type))
                             (function (lambda (l r)
                                         (string< (symbol-name l)
                                                  (symbol-name r))))))
        (speedbar-vars (sort '(speedbar-dynamic-tags-function-list
                               speedbar-tag-hierarchy-method
                               speedbar-tag-group-name-minimum-length
                               speedbar-tag-split-minimum-length
                               speedbar-tag-regroup-maximum-length
                               speedbar-fetch-etags-command
                               speedbar-fetch-etags-arguments
                               speedbar-fetch-etags-parse-list)
                             (function (lambda (l r)
                                         (string< (symbol-name l)
                                                  (symbol-name r))))))
        (ecb-options (mapcar
                      'intern
                      (sort
                       (let (completion-ignore-case)
                         (all-completions "ecb-" obarray 'user-variable-p))
                       'string-lessp)))
        (ecb-internal-vars (sort '(ecb-path-selected-directory
                                   ecb-path-selected-source
                                   ecb-use-semantic-grouping
                                   ecb-idle-timer-alist
                                   ecb-post-command-hooks
                                   ecb-max-specpdl-size-old
                                   ecb-max-lisp-eval-depth-old
                                   ecb-minor-mode
                                   ecb-last-window-config-before-deactivation
                                   ecb-edit-area-creators
                                   ecb-windows-hidden
                                   ecb-toggle-layout-state
                                   ecb-current-maximized-ecb-buffer-name
                                   ecb-tree-buffers-of-current-layout)
                                 (function (lambda (l r)
                                             (string< (symbol-name l)
                                                      (symbol-name r)))))))
    (append emacs-vars semantic-vars speedbar-vars
            ecb-internal-vars ecb-options)))


(silentcomp-provide 'ecb-help)

;; ecb-help.el ends here
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.