unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
@ 2023-08-02 13:11 Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-08-03 14:58 ` Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-08-02 13:11 UTC (permalink / raw)
  To: 65022

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))






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-02 13:11 bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8 Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-03 14:58 ` Michael Albinus
  2023-08-03 15:42   ` Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2023-08-03 14:58 UTC (permalink / raw)
  To: 65022; +Cc: nephrite

[-- Attachment #1: Type: text/plain, Size: 798 bytes --]

Георгий Потапов via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 868 bytes --]

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 29361f8a113..a052b054f03 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3640,7 +3640,7 @@ tramp-skeleton-write-region

 	     ;; Set the ownership.
              (when need-chown
-               (tramp-set-file-uid-gid filename uid gid)))
+               (tramp-set-file-uid-gid filename uid gid))

 	   ;; Set extended attributes.  We ignore possible errors,
 	   ;; because ACL strings could be incompatible.
@@ -3662,7 +3662,7 @@ tramp-skeleton-write-region
 	   (when (and (null noninteractive)
 		      (or (eq ,visit t) (string-or-null-p ,visit)))
 	     (tramp-message v 0 "Wrote %s" filename))
-	   (run-hooks 'tramp-handle-write-region-hook))))))
+	   (run-hooks 'tramp-handle-write-region-hook)))))))

 ;;; Common file name handler functions for different backends:


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-03 14:58 ` Michael Albinus
@ 2023-08-03 15:42   ` Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-08-04  4:23     ` Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-08-03 15:42 UTC (permalink / raw)
  To: 65022

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!






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-03 15:42   ` Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-04  4:23     ` Michael Albinus
  2023-08-04  7:19       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2023-08-04  4:23 UTC (permalink / raw)
  To: 65022
  Cc: 65022-done,
	Георгий Потапов

Version: 29.2

Георгий Потапов via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-04  4:23     ` Michael Albinus
@ 2023-08-04  7:19       ` Eli Zaretskii
  2023-08-04  7:24         ` bug#65022: Aw: " Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-04  7:19 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 65022, nephrite

> Resent-To: bug-gnu-emacs@gnu.org
> Cc: 65022-done@debbugs.gnu.org,
>  Георгий Потапов <nephrite@inbox.ru>
> From: Michael Albinus <michael.albinus@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@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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65022: Aw: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-04  7:19       ` Eli Zaretskii
@ 2023-08-04  7:24         ` Michael Albinus
  2023-08-05 16:12           ` Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2023-08-04  7:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 65022, nephrite

[-- Attachment #1: Type: text/html, Size: 2097 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65022: Aw: Re: bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8
  2023-08-04  7:24         ` bug#65022: Aw: " Michael Albinus
@ 2023-08-05 16:12           ` Michael Albinus
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Albinus @ 2023-08-05 16:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 65022, nephrite

Michael Albinus <michael.albinus@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-05 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 13:11 bug#65022: 29.1; Tramp resets file buffer encoding to UTF-8 Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 14:58 ` Michael Albinus
2023-08-03 15:42   ` Георгий Потапов via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04  4:23     ` Michael Albinus
2023-08-04  7:19       ` Eli Zaretskii
2023-08-04  7:24         ` bug#65022: Aw: " Michael Albinus
2023-08-05 16:12           ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).