Skip to content

Commit

Permalink
Don't try to insert deps if buffer has been killed
Browse files Browse the repository at this point in the history
  • Loading branch information
amake committed Aug 8, 2024
1 parent c6d7d01 commit 91d14bd
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions macports-describe.el
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,17 @@ CALLBACK is responsible for setting the markers to nil when finished."
(macports-core--async-shell-command-to-string
command
(lambda (result exit-status)
(with-current-buffer buf
(save-excursion
(let* ((inhibit-read-only t)
(cleaned (replace-regexp-in-string "\r" "" result))
(had-output (not (string-blank-p cleaned))))
(delete-region (marker-position s-marker) (marker-position e-marker))
(goto-char (marker-position s-marker))
(insert (if had-output cleaned empty-msg))
(set-marker e-marker (point))
(funcall callback s-marker e-marker had-output (= exit-status 0)))))))))
(when (buffer-live-p buf)
(with-current-buffer buf
(save-excursion
(let* ((inhibit-read-only t)
(cleaned (replace-regexp-in-string "\r" "" result))
(had-output (not (string-blank-p cleaned))))
(delete-region (marker-position s-marker) (marker-position e-marker))
(goto-char (marker-position s-marker))
(insert (if had-output cleaned empty-msg))
(set-marker e-marker (point))
(funcall callback s-marker e-marker had-output (= exit-status 0))))))))))

(defun macports-describe--linkify-urls ()
"Linkify URLs in current buffer."
Expand Down Expand Up @@ -208,23 +209,24 @@ Will null-out S-MARKER and E-MARKER markers upon completion."
(macports-core--async-shell-command-to-string
(concat macports-command " -q rdeps --no-build --no-test " port)
(lambda (result _exit-status)
(with-current-buffer buf
(save-excursion
(goto-char (marker-position s-marker))
(let (had-build-test-only
(inhibit-read-only t)
(no-build (split-string (string-trim result))))
(while (re-search-forward "[^[:blank:]\n]+" (marker-position e-marker) t)
(let ((dep (match-string-no-properties 0)))
(unless (member dep no-build)
(add-text-properties (match-beginning 0) (match-end 0) '(face macports-describe-build-test-only-rdeps))
(insert "*")
(setq had-build-test-only t))))
(when had-build-test-only
(goto-char (marker-position e-marker))
(insert "\n *Build- or test-only dependency"))))
(macports-describe--dispose-markers s-marker e-marker)
(macports-describe--update-status :rdeps-build-test-only t))))))
(when (buffer-live-p buf)
(with-current-buffer buf
(save-excursion
(goto-char (marker-position s-marker))
(let (had-build-test-only
(inhibit-read-only t)
(no-build (split-string (string-trim result))))
(while (re-search-forward "[^[:blank:]\n]+" (marker-position e-marker) t)
(let ((dep (match-string-no-properties 0)))
(unless (member dep no-build)
(add-text-properties (match-beginning 0) (match-end 0) '(face macports-describe-build-test-only-rdeps))
(insert "*")
(setq had-build-test-only t))))
(when had-build-test-only
(goto-char (marker-position e-marker))
(insert "\n *Build- or test-only dependency"))))
(macports-describe--dispose-markers s-marker e-marker)
(macports-describe--update-status :rdeps-build-test-only t)))))))

(defun macports-describe--update-status (key value)
"Update the load status with KEY and VALUE."
Expand Down

0 comments on commit 91d14bd

Please sign in to comment.