Skip to content

Commit

Permalink
Refactor internal-buffers to internal-buffer-list.
Browse files Browse the repository at this point in the history
Symmetric to buffer-list.
  • Loading branch information
aadcg committed Jun 21, 2024
1 parent f93c945 commit 28bb564
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
21 changes: 11 additions & 10 deletions source/buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,23 +1079,24 @@ This is a low-level function. See `buffer-delete' for the high-level version."
(buffers-delete (id buffer))
(add-to-recent-buffers buffer)))

(export-always 'internal-buffers)
(defun internal-buffers ()
;; Note that the `buffers' slot only keeps track of "main" buffers.
(append (sera:filter #'internal-url-p (buffer-list))
(alex:flatten (loop for window in (window-list)
collect (active-prompt-buffers window)
collect (panel-buffers window)
collect (status-buffer window)
collect (message-buffer window)))))

(export-always 'buffer-list)
(defun buffer-list ()
"Order is stable."
(sort (alex:hash-table-values (buffers *browser*))
#'>
:key #'id))

(export-always 'internal-buffers)
(defun internal-buffer-list (&key (all nil))
;; Note that the `buffers' slot only keeps track of "main" buffers.
(append (sera:filter #'internal-url-p (buffer-list))
(when all
(alex:flatten (loop for window in (window-list)
collect (active-prompt-buffers window)
collect (panel-buffers window)
collect (status-buffer window)
collect (message-buffer window))))))

(defun buffers-get (id)
"Get the `buffer' with the corresponding ID."
(gethash id (slot-value *browser* 'buffers)))
Expand Down
2 changes: 1 addition & 1 deletion source/status.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Augment this with `style' of STATUS, if necessary."
(loop for url in domain-deduplicated-urls
collect
;; FIXME: Removing NIL buffers here too, the same reason as above.
(let* ((internal-buffers (remove-if-not #'internal-url-p buffers :key #'url))
(let* ((internal-buffers (internal-buffer-list))
(domain (quri:uri-domain url))
(tab-display-text (if (internal-url-p url)
"internal"
Expand Down
4 changes: 3 additions & 1 deletion source/urls.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ TITLE is purely informative."
(query (quri:uri-query-params %url))
(title (alex:assoc-value query "title" :test 'equal))
(buffer-id (alex:assoc-value query "buffer" :test 'equal))
(buffer (find (read-from-string buffer-id) (internal-buffers) :key 'id)))
(buffer (find (read-from-string buffer-id)
(internal-buffer-list :all t)
:key 'id)))
(log:debug "Evaluate Lisp callback ~a in buffer ~a: ~a" request-id buffer title)
(values
(alex:if-let ((callback (sera:synchronized ((lisp-url-callbacks buffer))
Expand Down

0 comments on commit 28bb564

Please sign in to comment.