GNU bug report logs - #65022
29.1; Tramp resets file buffer encoding to UTF-8

Previous Next

Package: emacs;

Reported by: Георгий Потапов <nephrite <at> inbox.ru>

Date: Wed, 2 Aug 2023 13:34:05 UTC

Severity: normal

Found in version 29.1

Fixed in version 29.2

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65022 in the body.
You can then email your comments to 65022 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Wed, 02 Aug 2023 13:34:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Георгий Потапов <nephrite <at> inbox.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 02 Aug 2023 13:34:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Георгий Потапов <nephrite <at> inbox.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Wed, 2 Aug 2023 16:11:49 +0300
I edit my files in cp1251 encoding.

This works fine on local host but when I save files on remote host using 
tramp it resets encoding to utf-8 constantly.

Even if I do |(set-buffer-file-coding-system)| to cp1251, it sets the 
encoding for awhile, but after saving the file it immediately resets to 
utf-8-unix. The saved file appears in cp1251 as desired, but the buffer 
encoding becomes utf-8-unix and subsequent saving appears in utf-8-unix

For example, I do |(set-buffer-file-coding-system 'cp1251)|

save file

the file on disk is in cp1251 encoding, but the encoding flag in the 
left bottom becomes U for utf-8

save file again

it is in utf-8 encoding

It happens regardless of if the file contains only ASCII symbols or 
non-ASCII symbols.

Local files are saved normally.


The issue appeared in emacs 29.1, everything was ok in 28.1

workaround

|(defun set-remote-encoding () "set buffer encoding to cp1251" 
(set-buffer-file-coding-system 'cp1251)) (add-hook 'before-save-hook 
'set-remote-encoding) |





In GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-07-31 built on
 AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Pro (v10.0.2009.19045.3208)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation=aot
 --without-compress-install --with-tree-sitter CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

(NATIVE_COMP present but libgccjit not available)

Important settings:
  value of $LANG: RUS
  locale-coding-system: cp1251

Major mode: Fundamental

Minor modes in effect:
  poke-line-global-mode: t
  winner-mode: t
  smartparens-global-mode: t
  smartparens-global-strict-mode: t
  pixel-scroll-mode: t
  global-hi-lock-mode: t
  global-display-line-numbers-mode: t
  global-display-fill-column-indicator-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
c:/home/.emacs.d/lisp/j-mode hides 
c:/home/.emacs.d/elpa/j-mode-20171224.1856/j-mode
c:/home/.emacs.d/elpa/transient-20230120.1559/transient hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/transient
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-lint hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-lint
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-jump hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-jump
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-ensure
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish 
hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-diminish
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-delight 
hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-delight
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-core hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-core
c:/home/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key 
hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-bind-key
c:/home/.emacs.d/elpa/bind-key-20210210.1609/bind-key hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/use-package/bind-key
c:/home/.emacs.d/elpa/prolog-1.22/prolog hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/progmodes/prolog
c:/home/.emacs.d/elpa/hierarchy-20190425.842/hierarchy hides 
c:/emacs/emacs-29.1/emacs-29.1/share/emacs/29.1/lisp/emacs-lisp/hierarchy

Features:
(shadow sort mail-extr emacsbug message yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils poke-line poke-line-types tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time iso8601 time-date
semantic/idle semantic/analyze semantic/sort semantic/scope
semantic/analyze/fcn semantic/db eieio-base semantic/format ezimage
semantic/tag-ls semantic/find semantic/ctxt easy-mmode srcery-theme
winner smartparens semantic/util-modes semantic/util semantic pp
semantic/tag semantic/lex semantic/fw mode-local find-func cedet
pixel-scroll cua-base hl-line hi-lock display-line-numbers
display-fill-column-indicator eyebrowse format-spec dash elec-pair time
cus-load quail cyril-util mmm-mode mmm-univ mmm-class mmm-region
mmm-auto mmm-vars mmm-utils mmm-compat gperl-mode derived flymake-proc
flymake project compile text-property-search pcase folding-isearch
folding lilliputify evil evil-keybindings evil-integration evil-maps
evil-commands reveal flyspell ispell evil-jumps evil-command-window
evil-search evil-ex shell pcomplete comint ansi-osc ansi-color
evil-types evil-macros evil-repeat evil-states evil-core comp comp-cstr
warnings icons cl-extra help-mode advice evil-common windmove calc
calc-loaddefs calc-macs thingatpt rect evil-digraphs evil-vars ring
edmacro kmacro finder-inf rx slime-autoloads info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 462564 18444)
 (symbols 48 40503 1)
 (strings 32 192102 6856)
 (string-bytes 1 5120517)
 (vectors 16 45388)
 (vector-slots 8 1202977 28692)
 (floats 8 138 59)
 (intervals 56 593 0)
 (buffers 984 12))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Thu, 03 Aug 2023 14:59:02 GMT) Full text and rfc822 format available.

Message #8 received at 65022 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Георгий Потапов via "Bug reports
 for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: 65022 <at> debbugs.gnu.org,
 Георгий Потапов
 <nephrite <at> inbox.ru>
Subject: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Thu, 03 Aug 2023 16:58:49 +0200
[Message part 1 (text/plain, inline)]
Георгий Потапов via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

Hi Georgij,

> I edit my files in cp1251 encoding.
>
> This works fine on local host but when I save files on remote host
> using tramp it resets encoding to utf-8 constantly.

Thanks for the report. I could reproduce the problem locally.

It took me a while for debugging, but finally I could fix it. It was a
stupid scoping error when changing something between Emacs 28 and Emacs
29. The fix, which works for me, is appended.

It is a little bit tricky to install the patch, because it is in a
defmacro of tramp.el. This macro is used in tramp-sh.el. You must
compile both files in this order. Could you pls check?

Best regards, Michael.

[Message part 2 (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Thu, 03 Aug 2023 15:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Thu, 03 Aug 2023 15:48:02 GMT) Full text and rfc822 format available.

Message #14 received at 65022 <at> debbugs.gnu.org (full text, mbox):

From: Георгий Потапов <nephrite <at> inbox.ru>
To: 65022 <at> debbugs.gnu.org
Subject: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Thu, 3 Aug 2023 18:42:30 +0300
03.08.2023 17:58, Michael Albinus writes:
> It is a little bit tricky to install the patch, because it is in a
> defmacro of tramp.el. This macro is used in tramp-sh.el. You must
> compile both files in this order. Could you pls check?

Yes, I've installed the patch and now saving works as intended.

No more encoding switching.

Thank you very much!





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Fri, 04 Aug 2023 04:24:02 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Георгий Потапов via "Bug reports
 for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: 65022-done <at> debbugs.gnu.org,
 Георгий Потапов
 <nephrite <at> inbox.ru>
Subject: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Fri, 04 Aug 2023 06:23:00 +0200
Version: 29.2

Георгий Потапов via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

Hi Georgij,

>> It is a little bit tricky to install the patch, because it is in a
>> defmacro of tramp.el. This macro is used in tramp-sh.el. You must
>> compile both files in this order. Could you pls check?
>
> Yes, I've installed the patch and now saving works as intended.
>
> No more encoding switching.

Thanks for the feedback. I've installed the patch in the repositories,
will appear with Emacs 29.2.

> Thank you very much!

Best regards, Michael.




Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Fri, 04 Aug 2023 04:24:02 GMT) Full text and rfc822 format available.

Notification sent to Георгий Потапов <nephrite <at> inbox.ru>:
bug acknowledged by developer. (Fri, 04 Aug 2023 04:24:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Fri, 04 Aug 2023 07:20:02 GMT) Full text and rfc822 format available.

Message #25 received at 65022 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 65022 <at> debbugs.gnu.org, nephrite <at> inbox.ru
Subject: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Fri, 04 Aug 2023 10:19:23 +0300
> Resent-To: bug-gnu-emacs <at> gnu.org
> Cc: 65022-done <at> debbugs.gnu.org,
>  Георгий Потапов <nephrite <at> inbox.ru>
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Date: Fri, 04 Aug 2023 06:23:00 +0200
> 
> Version: 29.2
> 
> Георгий Потапов via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs <at> gnu.org> writes:
> 
> Hi Georgij,
> 
> >> It is a little bit tricky to install the patch, because it is in a
> >> defmacro of tramp.el. This macro is used in tramp-sh.el. You must
> >> compile both files in this order. Could you pls check?
> >
> > Yes, I've installed the patch and now saving works as intended.
> >
> > No more encoding switching.
> 
> Thanks for the feedback. I've installed the patch in the repositories,
> will appear with Emacs 29.2.

Am I missing something, or did you install this on master, not on
emacs-29?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Fri, 04 Aug 2023 07:25:02 GMT) Full text and rfc822 format available.

Message #28 received at 65022 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65022 <at> debbugs.gnu.org, nephrite <at> inbox.ru
Subject: Aw: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
Date: Fri, 4 Aug 2023 09:24:16 +0200
[Message part 1 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65022; Package emacs. (Sat, 05 Aug 2023 16:13:02 GMT) Full text and rfc822 format available.

Message #31 received at 65022 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65022 <at> debbugs.gnu.org, nephrite <at> inbox.ru
Subject: Re: Aw: Re: bug#65022: 29.1; Tramp resets file
 buffer encoding to UTF-8
Date: Sat, 05 Aug 2023 18:12:41 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

> On master. The emacs-29 branch will get it when I sync it with Tramp
> 2.6.1. Hopefully, later this weekend.

Pushed as 2695af297e8 to the emacs-29 branch.

> Best regards, Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Sep 2023 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 75 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.