":set fileencodings&" does not restore initial value

5 views
Skip to first unread message

Gary Johnson

unread,
Jun 13, 2021, 11:59:33 AM6/13/21
to vim...@googlegroups.com
When starting Vim on a Linux system, 'fileencodings' is set to
"ucs-bom,utf-8,default,latin1". But, after executing

set fileencodings&

or

set all&

the value changes to "usc-bom" even though the value of 'encoding'
has remained "utf-8". ":help fileencodings" says:

'fileencodings' 'fencs' string (default: "ucs-bom",
"ucs-bom,utf-8,default,latin1" when
'encoding' is set to a Unicode value)

I think the behavior of ":set fileencodings&" and ":set all&" is
contrary to the documentation and is a bug.

Example:

$ vim -N -u NONE -i NONE
:verbose set encoding? fileencodings?
encoding=utf-8
fileencodings=ucs-bom,utf-8,default,latin1
:set all&
:verbose set encoding? fileencodings?
encoding=utf-8
fileencodings=ucs-bom

The OS is Ubuntu 20.04.2. The Vim version is:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 11 2021 21:55:17)
Included patches: 1-2976
Compiled by gary@aurora
Normal version with GTK2 GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr +tag_binary
-arabic +file_in_path -mouse_sysmouse -tag_old_static
+autocmd +find_in_path -mouse_urxvt -tag_any_white
+autochdir +float +mouse_xterm -tcl
-autoservername +folding +multi_byte -termguicolors
+balloon_eval -footer +multi_lang -terminal
-balloon_eval_term +fork() -mzscheme +terminfo
+browse +gettext +netbeans_intg +termresponse
+builtin_terms -hangul_input +num64 +textobjects
+byte_offset +iconv +packages +textprop
+channel +insert_expand +path_extra +timers
+cindent +ipv6 -perl +title
+clientserver +job +persistent_undo +toolbar
+clipboard +jumplist +popupwin +user_commands
+cmdline_compl -keymap +postscript +vartabs
+cmdline_hist +lambda +printer +vertsplit
+cmdline_info -langmap -profile +virtualedit
+comments +libcall +python +visual
+conceal +linebreak -python3 +visualextra
+cryptv +lispindent +quickfix +viminfo
+cscope +listcmds +reltime +vreplace
+cursorbind +localmap -rightleft +wildignore
+cursorshape -lua -ruby +wildmenu
+dialog_con_gui +menu +scrollbind +windows
+diff +mksession +signs +writebackup
+digraphs +modify_fname +smartindent +X11
+dnd +mouse -sound -xfontset
-ebcdic +mouseshape +spell +xim
-emacs_tags -mouse_dec +startuptime +xpm
+eval +mouse_gpm +statusline +xsmp_interact
+ex_extra -mouse_jsbterm -sun_workshop +xterm_clipboard
+extra_search -mouse_netterm +syntax -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -g3 -DFEAT_CONCEAL -DFEAT_MOUSE_SGR -DFEAT_VARTABS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

Regards,
Gary

Bram Moolenaar

unread,
Jun 13, 2021, 2:28:13 PM6/13/21
to vim...@googlegroups.com, Gary Johnson

Gary Johnson wrote:

> When starting Vim on a Linux system, 'fileencodings' is set to
> "ucs-bom,utf-8,default,latin1". But, after executing
>
> set fileencodings&
>
> or
>
> set all&
>
> the value changes to "usc-bom" even though the value of 'encoding'
> has remained "utf-8". ":help fileencodings" says:
>
> 'fileencodings' 'fencs' string (default: "ucs-bom",
> "ucs-bom,utf-8,default,latin1" when
> 'encoding' is set to a Unicode value)
>
> I think the behavior of ":set fileencodings&" and ":set all&" is
> contrary to the documentation and is a bug.
>
> Example:
>
> $ vim -N -u NONE -i NONE
> :verbose set encoding? fileencodings?
> encoding=utf-8
> fileencodings=ucs-bom,utf-8,default,latin1
> :set all&
> :verbose set encoding? fileencodings?
> encoding=utf-8
> fileencodings=ucs-bom

The generic options code only handles a static default value. In this
case the default value depends on the 'encoding' option. That requires
some extra code to handle the exception. I think it's worth it.

--
This computer is so slow, it takes forever to execute and endless loop!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages