~ubuntu-branches/ubuntu/hardy/ess/hardy

« back to all changes in this revision

Viewing changes to lisp/ess-help.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2005-03-22 13:48:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050322134807-9mpmbb799jugf248
Tags: 5.2.6-1
* New upstream release
* chmod -R u+w on orig source

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
;; Copyright (C) 1989-1994 Bates, Kademan, Ritter and Smith
4
4
;; Copyright (C) 1997, A.J. Rossini <rossini@stat.sc.edu>
5
 
;; Copyright (C) 1998--2001     A.J. Rossini <rossini@u.washington.edu>,
6
 
;; Martin Maechler <maechler@stat.math.ethz.ch>, Kurt Hornik < >,
7
 
;; and Richard M. Heiberger <rmh@temple.edu>.
 
5
;; Copyright (C) 1998--2001 A.J. Rossini, Martin Maechler, Kurt Hornik and
 
6
;;      Richard M. Heiberger <rmh@temple.edu>.
 
7
;; Copyright (C) 2001--2004 A.J. Rossini, Rich M. Heiberger, Martin
 
8
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
8
9
 
9
 
;; Author: David Smith <dsmith@stats.adelaide.edu.au>
10
 
;; Maintainers: A.J. Rossini <rossini@u.washington.edu>,
11
 
;;              Martin Maechler <maechler@stat.math.ethz.ch>
 
10
;; Original Author: David Smith <dsmith@stats.adelaide.edu.au>
12
11
;; Created: 7 Jan 1994
13
 
;; Modified: $Date: 2002/01/28 08:36:32 $
14
 
;; Version: $Revision: 5.17 $
15
 
;; RCS: $Id: ess-help.el,v 5.17 2002/01/28 08:36:32 maechler Exp $
 
12
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
16
13
 
17
14
;; This file is part of ESS
18
15
 
128
125
                          "](" object ")*"))
129
126
         (old-hb-p      (get-buffer hb-name))
130
127
         (curr-win-mode major-mode)
131
 
         (tbuffer       (get-buffer-create hb-name))
 
128
         (tbuffer       (get-buffer-create hb-name))
132
129
         (curr-help-command             inferior-ess-help-command)
133
130
         ;;-- pass the buffer-local 'ess-help-sec-..'  to the ess-help buffer:
134
 
         (curr-help-sec-regex           ess-help-sec-regex)
 
131
         (curr-help-sec-regex           ess-help-sec-regex)
135
132
         (curr-help-sec-keys-alist      ess-help-sec-keys-alist)
136
133
         (curr-help-syntax-table        (syntax-table))
137
134
         (alist         ess-local-customize-alist))
138
135
 
139
136
    (set-buffer tbuffer)
140
 
    (ess-setq-vars-local (eval alist) (current-buffer))
 
137
    (ess-setq-vars-local (eval alist))
141
138
    (setq ess-help-sec-regex      curr-help-sec-regex)
142
139
    (setq ess-help-sec-keys-alist curr-help-sec-keys-alist)
143
140
    ;; see above, do same for inferior-ess-help-command... (i.e. remove
157
154
          (ess-command (format curr-help-command object) tbuffer)
158
155
          ;; was inferior-ess-help-command
159
156
 
 
157
          (ess-help-underline)
160
158
          ;; Stata is clean, so we get a big BARF from this.
161
159
          (if (not (string= ess-language "STA"))
162
160
              (ess-nuke-help-bs))
174
172
              (if (not (listp nodocs))
175
173
                  (setq nodocs (list PM (point-max))))
176
174
              (ess-write-to-dribble-buffer
177
 
               (format "(ess-help: error-buffer �%s� nodocs (%d %d)\n"
 
175
               (format "(ess-help: error-buffer '%s' nodocs (%d %d)\n"
178
176
                       (buffer-name) (car nodocs) (cadr nodocs)))
179
177
              ;; Avoid using 'message here -- may be %'s in string
180
178
              ;;(princ (buffer-substring (car nodocs) (cadr nodocs)) t)
187
185
          ;; else : show it
188
186
 
189
187
          ;;dbg (ess-write-to-dribble-buffer
190
 
          ;;dbg  (format "(ess-help �%s� before switch-to..\n" hb-name)
191
 
          (if (eq curr-win-mode 'ess-help-mode)
192
 
              (switch-to-buffer tbuffer)
193
 
            (ess-display-temp-buffer tbuffer))
 
188
          ;;dbg  (format "(ess-help '%s' before switch-to..\n" hb-name)
 
189
          (let ((special-display-regexps
 
190
                 (if ess-help-own-frame '(".") nil))
 
191
                (special-display-frame-alist ess-help-frame-alist)
 
192
                (special-display-function
 
193
                 (if (eq ess-help-own-frame 'one)
 
194
                     'ess-help-own-frame
 
195
                   special-display-function)))
 
196
            (if (eq curr-win-mode 'ess-help-mode)
 
197
                (if ess-help-own-frame
 
198
                    (pop-to-buffer tbuffer)
 
199
                  (switch-to-buffer tbuffer))
 
200
              (ess-display-temp-buffer tbuffer)))
194
201
          (if curr-help-syntax-table
195
202
              (set-syntax-table curr-help-syntax-table))
196
203
          (set-buffer-modified-p 'nil)
197
204
          (toggle-read-only t))))))
198
205
 
 
206
(defvar ess-help-frame nil
 
207
  "Stores the frame used for displaying R help buffers.")
 
208
 
 
209
(defun  ess-help-own-frame (buffer &rest ignore)
 
210
  "Put all ESS help buffers into `ess-help-frame'."
 
211
  ;; SJE: Code adapted from Kevin Rodgers.
 
212
  (if (frame-live-p ess-help-frame)
 
213
      (progn
 
214
        (or (frame-visible-p ess-help-frame)
 
215
            (make-frame-visible ess-help-frame))
 
216
        (raise-frame ess-help-frame)
 
217
        (select-frame ess-help-frame)
 
218
        (switch-to-buffer buffer)
 
219
        (selected-window))
 
220
    ;; else
 
221
    (let ((window (special-display-popup-frame buffer)))
 
222
      (set-window-dedicated-p window nil)
 
223
      (setq ess-help-frame (window-frame window))
 
224
      window)))
 
225
 
 
226
 
199
227
 
200
228
;;; THIS WORKS!
201
229
;;(require 'w3)
202
 
(defun ess-display-w3-help-on-object-other-window (object)
203
 
  "Display R-documentation for OBJECT using W3"
204
 
  (interactive "s Help on :")
205
 
  (let* ((ess-help-url (concat ess-help-w3-url-prefix
206
 
                               ess-help-w3-url-funs
207
 
                               object
208
 
                               ".html")))
 
230
;(defun ess-display-w3-help-on-object-other-window (object)
 
231
;  "Display R-documentation for OBJECT using W3"
 
232
;  (interactive "s Help on :")
 
233
;  (let* ((ess-help-url (concat ess-help-w3-url-prefix
 
234
;                              ess-help-w3-url-funs
 
235
;                              object
 
236
;                              ".html")))
209
237
    ;;(w3-fetch-other-window ess-help-url)
210
 
    ))
 
238
;    ))
211
239
 
212
240
 
213
241
;;*;; Major mode definition
238
266
  (define-key ess-help-mode-map "\177" 'scroll-down) ; DEL
239
267
  (define-key ess-help-mode-map "s" ess-help-sec-map)
240
268
  (define-key ess-help-mode-map "h" 'ess-display-help-on-object)
 
269
;; TODO: `electric mouse-2'
 
270
;; (define-key ess-help-mode-map [mouse-2] 'ess-display-help-on-object)
241
271
  (define-key ess-help-mode-map "l" 'ess-eval-line-and-step)
242
272
  (define-key ess-help-mode-map "r" 'ess-eval-region-and-go)
243
273
  (define-key ess-help-mode-map "n" 'ess-skip-to-next-section)
316
346
                    "Menu keymap for ess-help mode." ess-help-mode-menu)
317
347
  (easy-menu-add ess-help-mode-menu-map ess-help-mode-map)
318
348
 
319
 
  (run-hooks ess-help-mode-hook))
 
349
  (run-hooks 'ess-help-mode-hook))
320
350
 
321
351
;;*;; User commands defined in ESS help mode
322
352
 
323
353
(defun ess-skip-to-help-section nil
324
 
  "Jump to a section heading of a help buffer.  The section selected
 
354
  "Jump to a section heading of a help buffer.  The section selected
325
355
is determined by the command letter used to invoke the command, as
326
 
indicated by `ess-help-sec-keys-alist'.  Use \\[ess-describe-sec-map]
 
356
indicated by `ess-help-sec-keys-alist'.  Use \\[ess-describe-sec-map]
327
357
to see which keystrokes find which sections."
328
358
  (interactive)
329
359
  (let ((old-point (point))
462
492
  (skip-chars-forward "\n")
463
493
  (delete-region (point-min) (point)))
464
494
 
 
495
(defun ess-help-underline ()
 
496
  "Replace ^_H codes with underline face."
 
497
  (save-excursion
 
498
    (goto-char (point-min))
 
499
    (while (search-forward "_" nil t)
 
500
    (backward-delete-char 2)
 
501
    (put-text-property (point) (1+ (point)) 'face 'underline))))
 
502
 
465
503
;;*;; Link to Info
466
504
 
467
505
(defun ess-goto-info (node)