[ESS] Help buffer window behavior

Vitalie S. vitosmail at rambler.ru
Tue Mar 23 22:36:26 CET 2010


On Wed, 10 Mar 2010 11:08:59 +0200, Leo Alekseyev  
<leo.alekseyev at gmail.com> wrote:

> Hi all,
> I was wondering if there's a way to customize the focusing / exiting
> behavior of the R help buffers.  First, I would like the help buffer
> to take focus when it first appears -- just like emacs help buffers
> do.
>
> Secondly, I would like the buffer to return me back to the previous
> state of windows when exiting help (e.g. by pressing 'q') instead of
> simply switching focus to the ESS buffer, in the same way as pressing
> 'q' in emacs help (after doing e.g. C-h <key>) hides that buffer and
> restores previous windows (by running view-quit).  I tried binding 'q'
> to winner-undo in ess-help-mode-map, but that doesn't work for the
> following reason: I use (setq view-read-only t) in my .emacs, so I
> have view mode activated as well.  When run together with ess-help
> mode, (view-quit) merely turns off the view mode, without affecting
> any windows.
>
> Basically, I wish ESS's help windows behaved more like the rest of
> emacs help windows.  I'd appreciate any hints on how to do this!
>

This option is not inbuilt in the ess-display-help functions.
The code below (picked from the web) sorts this out , but does not act on  
the object at the point but the one before the parenthesis (i.e. plot(xxx|  
will show help on plot). It is quite straightforward to modify it with  
(current-word) to act just like ess-display-help-on-object.


(defun my-r-call-help ()
   "Call R's help page for the function at the point."
   (interactive "*")
   (let ((pointposition (point)))
     (up-list -1)
     (let ((posend (point)))
	(backward-sexp 1)
	(setq helpobject (buffer-substring-no-properties posend (point)))
	(goto-char pointposition)
	(setq startbuffer (current-buffer))
	(other-window 1)
	(set-buffer startbuffer)
	(ess-display-help-on-object helpobject)
	(other-window -1)
	)
     )
   )

(define-key ess-mode-map [(control ?h)(?f)] 'my-r-call-help)

q thing is achieved by just kilning the buffer:

(add-hook 'ess-help-mode-hook 'my-ess-help-options)
(defun my-ess-help-options ()
   (local-set-key  (kbd "k") '(lambda ()(interactive) (kill-buffer  
(current-buffer))))
   (local-set-key  (kbd "q") '(lambda ()(interactive) (kill-buffer  
(current-buffer))))
)

The above speeds me up considerably.
Would be nice to have this functionality in  ess-display-help-on-object.
Vitalie.

> Thanks,
> --Leo
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list