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 ;;;###autoload
(defun latex-help-texdoc (name) (defun latex-help-texdoc (name)
"Lookup NAME in the texdoc cache. "Lookup NAME in the texdoc cache.
When used interactively, prompt for NAME. If DIR is nil, it will be looked up When used interactively, prompt for NAME."
in the texdoc cache."
(interactive (list (latex-help--prompt-texdoc-entry))) (interactive (list (latex-help--prompt-texdoc-entry)))
(latex-help--maybe-init-caches) (latex-help--maybe-init-caches)
(when-let ((file (latex-help--texdoc-prompt-for-entry-file name))) (when-let ((file (latex-help--texdoc-prompt-for-entry-file name)))
@ -634,22 +633,39 @@ documentation for that thing."
"Get help with LaTeX. "Get help with LaTeX.
Prompt the user for an info topic or texdoc file, then open that thing." Prompt the user for an info topic or texdoc file, then open that thing."
(interactive) (interactive)
(let ((prompts)) (let ((prompts)
(tap (latex-help--get-thing-at-point))
(def-entry nil)
(def-name nil))
(latex-help--maybe-init-caches) (latex-help--maybe-init-caches)
(cl-flet ((add-cache-for-type (type) (cl-flet ((add-cache-for-type (type)
(dolist (entry (latex-help--get-cache-for-type type)) (dolist (entry (latex-help--get-cache-for-type type))
(push (format "(Info) %s - %s" (push (format "(Info) %s - %s"
(capitalize (symbol-name type)) (capitalize (symbol-name type))
(car entry)) (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 'command)
(add-cache-for-type 'package) (add-cache-for-type 'package)
(add-cache-for-type 'class) (add-cache-for-type 'class)
(add-cache-for-type 'environment) (add-cache-for-type 'environment)
(dolist (entry latex-help--texdoc-cache) (dolist (entry latex-help--texdoc-cache)
(push (format "(Texdoc) %s" entry) prompts)) (push (format "(Texdoc) %s" entry) prompts)
(when-let ((ans (completing-read "LaTeX Help: " prompts (when (and (member (cdr tap) '(class package environment))
nil t nil 'latex-help--general-history)) (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))))) ((not (zerop (length ans)))))
(if (string-prefix-p "(Texdoc) " ans) (if (string-prefix-p "(Texdoc) " ans)
(latex-help-texdoc (seq-subseq ans (length "(Texdoc) "))) (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 . LaTeX-math-mode)
(LaTeX-mode . my/-setup-LaTeX-mode)) (LaTeX-mode . my/-setup-LaTeX-mode))
:bind (:map TeX-mode-map :bind (:map TeX-mode-map
("C-c ?" . latex-help-texdoc)) ("C-c ?" . latex-help))
:init :init
(add-to-list 'major-mode-remap-alist '(plain-tex-mode . plain-TeX-mode)) (add-to-list 'major-mode-remap-alist '(plain-tex-mode . plain-TeX-mode))
(add-to-list 'major-mode-remap-alist '(latex-mode . LaTeX-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)) (add-to-list 'auto-mode-alist '("/\\.latexmkrc\\'" . perl-mode))
:config :config
(defun my/-auctex-texdoc-setup-env (oldfun &rest args) (defun my/-auctex-texdoc-setup-env (oldfun &rest args)
(let ((process-environment)) (let ((process-environment process-environment)
(if (display-graphic-p) (emacs-cmd (concat "emacsclient" (and (not (display-graphic-p)) " -nw"))))
(progn (setenv "MDVIEWER_texdoc" "emacsclient")
(setenv "PDFVIEWER_texdoc" "emacsclient")
(setenv "PAGER_texdoc" "emacsclient"))
(setenv "MDVIEWER_texdoc" "emacsclient -nw")
(setenv "PDFVIEWER_texdoc" "evince") (setenv "PDFVIEWER_texdoc" "evince")
(setenv "PAGER_texdoc" "emacsclient -nw")) (setenv "MDVIEWER_texdoc" emacs-cmd)
(setenv "PAGER_texdoc" emacs-cmd)
(apply oldfun args))) (apply oldfun args)))
(advice-add 'TeX-documentation-texdoc :around 'my/-auctex-texdoc-setup-env) (advice-add 'TeX-documentation-texdoc :around 'my/-auctex-texdoc-setup-env)
(defun my/-setup-LaTeX-mode () (defun my/-setup-LaTeX-mode ()