Subject: bug#38917: 26.3; tar-mode bugs and suggestions

From: [email-masked]
Date: Sat, 04 Jan 2020 23:04:11 +0900

Here are some bug reports of tar-mode and suggestions of new
functionalities.

(1)tar-mode buffer is not read only.
   Normal editing commands are allowed and the buffer is easily broken.
   For example, Tab key inserts a tab character.

(2)Tar subfile coding system may be inappropriate.
   If a subfile is an ASCII text, buffer-file-coding-system of the subfile
   buffer is 'undecided or an EOL type variant. And if non-ASCII characters
   are added, utf-8-unix or an EOL type variant is silently used to save
   the subfile buffer.
   For a real file, (default-value 'buffer-file-coding-system) or an EOL
   type variant is used if encodable, otherwise a new coding system is
   asked.

   If a coding system of a subfile is detected and non-encodable
   characters are added, they are silently replaced with SPCs when saving.
   For a real file, a new coding system is asked.

(3)Saving tar subfile does not mark the entry in tar-mode as modified.
   Edit and save a subfile, the entry should marked with a '*' character.
   Altering an attribute also needs to mark the entry.
   #'tar-alter-one-field should call #'tar-header-block-summarize
   with MOD-P=t.

(4)Cancelling 'g'(revert-buffer) clears the buffer modified flag.
   Edit and save a subfile, tar-mode buffer is flagged as modified.
   Then type 'g', emacs asks whether to revert really, and answer 'no'.
   The modified flag of the tar-mode buffer is cleared.
   'C-x C-s' reports '(No changes need to be saved)', and file is
   not saved.

(5)'d'(tar-flag-deleted) or 'u'(tar-unflag) flags the buffer as modified.
   Only marking or unmarking does not edit the real data for a tar file,
   then the tar-mode buffer's modified flag should not be changed.

(6)'r'(tar-rename-entry) should check new name.
   A name for a regular file entry should not end with '/'.
   And a directory entry name should end with '/'.

   Also, these points may be checked:
     a path containing consecutive '/'s
     a path containing '.' or '..'
     a path starting with '/'
     a path starting with a drive letter like 'c:'
     inappropriate characters for a real file
     reserved names in MS-DOS such as 'CON'
     a name allready used for another entry

(7)A tar file needs 2 blocks of 512 nuls at the end.
   If the last entry is a regular file and its data block ends at
   512*20 bytes with a non-zero length padding, the saved tar file size
   may be 512*20 bytes. The file is warned 'premature end of file'.
   In #'tar-pad-to-blocksize, the local variable 'pad-to' is wrong.

   Detailed procedure to reproduce:
     Prepare a tar file with only one entry(regular file).
     Edit the subfile so that 512*18 < subfile size < 512*19.
     Save the subfile and save the tar file.
     The size of the tar file is 10240, and it lacks blocks of nuls.
     Type 'g' and answer 'yes', the warning is displayed.

(8)'I'(tar-new-entry) changes the tar file size not to multiple of 10240.
   #'tar-new-entry simply increases the size of a tar file by 512.
   #'tar-pad-to-blocksize should be called.

The following parts are suggestions.

(A)Allow 'I'(tar-new-entry) to create a directory entry.
   When the path name is ending with '/'.

(B)Control visibility of subfile attributes.
   Add 'invisible text property on each attribute text.
   Setting the vatiable buffer-invisibility-spec changes the appearance.
   Supposed values are:
     file-type, user-permission, group-permission, other-permission,
     user-name, group-name, file-size, filie-name, link-name

(C)Mark multiple subfiles and operate on them.
   Marking commands:
     Mark the current line entry.
     Mark a directory and descendant entries.
     Mark entries matching a path regexp.
     Mark entries with an extension.
   Operations:
     tar-copy
     tar-rename-entry
     tar-chmod-entry
     tar-chown-entry
     tar-chgrp-entry

(D)Make #'tar-untar-buffer to accept a target directory.
   Also a subfile directory may be specified to limit extracted subfiles.

(E)Move entry postions or sort entry positions.
   If entries are renamed, it may be better to reorder entry positions.
   Ordering may be lexical or numerical.
   frame12.jpg may be preferred to be placed before frame110.jpg.
   Upper/lower case may be ignored.

In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29 built on CIRROCUMULUS
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor 'Microsoft Corp.', version 6.3.9600
Recent messages:

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS THREADS LCMS2

Important settings:
  value of $LANG: JPN
  locale-coding-system: cp932

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date
mule-util japan-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type 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 elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 99275 6564)
 (symbols 48 20225 1)
 (miscs 40 36 118)
 (strings 32 29771 1074)
 (string-bytes 1 764676)
 (vectors 16 14540)
 (vector-slots 8 572199 10838)
 (floats 8 51 66)
 (intervals 56 228 0)
 (buffers 992 11))