Fix some stuff
This commit is contained in:
parent
9ae0d7a93f
commit
267f209037
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user