Some more changes

This commit is contained in:
Alexander Rosenberg 2024-10-14 21:38:33 -07:00
parent a83f5ea6c1
commit a0a1738ff6
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 29 additions and 16 deletions

View File

@ -564,8 +564,7 @@ which to use. If NODE is non-nil, use that instead."
;;;###autoload
(defun latex-help-texdoc (name)
"Lookup NAME in the texdoc cache.
When used interactively, prompt for NAME. If DIR is nil, it will be looked up
in the texdoc cache."
When used interactively, prompt for NAME."
(interactive (list (latex-help--prompt-texdoc-entry)))
(latex-help--maybe-init-caches)
(when-let ((file (latex-help--texdoc-prompt-for-entry-file name)))
@ -634,22 +633,39 @@ documentation for that thing."
"Get help with LaTeX.
Prompt the user for an info topic or texdoc file, then open that thing."
(interactive)
(let ((prompts))
(let ((prompts)
(tap (latex-help--get-thing-at-point))
(def-entry nil)
(def-name nil))
(latex-help--maybe-init-caches)
(cl-flet ((add-cache-for-type (type)
(dolist (entry (latex-help--get-cache-for-type type))
(push (format "(Info) %s - %s"
(capitalize (symbol-name type))
(car entry))
prompts))))
prompts)
(when (and (eq type (cdr tap))
(equal (car entry) (car tap)))
(setq def-entry (car prompts)
def-name (car entry))))))
(add-cache-for-type 'command)
(add-cache-for-type 'package)
(add-cache-for-type 'class)
(add-cache-for-type 'environment)
(dolist (entry latex-help--texdoc-cache)
(push (format "(Texdoc) %s" entry) prompts))
(when-let ((ans (completing-read "LaTeX Help: " prompts
nil t nil 'latex-help--general-history))
(push (format "(Texdoc) %s" entry) prompts)
(when (and (member (cdr tap) '(class package environment))
(equal entry (car tap)))
(setq def-entry (car prompts)
def-name entry)))
(when-let ((ans (completing-read (format "LaTeX Help%s: "
(if def-name
(format " (default %s)"
def-name)
""))
prompts
nil t nil 'latex-help--general-history
def-entry))
((not (zerop (length ans)))))
(if (string-prefix-p "(Texdoc) " ans)
(latex-help-texdoc (seq-subseq ans (length "(Texdoc) ")))

13
init.el
View File

@ -1119,7 +1119,7 @@ otherwise, call `bibtex-find-text'."
(LaTeX-mode . LaTeX-math-mode)
(LaTeX-mode . my/-setup-LaTeX-mode))
:bind (:map TeX-mode-map
("C-c ?" . latex-help-texdoc))
("C-c ?" . latex-help))
:init
(add-to-list 'major-mode-remap-alist '(plain-tex-mode . plain-TeX-mode))
(add-to-list 'major-mode-remap-alist '(latex-mode . LaTeX-mode))
@ -1130,14 +1130,11 @@ otherwise, call `bibtex-find-text'."
(add-to-list 'auto-mode-alist '("/\\.latexmkrc\\'" . perl-mode))
:config
(defun my/-auctex-texdoc-setup-env (oldfun &rest args)
(let ((process-environment))
(if (display-graphic-p)
(progn (setenv "MDVIEWER_texdoc" "emacsclient")
(setenv "PDFVIEWER_texdoc" "emacsclient")
(setenv "PAGER_texdoc" "emacsclient"))
(setenv "MDVIEWER_texdoc" "emacsclient -nw")
(let ((process-environment process-environment)
(emacs-cmd (concat "emacsclient" (and (not (display-graphic-p)) " -nw"))))
(setenv "PDFVIEWER_texdoc" "evince")
(setenv "PAGER_texdoc" "emacsclient -nw"))
(setenv "MDVIEWER_texdoc" emacs-cmd)
(setenv "PAGER_texdoc" emacs-cmd)
(apply oldfun args)))
(advice-add 'TeX-documentation-texdoc :around 'my/-auctex-texdoc-setup-env)
(defun my/-setup-LaTeX-mode ()