[ESS] Printing *R* help pages within Emacs using doc-view
Stephen Eglen
S.J.Eglen at damtp.cam.ac.uk
Thu Jul 26 21:14:52 CEST 2012
Steven McKinney <smckinney at bccrc.ca> writes:
> Where does ess-help-object get defined?
>
> An initial attempt to find it in ESS-5.14 .el files comes up empty.
> Do I have the wrong version of ESS? Not looking in the right place?
Thanks for testing Steven; our lisp/Changelog (excerpt below) shows it
was introduced late last year. Please upgrade to new Emcas. If you are
on a mac, the easiest way to stay up to date is care of Vincent's great
Emacs+AUCTEX+ESS bundle:
http://vgoulet.act.ulaval.ca/en/emacs/mac/
Can you also just try if something like
$ lpr somefile.pdf
or
$ lpr -Pmyprinter somefile.pdf
works from your Mac terminal? that's all that's needed. It *should*
work.
Stephen
----------------------------------------------------------------------
2011-11-13 Vitalie Spinu <spinuvit at gmail.com>
* ess-help.el (ess-helpobj-at-point): modified the name of
ess-read-helpobj-name-default to a more intuitive one and
consistent with emacs conventions.
* ess-custom.el (ess-help-pop-to-buffer): If non-nil ess-help
buffers are given focus during the display.
(ess-ido-flex-matching): if you don't use ido flex matching but
still want it for ESS, here it is.
* ess-help.el (ess-display-help-on-object): put cache update on
universal argument, it also regenerates the help buffer as
before. Removed curr-* kludge which was not necessary. Removed the
handling of help buffer into separate function.
(ess-help-type): local variable in help files holding the help
type symbol. So far, 'help, 'index, 'vignette.
(ess-help-object): local in help files holding the name of the
help object, i.e. name of the package for index and help topic for
ordinary help.
>
> [MOMAC17:/Volumes/KilroyHD/kilroy/Software/Gnu/Emacs/ESS/ess-5.14/ess-5.14/lisp stevenmckinney]
> $ grep "ess-help-object" *.el
> [MOMAC17:/Volumes/KilroyHD/kilroy/Software/Gnu/Emacs/ESS/ess-5.14/ess-5.14/lisp stevenmckinney]
>
> Steven McKinney
> ________________________________________
> From: ess-help-bounces at r-project.org [ess-help-bounces at r-project.org] On Behalf Of Steven McKinney [smckinney at bccrc.ca]
> Sent: July 26, 2012 11:48 AM
> To: Stephen Eglen; ESS-help at r-project.org
> Subject: Re: [ESS] Printing *R* help pages within Emacs using doc-view
>
> Very nice Stephen,
>
> Looking forward to having this capability.
>
> On my Mac running OSX 10.6.8 (Snow Leopard) with R-2.15.1 I get
> a minibuffer message
>
> let: Symbol's value as variable is void: ess-help-object
>
> so the code below needs some kind of modification for Apple's
> flavour of Unix.
>
> Steven McKinney
> ________________________________________
> From: ess-help-bounces at r-project.org [ess-help-bounces at r-project.org] On Behalf Of Stephen Eglen [S.J.Eglen at damtp.cam.ac.uk]
> Sent: July 26, 2012 2:13 AM
> To: ESS-help at r-project.org
> Cc: Stephen Eglen
> Subject: [ESS] Printing *R* help pages within Emacs using doc-view
>
> Dear all,
>
> Here's some proof of concept code to solve the following problem for
> me. If you'd like to see it in ESS, let me know, and if I get
> sufficient feedback, I'll tidy it up and put it in.
>
> Unix only for now.
>
> If you are viewing a R help page in ESS, e.g. "rnorm", then if you hit
> the P key, a few seconds later, you should see /tmp/rnorm.pdf opened,
> which should render nicely thanks to doc-view. Then within doc-view,
> hit ! to send the PDF to a printer. This is the only line you'll need
> to configure/edit:
>
>
> (setq sje-doc-view-pdf-lpr-command "lpr -Pg0 %s") ;; docstring below
>
> You'll need a unix command to print a pdf; our local printers can print
> a pdf using a command like:
>
> $ lpr -Pg0 /tmp/rnorm.pdf
>
> If your printer doesn't accept pdf directly, you'll need to change it to
> something else. "g0" is the name of my local printer. It won't print
> automatically, when you hit ! you get the chance to edit the command
> sent.
>
> I've put the pdf in /tmp as I don't like them accummulating in the *R*
> current working directory.
>
> Feedback welcome!
>
> Stephen
>
> p.s. the code for printing pdf from doc-view is independent of ESS.
>
> ----------------------------------------------------------------------
> (defun ess-r-help-pdf ()
> (interactive)
> (let
> ((cmd (format "help(%s, help_type='pdf')\n" ess-help-object))
> (pdf (format "%s.pdf" ess-help-object))
> (newpdf (format "/tmp/%s.pdf" ess-help-object))
> )
> (ess-command cmd)
> (rename-file pdf newpdf 'overwrite)
> (find-file newpdf)))
>
>
> (add-hook 'ess-help-mode-hook
> '(lambda () (local-set-key "P" 'ess-r-help-pdf)))
>
>
> ;;; Now set up doc-view for printing.
> (defun sje-doc-view-pdf-lpr ()
> "Send current PDF to the default printer.
> The default printer command is set by `sje-doc-view-pdf-lpr-command'."
> (interactive)
> (let ((cmd (format sje-doc-view-pdf-lpr-command (buffer-file-name))))
> (shell-command
> (read-string (format "Print command (default %s): " cmd) nil nil cmd))))
>
> ;; g0 is my default printer.
> (defvar sje-doc-view-pdf-lpr-command "lpr -Pg0 %s"
> "Print command to use to send a pdf to the printer. %s will
> get expanded to the name of the file associated with the current
> buffer.")
>
> (add-hook 'doc-view-mode-hook
> '(lambda () (local-set-key "!" 'sje-doc-view-pdf-lpr)))
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
More information about the ESS-help
mailing list