Right, Commands such as (shell-command "xclip -selection clipboard -o") hang unless the clipboard has the "right" content either text or image.
As a workaround, you can terminate it by using timeout TIMEOUT.
When only plain text exists in the clipboard and you use
(shell-command (format "xclip -selection clipboard -t ...
You can use the per-command setting of the encoding that @choroba mentions in his comment (C-x RET c utf-8) which will only affect the next command, but you can also set UTF-8 to be the default encoding everywhere. Add
to your init file and restart emacs. Or for the current session, click on "Options/...
(buffer-file-name) returns the full pathname of the file visited in the current buffer but that is NOT the name of the buffer, so the output is saved in a different buffer. The name of the current buffer is returned by calling the function buffer-name. But the doc string for shell-command says:
The optional second argument OUTPUT-BUFFER, if non-nil,