3
  1. I use Magit to manage Git repositories.
  2. Some of these repositories have collaborators whose names contain accented characters.
  3. In a freshly-started Emacs, everything looks fine.
  4. In a long-running Emacs process, such accented characters eventually start being rendered incorrectly.
  5. These characters appear in a magit buffer
    • which is not associated with a file
    • in a special portion of the buffer which is not accessible with the usual Emacs navigation commands, search commands, etc.

How should I go about understanding and fixing this problem?

2
  • 2
    Does it also happen in *magit-revision buffers (which show author names the main part of the buffer, not margins)? Checking coding system related variables like default-process-coding-system or process-coding-system-alist.
    – npostavs
    Commented Sep 10, 2017 at 18:57
  • @npostavs Yes it also happens in *magit-revision buffers. default-process-coding-system was different from its value in new processes. Resetting it fixes the problem. So now I know how to fix it, but not what is causing it or how to prevent it. Do you want to turn this into an answer I can formally accept?
    – jacg
    Commented Sep 11, 2017 at 7:19

1 Answer 1

3

Emacs decides how to decode output from subprocesses (like git) based on the value of default-process-coding-alist (and others, see (elisp) Default Coding Systems). The default value for this variable generally works well.

It sounds like you have some package that changes it; if you have a recent Emacs 26 snapshot you could use the watchpoint feature to track it down. Something along the lines of:

(defun debug-if-setting (symbol newval op where)
  "Call debugger if setting SYMBOL's value.
Don't do anything if let-binding."
  (if (or inhibit-debug-on-entry debugger-jumping-flag
          (not (eq op 'set)))
      nil
    (let ((inhibit-debug-on-entry t))
      (funcall debugger 'watchpoint symbol newval op where))))
(add-variable-watcher 'default-process-coding-system #'debug-if-setting)

Alternatively, you could paper over the problem with:

(defun use-default-process-coding (fun &rest args)
  (let ;; Replace the value with whatever you have by default.
       ((default-process-coding-system '(utf-8-unix . utf-8-unix)))
    (apply fun args)))
(advice-add 'magit--process-coding-system :around #'use-default-process-coding)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.