Skip to content

Commit

Permalink
Don't display in terminal-frame when the current Emacs is a daemon (#…
Browse files Browse the repository at this point in the history
…194)

Adds `purpose--frame-list` which is aware of `terminal-frame` and uses
it in all instances where `frame-list` would be used for selecting a
frame for displaying a buffer.

closes #161
  • Loading branch information
nnicandro authored May 4, 2024
1 parent bb462f1 commit 776c5ef
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions window-purpose-switch.el
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ the purpose PURPOSE."
(and (not (window-dedicated-p window))
(eql purpose (purpose-window-purpose window))))

(defun purpose--frame-list ()
"Return a list of all live frames.
Similar to `frame-list', the only difference being that the
initial, hidden, frame which is kept around when Emacs is run as
a daemon is excluded."
(if (daemonp)
(delq terminal-frame (frame-list))
(frame-list)))

(defun purpose--reusable-frames (alist)
"Return a list of reusable frames.
If ALIST contains a `reusable-frames' entry, its value determines which
Expand Down Expand Up @@ -252,9 +261,9 @@ terminal if it's non-nil."
(cl-remove-if-not
#'(lambda (frame)
(eql (frame-terminal frame) (frame-terminal)))
(frame-list)))
(purpose--frame-list)))
((eql reusable-frames t)
(frame-list))
(purpose--frame-list))
(t
(message "Bad value for reusable-frames in ALIST: %S"
reusable-frames)
Expand Down Expand Up @@ -489,7 +498,7 @@ This function doesn't raise the new frame."
(mapcar
#'(lambda (frame)
(purpose-display--frame-usable-windows frame buffer))
(remove (selected-frame) (frame-list)))))
(remove (selected-frame) (purpose--frame-list)))))
(window (car windows)))
(when window
(purpose-change-buffer buffer window 'reuse alist)
Expand Down

0 comments on commit 776c5ef

Please sign in to comment.