Change to when-let* and if-let*
This commit is contained in:
@ -185,7 +185,7 @@ return t. Otherwise, kill the buffer and return nil."
|
||||
(kill-buffer (current-buffer))
|
||||
(user-error "File \"%s\" is binary" file)))
|
||||
;; we are good to go
|
||||
(when-let (old-buffer (get-buffer latex-help-texdoc-buffer-name))
|
||||
(when-let* ((old-buffer (get-buffer latex-help-texdoc-buffer-name)))
|
||||
(kill-buffer old-buffer))
|
||||
(rename-buffer latex-help-texdoc-buffer-name)
|
||||
(pop-to-buffer (current-buffer))))))
|
||||
@ -337,9 +337,9 @@ This returns a list of conses of the display 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" entry))
|
||||
((not (zerop exit-code))))
|
||||
(when-let* ((exit-code (call-process latex-help-texdoc-program nil t
|
||||
nil "-Ml" entry))
|
||||
((not (zerop exit-code))))
|
||||
;; try to get the programs output without the normal Emacs process
|
||||
;; sentinel message
|
||||
(goto-char (point-max))
|
||||
@ -427,11 +427,11 @@ This is done by parsing the index for `latex-help-info-manual'."
|
||||
(*? any) ":" (+ " ")
|
||||
(group (+? any)) ".")))))
|
||||
(push (list "(SPACE)" "\\(SPACE)") found)
|
||||
(when-let (entry (assoc "(...\\)" found))
|
||||
(when-let* ((entry (assoc "(...\\)" found)))
|
||||
(setq found (assoc-delete-all "(...\\)" found))
|
||||
(push (cons "(" (cdr entry)) found)
|
||||
(push (cons ")" (cdr entry)) found))
|
||||
(when-let (entry (assoc "[...\\]" found))
|
||||
(when-let* ((entry (assoc "[...\\]" found)))
|
||||
(setq found (assoc-delete-all "[...\\]" found))
|
||||
(push (cons "[" (cdr entry)) found)
|
||||
(push (cons "]" (cdr entry)) found))
|
||||
@ -497,7 +497,7 @@ they want to use.
|
||||
|
||||
If DEFAULT is non-nil, use that instead of prompting. If it does not exist,
|
||||
return nil."
|
||||
(when-let (entries (cdr (assoc name (latex-help--get-cache-for-type type))))
|
||||
(when-let* ((entries (cdr (assoc name (latex-help--get-cache-for-type type)))))
|
||||
(cond
|
||||
(default
|
||||
(assoc default entries))
|
||||
@ -531,7 +531,7 @@ This returns the name of the thing that was prompted."
|
||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||
which to use. If NODE is non-nil, use that instead."
|
||||
(interactive (list (latex-help--prompt-for 'command)))
|
||||
(when-let (entry (latex-help--maybe-prompt-entry name 'command node))
|
||||
(when-let* ((entry (latex-help--maybe-prompt-entry name 'command node)))
|
||||
(latex-help--info-goto-entry entry)))
|
||||
|
||||
;;;###autoload
|
||||
@ -540,7 +540,7 @@ which to use. If NODE is non-nil, use that instead."
|
||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||
which to use. If NODE is non-nil, use that instead."
|
||||
(interactive (list (latex-help--prompt-for 'environment)))
|
||||
(when-let (entry (latex-help--maybe-prompt-entry name 'environment node))
|
||||
(when-let* ((entry (latex-help--maybe-prompt-entry name 'environment node)))
|
||||
(latex-help--info-goto-entry entry)))
|
||||
|
||||
;;;###autoload
|
||||
@ -549,7 +549,7 @@ which to use. If NODE is non-nil, use that instead."
|
||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||
which to use. If NODE is non-nil, use that instead."
|
||||
(interactive (list (latex-help--prompt-for 'package)))
|
||||
(when-let (entry (latex-help--maybe-prompt-entry name 'package node))
|
||||
(when-let* ((entry (latex-help--maybe-prompt-entry name 'package node)))
|
||||
(latex-help--info-goto-entry entry)))
|
||||
|
||||
;;;###autoload
|
||||
@ -558,7 +558,7 @@ which to use. If NODE is non-nil, use that instead."
|
||||
Unless NODE is non-nil, if NAME is in more than one node, prompt the user for
|
||||
which to use. If NODE is non-nil, use that instead."
|
||||
(interactive (list (latex-help--prompt-for 'class)))
|
||||
(when-let (entry (latex-help--maybe-prompt-entry name 'class node))
|
||||
(when-let* ((entry (latex-help--maybe-prompt-entry name 'class node)))
|
||||
(latex-help--info-goto-entry entry)))
|
||||
|
||||
;;;###autoload
|
||||
@ -567,7 +567,7 @@ which to use. If NODE is non-nil, use that instead."
|
||||
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)))
|
||||
(when-let* ((file (latex-help--texdoc-prompt-for-entry-file name)))
|
||||
(latex-help--texdoc-open-file file)))
|
||||
|
||||
(defun latex-help--prompt-info-and-texdoc (info-entry texdoc-entry)
|
||||
@ -604,7 +604,7 @@ point. If that thing at point is valid, it will open an info buffer to the
|
||||
documentation for that thing."
|
||||
(interactive)
|
||||
(latex-help--maybe-init-caches)
|
||||
(if-let (thing (latex-help--get-thing-at-point))
|
||||
(if-let* ((thing (latex-help--get-thing-at-point)))
|
||||
(let ((info-entry (assoc (car thing) (latex-help--get-cache-for-type
|
||||
(cdr thing))))
|
||||
(texdoc-entry (and (member (cdr thing) '(class package environment))
|
||||
@ -658,23 +658,23 @@ Prompt the user for an info topic or texdoc file, then open that thing."
|
||||
(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)))))
|
||||
(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) ")))
|
||||
(string-match (rx "(Info) " (group (+ (not " ")))
|
||||
" - " (group (+ any)))
|
||||
ans)
|
||||
(when-let ((thing (match-string 2 ans))
|
||||
(type (intern (downcase (match-string 1 ans))))
|
||||
(entry (latex-help--maybe-prompt-entry thing type)))
|
||||
(when-let* ((thing (match-string 2 ans))
|
||||
(type (intern (downcase (match-string 1 ans))))
|
||||
(entry (latex-help--maybe-prompt-entry thing type)))
|
||||
(latex-help--info-goto-entry entry)))))))
|
||||
|
||||
(provide 'latex-help)
|
||||
|
||||
Reference in New Issue
Block a user