From 267f209037c981cfc8e6388d0690277d03e0b094 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 11 Oct 2024 11:36:25 -0700 Subject: [PATCH] Fix some stuff --- elisp/latex-help.el | 36 +++++++++++++++++++++--------------- init.el | 2 ++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/elisp/latex-help.el b/elisp/latex-help.el index e563085..2583fc0 100644 --- a/elisp/latex-help.el +++ b/elisp/latex-help.el @@ -279,10 +279,11 @@ A marker file is a file that signifies that its parent is a texdoc entry." (cl-loop for root in latex-help-documentation-roots append (latex-help--search-texdoc-root root))) -(defun latex-help--list-texdoc-files-for-entry (entry) +(defun latex-help--texdoc-files-for-entry (entry) "List the texdoc files for ENTRY. ENTRY is of the form (name . dir). This returns a list of conses of the display -name of the entry and the file it belongs to." +name of the entry and the file it belongs to. The first item the the returned +list is the default value when prompting with `completing-read'." (with-temp-buffer (when-let ((exit-code (call-process latex-help-texdoc-program nil t nil "-Ml" (car entry))) @@ -309,10 +310,12 @@ name of the entry and the file it belongs to." (group (* any)))) nil t) (let* ((file (match-string 1)) + (relname (file-relative-name (match-string 1) + (cdr entry))) (desc (match-string 2)) (prompt (if (zerop (length desc)) - file - (format "%s - %s" desc file)))) + relname + (format "%s (%s)" desc relname)))) ;; check if the file is actually belongs to this entry (when (string-prefix-p (cdr entry) file) (push (cons prompt file) found)))) @@ -321,11 +324,12 @@ name of the entry and the file it belongs to." (defun latex-help--texdoc-prompt-for-entry-file (entry) "Prompt the user to open a texdoc file from ENTRY. This will return nil if the user does not want to open the file." - (let ((entries (latex-help--list-texdoc-files-for-entry entry))) + (let ((entries (latex-help--texdoc-files-for-entry entry))) (if (length= entries 1) - (and (y-or-n-p (format "Open texdoc \"%s\"?" (caar entry))) - (cdar entry)) - (let ((ans (completing-read "Texdoc File: " (mapcar 'car entries) nil t))) + (and (y-or-n-p (format "Open texdoc \"%s\"?" (caar entries))) + (cdar entries)) + (let ((ans (completing-read "Texdoc File: " (mapcar 'car entries) nil t + nil nil (caar entries)))) (unless (zerop (length ans)) (cdr (assoc ans entries))))))) @@ -525,16 +529,18 @@ in the texdoc cache." INFO-ENTRY is an entry from one of the info caches. TEXDOC-ENTRY is an entry from the texdoc cache." (let* ((texdoc-files (and texdoc-entry - (latex-help--list-texdoc-files-for-entry + (latex-help--texdoc-files-for-entry texdoc-entry))) - (prompts (nconc (mapcar (lambda (node) - (concat "(Info) " (car node))) - (cdr info-entry)) - (mapcar (lambda (file) + (prompts (nconc (mapcar (lambda (file) (concat "(Texdoc) " (car file))) - texdoc-files)))) + texdoc-files) + (mapcar (lambda (node) + (concat "(Info) " (car node))) + (cdr info-entry))))) (when prompts - (let ((selected (completing-read "LaTeX Help: " prompts nil t))) + (let ((selected (completing-read "LaTeX Help: " prompts nil t nil + nil (when texdoc-files + (car prompts))))) (when (string-match (rx bos "(" (group (+ (any (?a . ?z)) (any (?A . ?Z)))) ") " (group (* any))) diff --git a/init.el b/init.el index 3abf6fb..80838f5 100644 --- a/init.el +++ b/init.el @@ -766,6 +766,8 @@ to `posframe-show' if the display is graphical." (use-package consult-flycheck :defer nil :bind (:map flycheck-mode-map + ("C-c C-e" . consult-flycheck) + :map emacs-lisp-mode-map ("C-c C-e" . consult-flycheck))) ;; eldoc