This was a fast one. I struggled with this for quite a bit but a few minutes after posting the question, I found the answer myself.
I got a keyboard shortcut (Ctrl + ß) for opening Emacs in addition to the default shortcut Unity provides (Ctrl + 4 because it's the 4th application in my launcher). Every time I use Unity's shortcut, Emacs' menu bar integrates nicely with Unity. Every time I use my own shortcut, it doesn't.
I then found that the exec line of Emacs' desktop file looks like this:
Exec=emacs25 %F
My own shortcut, however, executes emacs
. I removed Emacs 24 and after launching Emacs via emacs
, it actually launches Emacs 25, according to Help → About Emacs
. Yet, the menu bar behaves differently.
When launching emacs25
from the command line, Emacs' menu bar integrates with Unity just like it does when using Unity's shortcut or when using the button in the launcher. I will now change my own shortcut to execute emacs25
.
If anyone knows why Emacs behaves in this weird fashion, please let me know.
Development version
Edit: If you want to use the current development version of Emacs, first install it normally (with sudo make install
). Then open a terminal, enter emacs
(but don't hit enter) and press tab twice. You will be shown several program names, including one with with a version number. In my case, this is emacs-27.0.50
. Then open /usr/local/share/applications/emacs.desktop
and adapt the Exec line. So
Exec=emacs %F
becomes:
Exec=emacs-27.0.50 %F
Save the file and open Emacs as usual via its desktop file. The menus will be integrated into the window bars.