holomorph / transmission

Emacs interface to a Transmission session
GNU General Public License v3.0
85 stars 11 forks source link

multibyte for unicode strings #27

Open tamwile opened 8 months ago

tamwile commented 8 months ago

When i have a torrent in my list with non ascii characters, they are represented as escaped unicode \xxx

The enable-multibyte-characters variable is set to true, so this shouldn't happen. Here is a hack to circumvent it in the meantime: Calling (set-buffer-multibyte t) doesn't work, we first need to (set-buffer-multibyte nil) and then to (set-buffer-multibyte t). Or alternatively, to call (toggle-enable-multibyte-characters) twice.

I can reproduce it with emacs -Q and emacs -nw.

At the beginning, i thought it was a bug in emacs, but proced works correctly with processes having non ascii chars.

transmission-draw-torrents seems to return the escaped version of strings, but when calling transmission-remote from the terminal, it works and renders correctly.

Can someone tell me if the error is in transmission or transmission.el, and possibly fix it ?

stvlm6 commented 1 week ago

I just upgraded from Ubuntu LTS 22.04 to 22.04.1 today. In the process I upgraded transmission from 3.00 to 4.0.5. I compile emacs (28) from source separately so it was not altered in the upgrade. I now have the issue exactly as you describe above, it was working as intended for the end user prior to this upgrade. I suspect it is a transmission problem although I am too lazy to dig deeper. Something related to transmission RPC maybe. Note, I have not yet downgraded back to 3.00 for confirmation that this is exactly where the problem is.

tamwile commented 1 week ago

Yes, that was also my conclusion. iirc, i think i have read an issue in the transmission repo saying they are now using a lib to handle unicode. The cli tools from the transmission project are working because they probably have been adapted.

I guess someone with some elisp knowledge could try to make a pull request to follow this breaking change of transmission.

In the meantime, i use this dirty trick:

(defun transmission-hack-multibyte ()
  "Circumvent multibyte bug with transmission.el"
  (interactive)
  (revert-buffer)
  (toggle-enable-multibyte-characters)
  (toggle-enable-multibyte-characters)
  )

And i bind g to this function instead of the default.

stvlm6 commented 1 week ago

Dirty trick applied to transmission.el since I like the auto refresh.

(defun transmission-timer-revert ()
  "Revert the buffer or cancel `transmission-timer'."
  (if (and (memq major-mode transmission-refresh-modes)
           (not (or (bound-and-true-p isearch-mode)
                    (buffer-narrowed-p)
                    (use-region-p))))
    (progn
      (revert-buffer)
      (set-buffer-multibyte nil)
      (set-buffer-multibyte t))
    (cancel-timer transmission-timer)))