[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[eev] psne, find-pspage, xrdb, TeXBook, LaTeX source, etc

From: Eduardo Ochs
Subject: [eev] psne, find-pspage, xrdb, TeXBook, LaTeX source, etc
Date: Mon, 11 Jul 2005 17:00:29 -0000

Hi all! If you download the new version of eev-current and install it
you'll notice that an old feature is back: psne. I just wrote a
section about it for the article (at

  Local copies of files from the internet

  Emacs knows how to fetch files from the internet, but for most
  purposes it is better to use local copies. Suppose that the
  environment variable S is set to ~/snarf/; then running this on a

    mkdir -p $S/http/
    cd       $S/http/

    # (find-fline "$S/http/")
    # (find-w3m   "$S/http/")

  creates a local copy of emacs-paper.html inside ~/snarf/http/. The
  two last lines are hyperlinks to the local copy; `find-w3m' opens it
  ``as HTML'', using a web browser called w3m that can be run either
  in standalone mode or inside Emacs; `find-w3m' uses w3m's Emacs
  interface, and it accepts extra arguments, which are treated as a

  Instead of running the `mkdir', `cd' and `wget' lines above we can
  run a single command that does everything:


  which also adds a line with that URL to a log file (usually
  ~/.psne.log). It is more convenient to have a `psne' that changes
  the current directory of the shell than one that doesn't, and for
  that it must be defined as a shell function.

  Eev comes with an installer script, called eev-rctool, that can help
  in adding the definitions for eev (like the ``function ee () {
  source ~/; }'' from the section ``Making programs receive
  commands'') to initialization files like ~/.bashrc (such
  initialization files are termed ``rcfiles''). But eev-rctool does
  _not_ add by default the definitions for `psne' and for S to
  rcfiles; however, it adds commented-out lines with instructions,
  which might be something like:

    # To define $S and psne uncomment this:
    #   . $EEVTMPDIR/
    # (find-eevtmpfile "")

Hyperlinks to PostScript, PDF and DVI documents

Buried inside the source code for eev.el lie some functions for
creating links to PostScript, PDF and DVI files; of those,
`find-pspage' and `find-dvipage' are the easiest to understand.
Running, say,

  (find-dvipage "$S/http/")
  (find-dvipage "$S/http/" 99)
  (find-pspage  "$S/http/")
  (find-pspage  "$S/http/"  99)

just write, respectively,

  xdvi +1 $S/http/ &
  xdvi +99 $S/http/ &
  gv --page=1 $S/http/ &
  gv --page=99 $S/http/ &

to $EE (i.e., to ~/ The code for find-dvipage and find-pspage
is very simple, and if we run `ee' in a shell after running these
hyperlink functions either we get an xdvi or gv process running or we
get an error message straight on our face. Note that gv can handle
(well-behaved) pdf files, and that in many distros both xdvi and gv
can handle compressed files.

`eebg-xdvi' and `eebg-gv' are similar to `find-dvipage' and
`find-pspage', but they make Emacs launch _immediately_ an xdvi or gv
process in the background, without using an external shell. With these
functions we can pop up an xdvi or gv window with a single `M-e'! Note
that we don't even need an external xterm listening on a communication
channel... One drawback: the messages from the process appear in the
buffer *Messages*; if you run an `eebg-xdvi' or `eebg-gv' link and no
xdvi/gv window appears then you have to switch to the buffer
*Messages* and check what has appeared there.

I have just added aliases for `eebg-xdvi' and `eebg-gv':
`find-dvipagenow' and `find-pspagenow', and I may drop the names
`eebg-xdvi' and `eebg-gv' in the future. These aliases with nice names
indicate that these functions are being promoted from uglyhackland to

If you feel comfortable enough with `find-dvipagenow' and
`find-pspagenow' you can copy them onto `find-dvipage' and
`find-pspage', with:

  (defalias 'find-dvipage 'eebg-xdvi)
  (defalias 'find-pspage  'eebg-gv)

Short Hyperlinks to PostScript, PDF and DVI documents

These calls

  (code-dvi "bad" "$S/http/")
  (code-ps  "bap" "$S/http/")

define functions find-badpage and find-bappage, that can be used as:

  (find-badpage 99)
  (find-bappage 99)

These short calls correspond to the `find-dvipage' and `find-pspage'
calls above; if you have replaced them with their "" variants
the "" variants will be used.

Also, these things work:

  (code-c-d "fooorg" "$S/http/" :xdvi :gv)
  (find-fooorgxdvi "bar.dvi")
  (find-fooorgxdvi "bar.dvi" 99)
  (find-fooorggv   "")
  (find-fooorggv   "" 99)

Changing xdvi's and gv's defaults (everywhere)

Both xdvi and gv ask the X server for the values of certain defaults,
like the initial magnification scale. One easy way to change these
defaults is through the "resources" database of the current X session;
the listing below is an abridged version of my ~/.Xdefaults file:

  ! (find-man "X" "\nRESOURCES")
  ! (find-man "X" ".Xdefaults")
  ! (find-man "X" "xrdb program")

  ! (find-man "xrdb")
  ! Run this to reload .Xdefaults after a change:
  ! (find-sh0 "xrdb -merge ~/.Xdefaults")

  ! (find-man "1 xdvi")
  ! xdvi*geometry: 730x750
  xdvi*expert: on
  xdvi*thorough: yes
  ! For 1280x1024:
  ! xdvi*shrinkFactor: 6
  ! For 1024x768:
  xdvi*shrinkFactor: 9
  xdvi*topMargin: .92in

  ! (find-man "1 gv")
  ! (find-node "(gv)Resources of gv" "*scale*")
  gv.scale: -2

If gv and xdvi are not set to the ideal magnification/zoom/scale then
for each gv or xdvi that is opened by a hyperlink we have to type a
few more keys ("+" and "-" on gv, "<number> s" on xdvi) to adjust the
zoom level, which is distracting, annoying, and eats up precious

The TeXBook and the source code of LaTeX2e

I've added a few new blocks to the examples/tex.e file of eev-current:

  (find-eevex "tex.e" "texbook")
  (find-eevex "tex.e" "find-texbookpage")
  (find-eevex "tex.e" "source2e.dvi")
  (find-eevex "tex.e" "find-source2epage")

"find-texbookpage" and "find-source2epage" implement the Lisp
functions (hyperlinks) with these names, and "texbook" and
"source2e.dvi" produce the .dvi files that are used by the
`find-texbookpage' and `find-source2epage' functions.

The online version of TeX source of the TeXBook says "you should not
typeset this"; I don't know what to say about that. The TeXBook (in
its hardcover edition, even!) is a must-have for anyone who uses TeX
or LaTeX, and an online version of it for quick reference is not a
substitute for the real book - it's a complement for it, and I hope
that the publishers will not get angry with us for using it. Anyway:

The source code for LaTeX2e is written on a "literate programming"
language; DocTeX, I think. By running latex on source2e.tex the many
.dtx files that comprise the source of the "base" of LaTeX2e are TeXed
into a nice .dvi file called source2e.dvi.

A problem: suppose that we want to create a link to the 4th page of
ltlists.dtx in source2e.dvi. A link like

  (find-source2epage (+ 9 245 3))

is not expressive enough - it's ugly, it can't be interpreted
immediately by humans, it can break when the LaTeX version changes,
etc. A solution: make `find-source2epage' smarter; make it interpret
some symbols as names of packages, i.e., as specific pages. So:

 (find-source2epage 'ltlists)
 (find-source2epage 'ltlists 3)
 (find-source2epage 'ltlists 3 "\\list{LABEL}{COMMANDS}")
 (find-source2efile "ltlists.dtx" "\\list{LABEL}{COMMANDS}")
 (find-source2efile "ltlists.dtx" "\\def\\list#1#2")

The first link above points to the first page of the section
corresponding to ltlists.dtx, the second one points to the first page
plus 3, the third too (the other arguments are ignored), and the other
two links point to the .dtx file itself.

The table with the names of sections and their pages (a plist) was
built by hand from the .toc ("table of contents") file.

There's something similar for the TeXbook:

  (find-texbookpage 'appendixI "Index")
  (find-texbookpage 'appendixF "Font Tables")
  (find-texbookpage 'chapter21 2   "\\boxit")
  (find-texbookfile "texbook.tex" "|\\boxit|")


-- - Choose from over 50 domains or use your own

reply via email to

[Prev in Thread] Current Thread [Next in Thread]