auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Re: Accessing TeX-related documentation


From: Jim Ottaway
Subject: [AUCTeX-devel] Re: Accessing TeX-related documentation
Date: Sun, 20 Nov 2005 18:15:07 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>>>> Ralf Angeli <address@hidden> writes:

> Occasionally I find myself opening an external shell for running
> texdoc.  I think it would be nice to have access to TeX-related
> documentation from inside Emacs.  We could start with something like

> (defun TeX-doc (name)
>   "Display documentation for NAME."
>   (interactive "sCommand or package: ")
>   (call-process "texdoc" nil 0 nil name))

> I'll have to check if MikTeX offers something similar.

> Maybe this could be expanded later to include command references like
> <URL:http://www.miwie.org/tex-refs/>.  Also, etexshow for ConTeXt
> could be hooked in.

> Would that be nice?

Yes that would be nice.

I also often find myself having to look at the source of packages and
classes [usually ones I have written myself when I can't remember what
a command I wrote years ago does].  It is handy to have a command to
look these up as well.  I have a very crude thing that does this using
kpsewhich:

(defun jeho-latex-find-package-current-file ()
  (interactive)
  (let ((packages '())
        documentclass package)
    (save-excursion
      (goto-char (point-min))
      (while
          (re-search-forward
           "\\(usepackage\\|documentclass\\)\\(?:\\[[^]]+\\]\\)?{\\([^}]+\\)}"
           nil t)
        (if (string= (match-string 1) "documentclass")
            (setq documentclass (cons (match-string 2)
                                      (concat (match-string 2) ".cls")))
          (push (cons (match-string 2)
                      (concat (match-string 2) ".sty"))
                packages))))
    (when documentclass
      (push documentclass packages))
    (setq package (cdr (assoc (completing-read
                               "Package: "
                               (if (or documentclass packages)
                                   (cons documentclass packages)
                                 '()))
                              packages)))
    (when package
      (setq output (shell-command-to-string (concat "kpsewhich " package)))
      (cond ((string-match (format "\\(.+%s\\)\n" package) output)
             (if (file-exists-p (match-string 1 output))
                 (find-file (match-string 1 output))
               (error "Can't find file: %s" (match-string 1 output))))
            ((string= output "")
             (error "Can't find package %s" package))
            (t (error "Kpsewhich error: %s" output))))))

Regards,

-- 
Jim Ottaway





reply via email to

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