If you want to switch to a buffer that is in another frame, use C-x 5 b, not C-x 4 b or C-x b. IOW, just use C-x 5 b for your buffer that is in a dedicated window, after using your toggle command.
If you want to have certain buffers always be in dedicated windows in their own frames, you can use option special-display-buffer-names or special-display-regexps....
As @tarsius says, I think you'll probably have to put something
together yourself to get what you want. To hopefully get you closer
to doing that, I'll try to solve a part of the problem.
Here's the helpful diagram you gave in your duplicate stackoverflow
frame 1 frame 2
Aquamacs is a version of GNU Emacs configured to behave in a more OSX way like TextEdit. This means that each thing is in a separate OS Window. Later versions of Aquamacs and macOS have added tabs so things can open in a new tab.
Thus Aquamacs is behaving as designed.
You can limit the number of new OS Windows/Emacs frames that are opened by customising ...
I cannot offer more than the following rather general answer (copied straight from another question).
You can control how Magit selects a window to display a certain buffer using the option magit-display-buffer-function as described in Switching Buffers. Unfortunately this is a rather complicated matter and it is not possible to come up with a solution that ...
Notice that your code will misbehave if ad-do-it ends up signalling an error (so the subsequent fset is not executed any more to restore the normal state).
Here's a slightly more verbose way to get what you want, which I think works better (e.g. it lets C-h f show you what's going on, and it does not misbehave when you use the new threading facilities):
Both fset and defalias can point to a symbol or its current function definition, depending on whether you pass them the symbol or symbol-function applied to the symbol. The latter gets the value of symbol-function at the time of aliasing. The former gives you the value of symbol-function at the time the alias in invoked - it is essentially an indirection.