From unknown Fri Aug 15 15:34:50 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#61326 <61326@debbugs.gnu.org> To: bug#61326 <61326@debbugs.gnu.org> Subject: Status: 30.0.50; Editing fil in zip file without extension save creates new file Reply-To: bug#61326 <61326@debbugs.gnu.org> Date: Fri, 15 Aug 2025 22:34:50 +0000 retitle 61326 30.0.50; Editing fil in zip file without extension save creat= es new file reassign 61326 emacs submitter 61326 Adam Sj=C3=B8gren severity 61326 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 12:00:35 2023 Received: (at submit) by debbugs.gnu.org; 6 Feb 2023 17:00:35 +0000 Received: from localhost ([127.0.0.1]:49751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP4r4-00064n-Sj for submit@debbugs.gnu.org; Mon, 06 Feb 2023 12:00:35 -0500 Received: from lists.gnu.org ([209.51.188.17]:48724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP4r2-00064f-Uh for submit@debbugs.gnu.org; Mon, 06 Feb 2023 12:00:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP4qx-0002lI-T4 for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 12:00:32 -0500 Received: from virgil.koldfront.dk ([212.237.178.116]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP4qt-00070z-TE for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 12:00:26 -0500 Received: from tullinup.koldfront.dk (tullinup.koldfront.dk [192.168.1.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by virgil.koldfront.dk (Postfix) with ESMTPS id 16EB816C168F1 for ; Mon, 6 Feb 2023 18:00:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 virgil.koldfront.dk 16EB816C168F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koldfront.dk; s=mail; t=1675702814; bh=dVBc0XIPiCfOaMR9fdn01abUwypAASst4juHYfvdrJY=; h=From:To:Subject:Date:From; b=DkdOIl4fb3YocNYsVMUmHXuhYDfh427LshXIxMUM4lZC0RarfJY6FQ82BYV/TiLnL RgrEuF42eTeh5VpkOvcloDrfCMHL5SK18QK6PH4zqwli8LSHRafBGKhnGq4nvwOl1e fj5HwaHjV++X6zDXkXT8BBf496qN+WUTg2282t8DFTAQ7sz+z7Unc7llWSPJ3NIv6g q8XpYjLfQiD065AuyBQ8IYJBoM7ksEBm5foPkxOqqJastL7p0V4XMJp8sXZTlZP6+M VlIxGP8HIf+0oetrVLs/WALDcf6jUOjWeju1OYI/QS+AcCbwB7OSn5JyFvWn8Hn+iV zmspefHeVjzcQ== Received: by tullinup.koldfront.dk (Postfix, from userid 1000) id 0643C201A00FD; Mon, 6 Feb 2023 18:00:14 +0100 (CET) From: =?utf-8?Q?Adam_Sj=C3=B8gren?= To: bug-gnu-emacs@gnu.org Subject: 30.0.50; Editing fil in zip file without extension save creates new file Organization: koldfront - analysis & revolution, Copenhagen, Denmark OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc X-Now-Playing: The Real Snow White, 4:13 Dream (The Cure) X-Hashcash: 1:25:230206:bug-gnu-emacs@gnu.org::dN7UVlw/KqLXJXab:2RNvq X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=212.237.178.116; envelope-from=asjo@koldfront.dk; helo=virgil.koldfront.dk X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) If I open a zip archive in Emacs, I get a listing of files within the archive, and I can edit the files by pressing RET, and if I then save the file, Emacs updates the archive. However, if the zip archive doesn't have ".zip" (or ".jar") at the end of the filename, Emacs instead of updating the archive opened, creates a new archive with ".zip" added. Example: $ echo ABBA > a.txt $ zip a.zip a.txt adding: a.txt (stored 0%) $ mv a.zip extless $ ls a.txt extless $ emacs -Q extless=20 $ # RET on a.txt, add to content, save $ ls a.txt extless extless.zip $=20 I was expecting the zip archive I opened, "extless" to be updated, instead of a new file "extless.zip" appearing. The expected behaviour is useful when editing e.g. "zipimport" binaries, such as yt-dlp: https://github.com/yt-dlp/yt-dlp#release-files In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.16.0) of 2023-01-15 built on tullinup Repository revision: b017c0453c73798c30b2f046bfa62a57cf6ea72b Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101006 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure -C --with-tree-sitter --with-librsvg --with-xinput2 --without-pgtk --with-native-compilation=3Daot' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix Major mode: Group Minor modes in effect: gnus-topic-mode: t gnus-undo-mode: t age-encryption-mode: t pixel-scroll-precision-mode: t global-git-commit-mode: t magit-auto-revert-mode: t dumb-jump-mode: t shell-dirtrack-mode: t which-function-mode: t global-auto-complete-mode: t save-place-mode: t jabber-activity-mode: t winner-mode: t server-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 font-lock-mode: t buffer-read-only: t line-number-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: ~/elisp/let-alist/let-alist hides ~/elisp/extra/let-alist /home/asjo/elisp/boxquote.el/boxquote hides ~/elisp/extra/boxquote ~/elisp/let-alist/let-alist hides /usr/src/emacs/lisp/emacs-lisp/let-alist Features: (shadow bbdb-message emacsbug shr-color executable js-mode-expansions js c-ts-mode treesit cc-mode-expansions cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs flow-fill rng-xsd xsd-regexp rng-cmpct nxml-mode-expansions rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-enc xmltok jka-compr mm-archive bbdb-gnus-aux qp mule-util url-http url-gw url-auth gnus-gravatar gravatar sort smiley gnus-cite textsec uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check gnus-bcklg gnus-async gnus-dup gnus-ml disp-table gnus-topic utf-7 imap rfc2104 face-remap epa-file network-stream nsm nnml bbdb-gnus bbdb-mua nnnil gnus-demon gnus-delay gnus-draft gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp gnus-cache nndraft nnmh mail-extr spam spam-stat bbdb-com gnus-uu yenc gnus-msg gnus-html url-queue help-fns radix-tree url-cache mm-url bbdb-picture gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr pixel-fill kinsoku url-file svg gnus-group gnus-undo gnus-fun hashcash gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win gnus nnheader range flymake-proc flymake time age pixel-scroll cua-base litable magithub magithub-ci magithub-issue magithub-cache magithub-core magit-submodule magit-obsolete magit-popup magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log magit-diff smerge-mode diff git-commit log-edit message sendmail yank-media rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor magit-mode magit-git magit-section benchmark magit-utils vc-git diff-mode ido crm markdown-mode color noutline outline rg pcase rg-info-hack rg-menu transient rg-ibuffer ibuf-macs rg-result wgrep-rg rg-history rg-header ibuf-ext ibuffer ibuffer-loaddefs wgrep grep compile text-property-search dumb-jump f dash s etags fileloop generator xref project tramp tramp-loaddefs trampver tramp-integration cus-edit pp cus-load files-x tramp-compat shell pcomplete parse-time iso8601 ls-lisp auto-loads tex-site expand-region subword-mode-expansions cperl-mode-expansions text-mode-expansions html-mode-expansions er-basic-expansions thingatpt expand-region-core expand-region-custom which-func cperl-mode auto-complete-config auto-complete edmacro kmacro popup debian-changelog-mode imenu add-log dpkg-dev-el saveplace vc vc-dispatcher bbdb bbdb-site timezone bbdb-loaddefs julia-mode julia-mode-latexsubs boxquote rect jabber-last-message-correction jabber-http-file-upload jabber-print-html jabber-otr jabber jabber-notifications notifications jabber-libnotify dbus jabber-awesome jabber-osd jabber-wmii jabber-xmessage jabber-festival jabber-sawfish jabber-ratpoison jabber-tmux jabber-screen jabber-socks5 jabber-ft-server jabber-si-server jabber-ft-client jabber-ft-common jabber-si-client jabber-si-common jabber-feature-neg jabber-truncate jabber-time jabber-autoaway time-date jabber-vcard-avatars jabber-chatstates jabber-events jabber-vcard jabber-avatar jabber-activity jabber-watch jabber-modeline easy-mmode advice jabber-ahc-presence jabber-ahc jabber-version jabber-ourversion jabber-muc-nick-completion hippie-exp comint ansi-osc ansi-color jabber-browse jabber-search jabber-register jabber-roster format-spec jabber-presence jabber-muc jabber-bookmarks jabber-private jabber-muc-nick-coloring hexrgb jabber-widget jabber-disco wid-edit jabber-chat jabber-history jabber-chatbuffer jabber-alert jabber-iq jabber-core jabber-console derived sgml-mode facemenu dom ewoc jabber-keymap jabber-sasl sasl sasl-anonymous sasl-login sasl-plain fsm jabber-logon jabber-conn comp comp-cstr warnings icons rx cl-extra help-mode srv dns starttls tls jabber-xml xml jabber-menu jabber-util cl winner ring gnutls puny find-file-from-selection find-lisp dired dired-loaddefs cap-words superword subword server finder-inf 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 term/x-win x-win term/common-win x-dnd 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 dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 1135254 142749) (symbols 48 43507 17) (strings 32 298866 21178) (string-bytes 1 12616608) (vectors 16 98259) (vector-slots 8 3113739 175347) (floats 8 750 1097) (intervals 56 795 371) (buffers 984 33)) --=20 "Den ene mands loft Adam Sj=C3=B8gr= en Er den anden mands gulv" asjo@koldfront.dk From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 13:04:44 2023 Received: (at 61326) by debbugs.gnu.org; 6 Feb 2023 18:04:44 +0000 Received: from localhost ([127.0.0.1]:49850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP5rA-00085m-HD for submit@debbugs.gnu.org; Mon, 06 Feb 2023 13:04:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP5r8-00085a-Cd for 61326@debbugs.gnu.org; Mon, 06 Feb 2023 13:04:42 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP5r2-00044g-2d; Mon, 06 Feb 2023 13:04:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Tzsbudb3b2rGDz6lSRM4Oh+mEHPH/9cqIqvPEPUIxvA=; b=E4UrEt31MuBI4kNvi98p NX4hWC0xIzyQiEe9AHP5cfpcXIB2FCgyGPp1O8HxFz6kjUb5WGuqsjA31qzVL3zZwd8hunLZfu8wF nlF9zgGizY504F//mYjuTi2iNYg+H7H+8wARwXAOWpNzLJ2sHL+82+srVEorzS3+4zxbi+Ny4370M g9f1j1UIn1piK8D+lsze/XIWKCm+2wB9+8XhDB899JH5SLR8/2asV257UAjeaebGT56oMv2UbNDkO 6IgtgyRFiB/oATM5x6aGe4WGkNMtqC/iuQ64yseF9O43lgvfr4Fae3JsX8wcj9uz/FtxFyY9tT47Y WVgipTro8dbgeg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP5r1-0000bM-7u; Mon, 06 Feb 2023 13:04:35 -0500 Date: Mon, 06 Feb 2023 20:04:47 +0200 Message-Id: <83mt5qpt4w.fsf@gnu.org> From: Eli Zaretskii To: Adam =?utf-8?Q?Sj=C3=B8gren?= In-Reply-To: <87zg9qohk1.fsf@tullinup.koldfront.dk> (bug-gnu-emacs@gnu.org) Subject: Re: bug#61326: 30.0.50; Editing fil in zip file without extension save creates new file References: <87zg9qohk1.fsf@tullinup.koldfront.dk> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Mon, 06 Feb 2023 18:00:14 +0100 > From: Adam Sjøgren via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > If I open a zip archive in Emacs, I get a listing of files within the > archive, and I can edit the files by pressing RET, and if I then save > the file, Emacs updates the archive. > > However, if the zip archive doesn't have ".zip" (or ".jar") at the end > of the filename, Emacs instead of updating the archive opened, creates a > new archive with ".zip" added. AFAIR, Emacs uses the 'zip' program to create or update a zip archive, and I suspect that the fact the archive has .zip appended is because that's what the 'zip' program does. Did you try looking at the command that Emacs invokes when you update a member of the archive? From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 13:15:47 2023 Received: (at 61326) by debbugs.gnu.org; 6 Feb 2023 18:15:47 +0000 Received: from localhost ([127.0.0.1]:49867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP61q-0008O7-PW for submit@debbugs.gnu.org; Mon, 06 Feb 2023 13:15:46 -0500 Received: from virgil.koldfront.dk ([212.237.178.116]:36916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP61o-0008Nv-4P for 61326@debbugs.gnu.org; Mon, 06 Feb 2023 13:15:45 -0500 Received: from tullinup.koldfront.dk (tullinup.koldfront.dk [192.168.1.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by virgil.koldfront.dk (Postfix) with ESMTPS id C123416C1623D for <61326@debbugs.gnu.org>; Mon, 6 Feb 2023 19:15:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 virgil.koldfront.dk C123416C1623D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koldfront.dk; s=mail; t=1675707341; bh=kmAVuEw1FiaUHYXsZ6T37F9mDtD0Z+cvpdTbSvJNkqk=; h=From:To:Subject:In-Reply-To:References:Date:From; b=Myb+vFTmHhrbmYJ7uCbI2WRdmIbd45XdzIO0OS56aCISE8+YGjS/8CE4QfYwe8kc1 eLBp6uAo50ddBtIQmxavdK96/tXb6gsUwl7OudaRHoH0jJq4tRZl//5gXh2tS4mEy+ 5Jk/ktJE4EUjEBGQ61chlTpmUHPW9FnqcxjV7jsy4qKx5gAgmmAnDuQ5F0dQ/OGk/7 kftMDSSMjKmMVLk/XRxAeHfluGAJUsBL+XHeSRHkpqsWDRwWqQrmfAT5XEQ+x9MQeJ CqySI4Q1rOHAIxf69O8Wo8ASg43cIqdEFyxlZJlIichwMnMrSjfQGtIW3zdMu+LHo2 zV9Xn+IfLPE7g== Received: by tullinup.koldfront.dk (Postfix, from userid 1000) id A866D201A00FD; Mon, 6 Feb 2023 19:15:41 +0100 (CET) From: =?utf-8?Q?Adam_Sj=C3=B8gren?= To: 61326@debbugs.gnu.org Subject: Re: bug#61326: 30.0.50; Editing fil in zip file without extension save creates new file In-Reply-To: <83mt5qpt4w.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 06 Feb 2023 20:04:47 +0200") Organization: koldfront - analysis & revolution, Copenhagen, Denmark References: <87zg9qohk1.fsf@tullinup.koldfront.dk> <83mt5qpt4w.fsf@gnu.org> OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc X-Now-Playing: The Real Snow White, 4:13 Dream (The Cure) X-Hashcash: 1:25:230206:61326@debbugs.gnu.org::6Ygp+FV4lqnFbH/x:W3EC X-Hashcash: 1:25:230206:eliz@gnu.org::SLJETlCsKWQWw75H:15fSq X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61326 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli writes: > I suspect that the fact the archive has .zip appended is because > that's what the 'zip' program does. Yes - I skimmed the man-page for zip(1), and there doesn't seem to be an option to turn off "add .zip if there is no '.' in the filename" - unfortunately, that would have been really handy here. > Did you try looking at the command that Emacs invokes when you update > a member of the archive? I did not. From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 13:57:27 2023 Received: (at 61326) by debbugs.gnu.org; 6 Feb 2023 18:57:27 +0000 Received: from localhost ([127.0.0.1]:49946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP6gA-0001Af-RP for submit@debbugs.gnu.org; Mon, 06 Feb 2023 13:57:27 -0500 Received: from virgil.koldfront.dk ([212.237.178.116]:46964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP6g7-0001AR-Fg for 61326@debbugs.gnu.org; Mon, 06 Feb 2023 13:57:24 -0500 Received: from tullinup.koldfront.dk (tullinup.koldfront.dk [192.168.1.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by virgil.koldfront.dk (Postfix) with ESMTPS id 6AEF116C168F1 for <61326@debbugs.gnu.org>; Mon, 6 Feb 2023 19:57:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 virgil.koldfront.dk 6AEF116C168F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koldfront.dk; s=mail; t=1675709839; bh=8R6OIpfFZsQplsGjLndxTx+os09jSUoNVL9u5p2NN8E=; h=From:To:Subject:Date:From; b=KaxAAIjJKrH78+frvcrn8gFkX+kPP8slfJkvHyHKVWJvNhSo/shlwBfFIx9GHj+d3 ZnCV210TS3R4h1YZJB5s/ExG/lLK2rsAi8xsNsCtOZRj7Z8pysz+1y9ZGEf90ruVpF 00n0X7+ndZmIYP0Mubu51NptOLVoDxwaLd8piEoJCihtMD2u0kGThZdKZHg+0z2VDv ThGizm9YeyAMs99bzwwMjywqrJW61rOUMAR1Ht4szgt/u9WH9uJ/7ONEu7LmdWxP2Z xuarjjDn7DI4KENUlV7VmdCVa7O8hoN/rDREozLLpfLdAKG/duVbZ3IdVbGnm1VRia j3uryGSqloIKg== Received: by tullinup.koldfront.dk (Postfix, from userid 1000) id 57558201E2A18; Mon, 6 Feb 2023 19:57:19 +0100 (CET) From: =?utf-8?Q?Adam_Sj=C3=B8gren?= To: 61326@debbugs.gnu.org Subject: Adding --no-add-suffix to zip patch Organization: koldfront - analysis & revolution, Copenhagen, Denmark OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc X-Now-Playing: The Real Snow White, 4:13 Dream (The Cure) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61326 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Adding a '--no-add-suffix' option to zip 3.0 is not too bad: diff -u orig/zip-3.0/globals.c chan/zip-3.0/globals.c --- orig/zip-3.0/globals.c 2008-05-25 19:26:38.000000000 +0200 +++ chan/zip-3.0/globals.c 2023-02-06 19:42:48.000000000 +0100 @@ -106,6 +106,7 @@ int noisy = 1; /* 0=quiet operation */ int extra_fields = 1; /* 0=create minimum, 1=don't copy old, 2=keep old */ int use_descriptors = 0; /* 1=use data descriptors 12/29/04 */ +int no_add_suffix = 0; /* 1=do not add suffix .zip to archive names without . */ int zip_to_stdout = 0; /* output zipfile to stdout 12/30/04 */ int allow_empty_archive = 0; /* if no files, create empty archive anyway 12/28/05 */ int copy_only = 0; /* 1=copying archive entries only */ diff -u orig/zip-3.0/zip.c chan/zip-3.0/zip.c --- orig/zip-3.0/zip.c 2023-02-06 19:49:42.000000000 +0100 +++ chan/zip-3.0/zip.c 2023-02-06 19:47:26.000000000 +0100 @@ -1942,6 +1942,7 @@ #ifdef UNICODE_TEST #define o_sC 0x146 #endif +#define o_nas 0x147 /* the below is mainly from the old main command line @@ -2042,6 +2043,7 @@ {"N", "notes", o_NO_VALUE, o_NOT_NEGATABLE, 'N', "add notes as entry comments"}, #endif {"o", "latest-time", o_NO_VALUE, o_NOT_NEGATABLE, 'o', "use latest entry time as archive time"}, + {"", "no-add-suffix", o_NO_VALUE, o_NOT_NEGATABLE, o_nas, "do not add .zip suffix to archive name without ."}, {"O", "output-file", o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'O', "set out zipfile different than in zipfile"}, {"p", "paths", o_NO_VALUE, o_NOT_NEGATABLE, 'p', "store paths"}, {"P", "password", o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'P', "encrypt entries, option value is password"}, @@ -2378,6 +2380,7 @@ before = 0; /* 0=ignore, else exclude files before this time */ after = 0; /* 0=ignore, else exclude files newer than this time */ + no_add_suffix = 0 /* 0=add .zip if no . as usual, else use archive name unchanged */ special = ".Z:.zip:.zoo:.arc:.lzh:.arj"; /* List of special suffixes */ key = NULL; /* Scramble password if scrambling */ key_needed = 0; /* Need scramble password */ @@ -3299,6 +3302,11 @@ break; #endif + case o_nas: + no_add_suffix = 1; + break; + + case o_NON_OPTION_ARG: /* not an option */ /* no more options as permuting */ @@ -3340,8 +3348,14 @@ #endif /* !MACOS && !WINDLL */ { /* name of zipfile */ - if ((zipfile = ziptyp(value)) == NULL) { - ZIPERR(ZE_MEM, "was processing arguments"); + if (no_add_suffix) { + zipfile = value; + } + else { + if ((zipfile = ziptyp(value)) == NULL) { + ZIPERR(ZE_MEM, "was processing arguments"); + } + free(value); } /* read zipfile if exists */ /* @@ -3349,7 +3363,6 @@ ZIPERR(r, zipfile); } */ - free(value); } if (show_what_doing) { fprintf(mesg, "sd: Zipfile name '%s'\n", zipfile); diff -u orig/zip-3.0/zip.h chan/zip-3.0/zip.h --- orig/zip-3.0/zip.h 2008-05-25 19:23:22.000000000 +0200 +++ chan/zip-3.0/zip.h 2023-02-06 19:43:41.000000000 +0100 @@ -442,6 +442,7 @@ extern int use_privileges; /* use security privilege overrides */ #endif extern int use_descriptors; /* use data descriptors (extended headings) */ +extern int no_add_suffix; /* do not add suffix .zip to archive names without . */ extern int allow_empty_archive; /* if no files, create empty archive anyway */ extern int copy_only; /* 1 = copy archive with no changes */ extern int zip_to_stdout; /* output to stdout */ But getting something like that accepted and distributed, and for Emacs to tell whether the installed zip has that option or not, seems like a lot of work. From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 20:31:53 2023 Received: (at 61326) by debbugs.gnu.org; 7 Feb 2023 01:31:53 +0000 Received: from localhost ([127.0.0.1]:50493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPCps-0003tR-VT for submit@debbugs.gnu.org; Mon, 06 Feb 2023 20:31:53 -0500 Received: from netyu.xyz ([152.44.41.246]:51552 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPCpr-0003tJ-Dm for 61326@debbugs.gnu.org; Mon, 06 Feb 2023 20:31:52 -0500 Received: from smtpclient.apple ( [36.249.106.224]) by netyu.xyz (OpenSMTPD) with ESMTPSA id f81ccfe2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Feb 2023 01:31:50 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Ruijie Yu Mime-Version: 1.0 (1.0) Subject: Re: bug#61326: Adding --no-add-suffix to zip patch Date: Tue, 7 Feb 2023 09:31:11 +0800 Message-Id: <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> In-Reply-To: <87ilgeoc4w.fsf@tullinup.koldfront.dk> To: =?utf-8?Q?Adam_Sj=C3=B8gren?= X-Mailer: iPhone Mail (20D47) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Feb 7, 2023, at 02:58, Adam Sj=C3=B8gren via Bug reports for GNU Emacs, t= he Swiss army knife of text editors wrote: >=20 > =EF=BB=BFAdding a '--no-add-suffix' option to zip 3.0 is not too bad: >=20 > diff -u orig/zip-3.0/globals.c chan/zip-3.0/globals.c > --- orig/zip-3.0/globals.c 2008-05-25 19:26:38.000000000 +0200 > +++ chan/zip-3.0/globals.c 2023-02-06 19:42:48.000000000 +0100 > @@ -106,6 +106,7 @@ > int noisy =3D 1; /* 0=3Dquiet operation */ > int extra_fields =3D 1; /* 0=3Dcreate minimum, 1=3Ddon't copy old,= 2=3Dkeep old */ > int use_descriptors =3D 0; /* 1=3Duse data descriptors 12/29/04 */ > +int no_add_suffix =3D 0; /* 1=3Ddo not add suffix .zip to archive n= ames without . */ > int zip_to_stdout =3D 0; /* output zipfile to stdout 12/30/04 */ > int allow_empty_archive =3D 0; /* if no files, create empty archive anywa= y 12/28/05 */ > int copy_only =3D 0; /* 1=3Dcopying archive entries only */ > diff -u orig/zip-3.0/zip.c chan/zip-3.0/zip.c > --- orig/zip-3.0/zip.c 2023-02-06 19:49:42.000000000 +0100 > +++ chan/zip-3.0/zip.c 2023-02-06 19:47:26.000000000 +0100 > @@ -1942,6 +1942,7 @@ > #ifdef UNICODE_TEST > #define o_sC 0x146 > #endif > +#define o_nas 0x147 >=20 >=20 > /* the below is mainly from the old main command line > @@ -2042,6 +2043,7 @@ > {"N", "notes", o_NO_VALUE, o_NOT_NEGATABLE, 'N', "add no= tes as entry comments"}, > #endif > {"o", "latest-time", o_NO_VALUE, o_NOT_NEGATABLE, 'o', "use la= test entry time as archive time"}, > + {"", "no-add-suffix", o_NO_VALUE, o_NOT_NEGATABLE, o_nas, "do n= ot add .zip suffix to archive name without ."}, > {"O", "output-file", o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'O', "set ou= t zipfile different than in zipfile"}, > {"p", "paths", o_NO_VALUE, o_NOT_NEGATABLE, 'p', "store p= aths"}, > {"P", "password", o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'P', "encryp= t entries, option value is password"}, > @@ -2378,6 +2380,7 @@ > before =3D 0; /* 0=3Dignore, else exclude files before this t= ime */ > after =3D 0; /* 0=3Dignore, else exclude files newer than t= his time */ >=20 > + no_add_suffix =3D 0 /* 0=3Dadd .zip if no . as usual, else use ar= chive name unchanged */ > special =3D ".Z:.zip:.zoo:.arc:.lzh:.arj"; /* List of special suffixes *= / > key =3D NULL; /* Scramble password if scrambling */ > key_needed =3D 0; /* Need scramble password */ > @@ -3299,6 +3302,11 @@ > break; > #endif >=20 > + case o_nas: > + no_add_suffix =3D 1; > + break; > + > + > case o_NON_OPTION_ARG: > /* not an option */ > /* no more options as permuting */ > @@ -3340,8 +3348,14 @@ > #endif /* !MACOS && !WINDLL */ > { > /* name of zipfile */ > - if ((zipfile =3D ziptyp(value)) =3D=3D NULL) { > - ZIPERR(ZE_MEM, "was processing arguments"); > + if (no_add_suffix) { > + zipfile =3D value; > + } > + else { > + if ((zipfile =3D ziptyp(value)) =3D=3D NULL) { > + ZIPERR(ZE_MEM, "was processing arguments"); > + } > + free(value); > } > /* read zipfile if exists */ > /* > @@ -3349,7 +3363,6 @@ > ZIPERR(r, zipfile); > } > */ > - free(value); > } > if (show_what_doing) { > fprintf(mesg, "sd: Zipfile name '%s'\n", zipfile); > diff -u orig/zip-3.0/zip.h chan/zip-3.0/zip.h > --- orig/zip-3.0/zip.h 2008-05-25 19:23:22.000000000 +0200 > +++ chan/zip-3.0/zip.h 2023-02-06 19:43:41.000000000 +0100 > @@ -442,6 +442,7 @@ > extern int use_privileges; /* use security privilege overrides */ > #endif > extern int use_descriptors; /* use data descriptors (extended headings= ) */ > +extern int no_add_suffix; /* do not add suffix .zip to archive name= s without . */ > extern int allow_empty_archive; /* if no files, create empty archive anywa= y */ > extern int copy_only; /* 1 =3D copy archive with no changes */ > extern int zip_to_stdout; /* output to stdout */ >=20 > But getting something like that accepted and distributed, and for Emacs > to tell whether the installed zip has that option or not, seems like a > lot of work. Maybe, at least in the meantime, we change it such that all write operations= for zip create files in temp, and move to / overwrite the original file whe= n done? Although I don=E2=80=99t have a full understanding on how that would= be done and whether there are problems along with it.=20= From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 22:27:46 2023 Received: (at 61326) by debbugs.gnu.org; 7 Feb 2023 03:27:46 +0000 Received: from localhost ([127.0.0.1]:50550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPEe1-00078q-VU for submit@debbugs.gnu.org; Mon, 06 Feb 2023 22:27:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPEe0-00078Y-P0 for 61326@debbugs.gnu.org; Mon, 06 Feb 2023 22:27:45 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPEdt-0004P6-78; Mon, 06 Feb 2023 22:27:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=gicD7wLKfwcy30i98lR0xBl9F0qp9IRrIFkg3Xlj4IQ=; b=hhd7faInxdJNOI1y+Nbi XIiC1hAYtZsTJj13UBRH6sMMaeDHteuOojVNFOw2mq8t4tSL7ZO84VxvU+fy7iTjsyBGDrJ2JjHGa DRvztdDUgli2swvrN5FPsYN4REDunuUL9an/i2e11iPgO2Uqm0wtIN2IEWTOl+s1TW3SwxF33hWuV bvz8L8uCWRoSNE1y+aCPIWy1AX8Gvqcb0pKmFZ3124NDTvpEUlRwQMJxtN8VKrt8JcyeYE5lA1Dws qRs2YbrfSPll+uad5U2tqTWJ5GREJw+FpKtZJjtkwmaZy3z5AAys+coBPu64p9G9RaL6S3wQxdm41 jvSqSN0BLfQ/pA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPEds-0001j9-KJ; Mon, 06 Feb 2023 22:27:36 -0500 Date: Tue, 07 Feb 2023 05:27:49 +0200 Message-Id: <83k00up32i.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> (bug-gnu-emacs@gnu.org) Subject: Re: bug#61326: Adding --no-add-suffix to zip patch References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 61326@debbugs.gnu.org > Date: Tue, 7 Feb 2023 09:31:11 +0800 > From: Ruijie Yu via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Maybe, at least in the meantime, we change it such that all write operations for zip create files in temp, and move to / overwrite the original file when done? Although I don’t have a full understanding on how that would be done and whether there are problems along with it. How about submitting a patch to do that, but only when the original file doesn't have an extension? From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 09:23:59 2023 Received: (at 61326) by debbugs.gnu.org; 7 Feb 2023 14:23:59 +0000 Received: from localhost ([127.0.0.1]:51608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPOt5-0003Du-Ab for submit@debbugs.gnu.org; Tue, 07 Feb 2023 09:23:59 -0500 Received: from netyu.xyz ([152.44.41.246]:38744 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPOt3-0003Dk-E6 for 61326@debbugs.gnu.org; Tue, 07 Feb 2023 09:23:57 -0500 Received: from fw.net.yu.netyu.xyz ( [36.249.106.224]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 1c91d5dc (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Feb 2023 14:23:55 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> User-agent: mu4e 1.8.13; emacs 29.0.60 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: Adding --no-add-suffix to zip patch Date: Tue, 07 Feb 2023 21:53:12 +0800 In-reply-to: <83k00up32i.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Eli Zaretskii writes: >> Cc: 61326@debbugs.gnu.org >> Date: Tue, 7 Feb 2023 09:31:11 +0800 >> From: Ruijie Yu via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Maybe, at least in the meantime, we change it such that all write operat= ions >> for zip create files in temp, and move to / overwrite the original file = when >> done? Although I don=E2=80=99t have a full understanding on how that wou= ld be done and >> whether there are problems along with it. > > How about submitting a patch to do that, but only when the original > file doesn't have an extension? Will do. Will report back in 2-3 days unless someone else gets to it first. Best, RY From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 09:54:14 2023 Received: (at 61326) by debbugs.gnu.org; 7 Feb 2023 14:54:14 +0000 Received: from localhost ([127.0.0.1]:51653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPPML-000402-Vn for submit@debbugs.gnu.org; Tue, 07 Feb 2023 09:54:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPPMK-0003zq-1P for 61326@debbugs.gnu.org; Tue, 07 Feb 2023 09:54:12 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPPMD-0004Xy-Nt; Tue, 07 Feb 2023 09:54:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=UZ96IQ+YGGpvaceGv74a5wG0CZdz6+EV7qCrDeh/VLQ=; b=iy9L7vJWsfYuX6wLX9jS Qf2pUl8vADgJhdJ7Lac/S9h5COGSTxeWtaU0fsXRuzTSqTnFFgJH5RySPrwH7ytKkUB1Mpda0uyxm 5DnQ/zQR9O8VDK/iTBsNRC35wV3mu9OMOgw5RBO3LFPa+O5mfj3MXn6Oc7HifPUOoLVLZej9PHqyH qGDp0BJzT+UiBgm1SPUbZLsjDz4J9D2B4im3ZRChW8Eu/8Y6/jhfg7yM664d9Ku0iJDiP824EHxjQ e3/Gw8VQeiLv1SsM/5o3udCYDS2pnEvCjSQdy5E6RkKe54URi/hOZEcyNB7huWtJ3J5EcvK74SVw+ GnF8nrv6IqksXw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPPMD-0000ds-7l; Tue, 07 Feb 2023 09:54:05 -0500 Date: Tue, 07 Feb 2023 16:54:21 +0200 Message-Id: <834jrxpluq.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Tue, 07 Feb 2023 21:53:12 +0800) Subject: Re: bug#61326: Adding --no-add-suffix to zip patch References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Tue, 07 Feb 2023 21:53:12 +0800 > > > Eli Zaretskii writes: > > >> Cc: 61326@debbugs.gnu.org > >> Date: Tue, 7 Feb 2023 09:31:11 +0800 > >> From: Ruijie Yu via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> Maybe, at least in the meantime, we change it such that all write operations > >> for zip create files in temp, and move to / overwrite the original file when > >> done? Although I don’t have a full understanding on how that would be done and > >> whether there are problems along with it. > > > > How about submitting a patch to do that, but only when the original > > file doesn't have an extension? > > Will do. Will report back in 2-3 days unless someone else gets to it > first. Thanks in advance. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 14:59:40 2023 Received: (at 61326) by debbugs.gnu.org; 7 Feb 2023 19:59:40 +0000 Received: from localhost ([127.0.0.1]:54126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPU7w-0006qv-8C for submit@debbugs.gnu.org; Tue, 07 Feb 2023 14:59:40 -0500 Received: from virgil.koldfront.dk ([212.237.178.116]:44422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPU7t-0006qj-W7 for 61326@debbugs.gnu.org; Tue, 07 Feb 2023 14:59:38 -0500 Received: from tullinup.koldfront.dk (tullinup.koldfront.dk [192.168.1.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by virgil.koldfront.dk (Postfix) with ESMTPS id C6FBE16BCC903 for <61326@debbugs.gnu.org>; Tue, 7 Feb 2023 20:59:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 virgil.koldfront.dk C6FBE16BCC903 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koldfront.dk; s=mail; t=1675799973; bh=mHNwEmqr11b+iw3T+auHLjeKS7rtgk/n8it76ckLYc4=; h=From:To:Subject:In-Reply-To:References:Date:From; b=j/9/x/RYxgTckOh2T47Gu0C+KWrWlllF9C1wfyEzPnnwDoGN84sisBJJtGbCRl3jy pRfiwvPofEzHLYZdhh67fyQ03/F+aVb6BNMz6vqJoB2SBCrmvXSOO3VQIzVzQCyIKH 50nJaABM6XjignRgDYgqIxUdaGLYCoBZSX9xdPOYEhwCwtxGm9sErjPToBfaSzH0pf N7yaPA0NXIYQgCgdHRwSbCuwuZNoejRBIYMRAMu3yfz61NWfJQyRMz44JFcmFpWTgq sQUNKbzjY7DXVmVmBZhrSaSsZhEROR82VT6fYQCUN4SGMo1NyKraLwltHQJy4BjxIv iZUIqV18TyAfw== Received: by tullinup.koldfront.dk (Postfix, from userid 1000) id B176420196C92; Tue, 7 Feb 2023 20:59:33 +0100 (CET) From: =?utf-8?Q?Adam_Sj=C3=B8gren?= To: 61326@debbugs.gnu.org Subject: Re: bug#61326: Adding --no-add-suffix to zip patch In-Reply-To: <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> (Ruijie Yu's message of "Tue, 7 Feb 2023 09:31:11 +0800") Organization: koldfront - analysis & revolution, Copenhagen, Denmark References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc X-Now-Playing: The Real Snow White, 4:13 Dream (The Cure) X-Hashcash: 1:25:230207:ruijie@netyu.xyz::j0quCQBs7pLHCCx+:0nbxX X-Hashcash: 1:25:230207:61326@debbugs.gnu.org::MHyT4/JDBk/xavg2:0Hgqf X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61326 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Ruijie writes: > Maybe, at least in the meantime, we change it such that all write > operations for zip create files in temp, and move to / overwrite the > original file when done? Although I don=E2=80=99t have a full understandi= ng on > how that would be done and whether there are problems along with it. That sounds like a good solution, for archives with no '.' in the filename. I guess the main problem is if the archive is huge, updating an existing archive might (?) be more efficient than creating an entirely new one. Another way to go about it could be to temporarily rename the archive to have a name with a '.' in it, make the change, and then rename it back; conceptually: mv a a.zip # update a.zip rather than a mv a.zip a That has its own set of possible problems. Maybe you could make a link to the original archive, where the link has a '.' in the name, have zip update the file via the link and then remove the link again; conceptually: ln a a.zip # update a.zip rather than a rm a.zip I think I like this the most, but again... From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 20:31:41 2023 Received: (at submit) by debbugs.gnu.org; 8 Feb 2023 01:31:41 +0000 Received: from localhost ([127.0.0.1]:54318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPZJE-0003tL-Uy for submit@debbugs.gnu.org; Tue, 07 Feb 2023 20:31:41 -0500 Received: from lists.gnu.org ([209.51.188.17]:50988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPZJC-0003tC-O3 for submit@debbugs.gnu.org; Tue, 07 Feb 2023 20:31:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPZJ8-0001fk-EL for bug-gnu-emacs@gnu.org; Tue, 07 Feb 2023 20:31:34 -0500 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPZJ5-0005KI-I2 for bug-gnu-emacs@gnu.org; Tue, 07 Feb 2023 20:31:32 -0500 Received: from fw.net.yu.netyu.xyz ( [36.249.106.224]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 00d5da1a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 8 Feb 2023 01:31:26 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <87ilgdjlga.fsf@tullinup.koldfront.dk> User-agent: mu4e 1.8.13; emacs 29.0.60 From: Ruijie Yu To: Adam =?utf-8?Q?Sj=C3=B8gren?= Subject: Re: bug#61326: Adding --no-add-suffix to zip patch Date: Wed, 08 Feb 2023 09:21:11 +0800 In-reply-to: <87ilgdjlga.fsf@tullinup.koldfront.dk> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) Adam Sj=C3=B8gren via "Bug reports for GNU Emacs, the Swiss army knife of t= ext editors" writes: > Ruijie writes: > >> Maybe, at least in the meantime, we change it such that all write >> operations for zip create files in temp, and move to / overwrite the >> original file when done? Although I don=E2=80=99t have a full understand= ing on >> how that would be done and whether there are problems along with it. > > That sounds like a good solution, for archives with no '.' in the filenam= e. > > I guess the main problem is if the archive is huge, updating an existing > archive might (?) be more efficient than creating an entirely new one. > > Another way to go about it could be to temporarily rename the archive to > have a name with a '.' in it, make the change, and then rename it back; > conceptually: > > mv a a.zip > # update a.zip rather than a > mv a.zip a > > That has its own set of possible problems. > > Maybe you could make a link to the original archive, where the link has > a '.' in the name, have zip update the file via the link and then remove > the link again; conceptually: > > ln a a.zip > # update a.zip rather than a > rm a.zip > > I think I like this the most, but again... I like the link solution, but I don't think we can reliably "link" without knowing that we actually can do so -- i.e., on MS Windows, IIUC, one needs admin privilege to create symlinks on cmd unless something in the registry is changed. Also, on old MS Windows versions like XP and earier, I believe it is impossible to create symlinks at all. (Do we still support them?) Come to think of it, I think your mv idea might be better and even easier to implement than my zip-offsite-then-overwrite idea. I might lean towards that method if people have no bias when I work on the patch in a couple hours. Best, RY From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 22:27:57 2023 Received: (at 61326) by debbugs.gnu.org; 8 Feb 2023 03:27:57 +0000 Received: from localhost ([127.0.0.1]:54432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPb7l-000704-24 for submit@debbugs.gnu.org; Tue, 07 Feb 2023 22:27:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPb7j-0006zn-8F for 61326@debbugs.gnu.org; Tue, 07 Feb 2023 22:27:55 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPb7b-0007pm-OA; Tue, 07 Feb 2023 22:27:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9mJB59yDh/TxQ66X9eMCqAASC5qWdnoqycw3nNee7HE=; b=LtRJpOxDqHI+ 9gzLOPpRs9BlmCvtX4XApVPTd9Ux5IuC26sUhX5L7HVPK63K/sYqrBxWubSQVsup2hj+3wTxqV1xc GZuDbM5s+kAzfaRvpLTCWAT+gZVPyYulbSTeugpUJQN3eqXqEwIQ6Si/B4o4dL1C5PiiJdmXVP9Uu N7ZulHzPKgoer6HYnnYpSxdIKrdEs6/o6OYN76Dr8DIskF+e2Ee+JPIdDyd8wCFTEhljAZDRgHvSC BiX1sqrH9+VfR7QOxzRaGf8e7SWHbiOA/2p9zX+GJD8/r9nh9VsUjsz5xamzLNfftZDVF4SP6GIWh vb/I9LX4EHLEfi2CnxrsLA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPb7b-0007hU-5w; Tue, 07 Feb 2023 22:27:47 -0500 Date: Wed, 08 Feb 2023 05:28:03 +0200 Message-Id: <83y1p8omyk.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#61326: Adding --no-add-suffix to zip patch References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <87ilgdjlga.fsf@tullinup.koldfront.dk> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 61326@debbugs.gnu.org > Date: Wed, 08 Feb 2023 09:21:11 +0800 > From: Ruijie Yu via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Also, on old MS Windows versions like XP and earier, I believe it is > impossible to create symlinks at all. (Do we still support them?) Yes, we do. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 08 12:00:17 2023 Received: (at 61326) by debbugs.gnu.org; 8 Feb 2023 17:00:17 +0000 Received: from localhost ([127.0.0.1]:56505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPnns-0005qM-N9 for submit@debbugs.gnu.org; Wed, 08 Feb 2023 12:00:17 -0500 Received: from netyu.xyz ([152.44.41.246]:36430 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPnnn-0005q6-HZ for 61326@debbugs.gnu.org; Wed, 08 Feb 2023 12:00:15 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id e6b2930e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 8 Feb 2023 17:00:08 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> User-agent: mu4e 1.8.13; emacs 29.0.60 From: Ruijie Yu To: 61326@debbugs.gnu.org Subject: Re: bug#61326: [DRAFT PATCH] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Thu, 09 Feb 2023 00:48:15 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: Eli Zaretskii , asjo@koldfront.dk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text edit= ors" writes: > Eli Zaretskii writes: > >>> Cc: 61326@debbugs.gnu.org >>> Date: Tue, 7 Feb 2023 09:31:11 +0800 >>> From: Ruijie Yu via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>> >>> Maybe, at least in the meantime, we change it such that all write opera= tions >>> for zip create files in temp, and move to / overwrite the original file= when >>> done? Although I don=E2=80=99t have a full understanding on how that wo= uld be done and >>> whether there are problems along with it. >> >> How about submitting a patch to do that, but only when the original >> file doesn't have an extension? > > Will do. Will report back in 2-3 days unless someone else gets to it > first. > > Best, > > > RY Here is a preliminary patch that contains some "REVIEW" comments where I need inputs. I have tested with the following recipe and things seem to work correctly: $ touch 1 2 && zip z 1 2 && mv z.zip z $ ls -l .... 1 .... 2 .... z $ src/emacs -Q RET ; open file "1" from within "z" archive s C-x C-s ; insert "s" and save file "1" C-x C-c ; exit $ ls -l # notice that no "z.zip" exists, and "z" is correctly updated .... 1 .... 2 .... z Patch based on 907fd1f7ff402f9d226ebb3b891ea5b54fac1d1c which is ~3 days old. I will amend the commit (and rebase if necessary) according to ML reviews and further progress. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-arc-mode.el-Work-around-zip-s-filename-limitati.patch >From bc086395929520a66eb928fd5d3baf6c9fa79bb5 Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Thu, 9 Feb 2023 00:45:19 +0800 Subject: [PATCH] lisp/arc-mode.el Work around zip's filename limitations on extension [DRAFT PATCH] Fixes 61326. The "zip" executable requires that the named archive must have an extension, else it attaches ".zip" to the supplied file name, causing incorrect behaviors. This patch looks for such scenarios and temporarily rename extension-less archives so that "zip" would function correctly. TODO: 1. Address all REVIEW points. 2. Make sure other write operations, in addition to zip-write-member, are fixed. 3. Tests? (I might need some pointers as to where existing tests are and how to write them.) --- lisp/arc-mode.el | 82 +++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6f3e922880d..ac8c7cefa89 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -1350,42 +1350,61 @@ archive-write-file-member (setq last-coding-system-used archive-member-coding-system)) t) -(defun archive-*-write-file-member (archive descr command) +;; REVIEW: is there a better name than AVOID-EXTLESS-P? +(defun archive-*-write-file-member (archive descr command + &optional avoid-extless-p) (let* ((archive (expand-file-name archive)) (ename (archive--file-desc-ext-file-name descr)) (tmpfile (expand-file-name ename archive-tmpdir)) (top (directory-file-name (file-name-as-directory archive-tmpdir))) (default-directory (file-name-as-directory top))) + ;; REVIEW: the diff here is because the previous code had TAB's + ;; (while assuming each TAB is 4 spaces), and my Emacs replaced + ;; them with spaces. What is the status quo on this kind of diff? + ;; I can remove them if we consider this change excessive and/or + ;; intrusive. (unwind-protect (progn (make-directory (file-name-directory tmpfile) t) - ;; If the member is itself an archive, write it without - ;; the dired-like listing we created. - (if (eq major-mode 'archive-mode) - (archive-write-file tmpfile) - (write-region nil nil tmpfile nil 'nomessage)) - ;; basic-save-buffer needs last-coding-system-used to have - ;; the value used to write the file, so save it before any - ;; further processing clobbers it (we restore it in - ;; archive-write-file-member, above). - (setq archive-member-coding-system last-coding-system-used) - (if (archive--file-desc-mode descr) - ;; Set the file modes, but make sure we can read it. - (set-file-modes tmpfile - (logior ?\400 (archive--file-desc-mode descr)))) - (setq ename - (encode-coding-string ename archive-file-name-coding-system)) + ;; If the member is itself an archive, write it without + ;; the dired-like listing we created. + (if (eq major-mode 'archive-mode) + (archive-write-file tmpfile) + (write-region nil nil tmpfile nil 'nomessage)) + ;; basic-save-buffer needs last-coding-system-used to have + ;; the value used to write the file, so save it before any + ;; further processing clobbers it (we restore it in + ;; archive-write-file-member, above). + (setq archive-member-coding-system last-coding-system-used) + (if (archive--file-desc-mode descr) + ;; Set the file modes, but make sure we can read it. + (set-file-modes tmpfile + (logior ?\400 (archive--file-desc-mode descr)))) + (setq ename + (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir)) + (safe-archive + (if avoid-extless-p + (make-temp-name + (expand-file-name (concat archive "_tmp."))) + archive)) + (maybe-rename + (lambda (newname) + (when avoid-extless-p + (with-current-buffer archive-superior-buffer + (rename-visited-file newname)))))) + ;; REVIEW: is `unwind-protect' necessary here? + (prog2 (funcall maybe-rename safe-archive) + (let ((exitcode + (apply #'call-process (car command) + nil nil nil + (append (cdr command) + (list safe-archive ename))))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" + exitcode))) + (funcall maybe-rename archive)))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -2048,12 +2067,19 @@ archive--file-desc-case-fiddled (not (eq (archive--file-desc-int-file-name fd) (archive--file-desc-ext-file-name fd)))) +(defun archive--file-name-zip-extless-p (fname) + ;; zip's rule: if the filename contains "." anywhere in the name + ;; (including obscure names like ".foo" and "bar."), then this + ;; filename is considered to have an extension. + (not (seq-contains-p (file-name-nondirectory fname) ?. #'eq))) + (defun archive-zip-write-file-member (archive descr) (archive-*-write-file-member archive descr (if (archive--file-desc-case-fiddled descr) - archive-zip-update-case archive-zip-update))) + archive-zip-update-case archive-zip-update) + (archive--file-name-zip-extless-p archive))) (defun archive-zip-chmod-entry (newmode files) (save-restriction -- 2.39.1 --=-=-= Content-Type: text/plain Best, RY --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 08 13:01:57 2023 Received: (at 61326) by debbugs.gnu.org; 8 Feb 2023 18:01:57 +0000 Received: from localhost ([127.0.0.1]:56610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPolY-0007TA-Sw for submit@debbugs.gnu.org; Wed, 08 Feb 2023 13:01:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPolW-0007Sw-19 for 61326@debbugs.gnu.org; Wed, 08 Feb 2023 13:01:56 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPolP-0006pL-8F; Wed, 08 Feb 2023 13:01:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BoxoKAZtJVM3JvLmf50OG8cK0pc1yENRZ1vYDDy0Rg8=; b=Dh5NG9mWb26U /n0chN0UmtzV8VDFs60RU6hID8I1MB1Gtwu8GguKMzvC6V1FD9H9UEFAx/+Ux7w814Xb4qaVLLVOF cOTN1j/GUWUm3Q4X72/6ZeQJrSogt+QKnkrGcd58gRJ9N1D/4TRXIb1Q7MgvyMdyFPn1VZ+BDC6TH lSbz2t9In8cQ8Cgcma9V4hHa3kaPabSj3kQSFJ89OKu036fRWyyVHycxwizKKh4dRhT27puvZ4yxa s0q0s+yyvN2APj91xjR6Nxe1p4A8UtM2YMznROlQED0azl7kDiulkKUPnc53NWToKPw8Hh4AKk4PK NJYDhdoAGxJJ3Ez+9vDeXA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPolO-0008TP-FC; Wed, 08 Feb 2023 13:01:46 -0500 Date: Wed, 08 Feb 2023 20:02:03 +0200 Message-Id: <83bkm4nihw.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Thu, 09 Feb 2023 00:48:15 +0800) Subject: Re: bug#61326: [DRAFT PATCH] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: Eli Zaretskii , asjo@koldfront.dk > Date: Thu, 09 Feb 2023 00:48:15 +0800 > > Here is a preliminary patch that contains some "REVIEW" comments where I > need inputs. Thanks, but could you perhaps post diffs disregarding the whitespace changes? That would make it easier to review the real changes. > -(defun archive-*-write-file-member (archive descr command) > +;; REVIEW: is there a better name than AVOID-EXTLESS-P? > +(defun archive-*-write-file-member (archive descr command > + &optional avoid-extless-p) ensure-extension? > + ;; REVIEW: the diff here is because the previous code had TAB's > + ;; (while assuming each TAB is 4 spaces), and my Emacs replaced > + ;; them with spaces. What is the status quo on this kind of diff? > + ;; I can remove them if we consider this change excessive and/or > + ;; intrusive. TABs in Emacs are by default 8 columns, not 4. It is OK to convert TABs to spaces when changing the code in Lisp, but please do that only for the last commit, to make the review process easier. For all the draft versions, please use "git diff" options that cause Git to ignore changes in whitespace. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 10 04:35:01 2023 Received: (at 61326) by debbugs.gnu.org; 10 Feb 2023 09:35:01 +0000 Received: from localhost ([127.0.0.1]:34353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQPo5-0003A8-3K for submit@debbugs.gnu.org; Fri, 10 Feb 2023 04:35:01 -0500 Received: from netyu.xyz ([152.44.41.246]:48376 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQPo2-00039y-HU for 61326@debbugs.gnu.org; Fri, 10 Feb 2023 04:35:00 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 14780955 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 10 Feb 2023 09:34:55 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> User-agent: mu4e 1.8.13; emacs 29.0.60 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v2] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Fri, 10 Feb 2023 16:40:25 +0800 In-reply-to: <83bkm4nihw.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Ruijie Yu >> Cc: Eli Zaretskii , asjo@koldfront.dk >> Date: Thu, 09 Feb 2023 00:48:15 +0800 >> >> Here is a preliminary patch that contains some "REVIEW" comments where I >> need inputs. > > Thanks, but could you perhaps post diffs disregarding the whitespace > changes? That would make it easier to review the real changes. Thanks, done. >> -(defun archive-*-write-file-member (archive descr command) >> +;; REVIEW: is there a better name than AVOID-EXTLESS-P? >> +(defun archive-*-write-file-member (archive descr command >> + &optional avoid-extless-p) > > ensure-extension? That sounds better, and I have renamed the variable in this iteration. >> + ;; REVIEW: the diff here is because the previous code had TAB's >> + ;; (while assuming each TAB is 4 spaces), and my Emacs replaced >> + ;; them with spaces. What is the status quo on this kind of diff? >> + ;; I can remove them if we consider this change excessive and/or >> + ;; intrusive. > > TABs in Emacs are by default 8 columns, not 4. > > It is OK to convert TABs to spaces when changing the code in Lisp, but > please do that only for the last commit, to make the review process > easier. For all the draft versions, please use "git diff" options > that cause Git to ignore changes in whitespace. > > Thanks. Thanks, I will keep that in mind. I have also made some rearrangements in the code to minimize delta. In addition, I fixed an issue from the first iteration: in the first iteration, the user would be prompted to revert buffer from disk if the rename was in action; in this iteration this should no longer be the case -- that is, the user should expect no difference between filenames with extensions and without. As pointed out in the commit message, two things remain: to ensure that all write operations to extensionless zip archives behave correctly, and to have some way to test that things continue to work in the future. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-arc-mode.el-Work-around-zip-s-filename-limitati.patch >From bc56c17082ea3ff2a76308f14310908853e3a2d1 Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Thu, 9 Feb 2023 00:45:19 +0800 Subject: [PATCH] lisp/arc-mode.el Work around zip's filename limitations on extension [DRAFT PATCH] Fixes 61326. The "zip" executable requires that the named archive must have an extension, else it attaches ".zip" to the supplied file name, causing incorrect behaviors. This patch looks for such scenarios and temporarily rename extension-less archives so that "zip" would function correctly. TODO: 1. Make sure other write operations, in addition to zip-write-member, are fixed. 2. Tests? (I might need some pointers as to where existing tests are and how to write them.) --- lisp/arc-mode.el | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6f3e922880d..cd7f4ca1134 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -1350,14 +1350,23 @@ archive-write-file-member (setq last-coding-system-used archive-member-coding-system)) t) -(defun archive-*-write-file-member (archive descr command) +(defun archive-*-write-file-member + (archive descr command &optional ensure-extension) (let* ((archive (expand-file-name archive)) + (real-archive archive) + (archive (if ensure-extension + (make-temp-name + (expand-file-name (concat archive "_tmp."))) + archive)) (ename (archive--file-desc-ext-file-name descr)) (tmpfile (expand-file-name ename archive-tmpdir)) (top (directory-file-name (file-name-as-directory archive-tmpdir))) (default-directory (file-name-as-directory top))) (unwind-protect - (progn + (cl-flet ((maybe-rename (newname) + (when ensure-extension + (with-current-buffer archive-superior-buffer + (rename-visited-file newname))))) (make-directory (file-name-directory tmpfile) t) ;; If the member is itself an archive, write it without ;; the dired-like listing we created. @@ -1376,16 +1385,20 @@ archive-*-write-file-member (setq ename (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil + (default-directory (file-name-as-directory archive-tmpdir))) + (unwind-protect + (progn + (maybe-rename archive) + (let ((exitcode + (apply #'call-process (car command) + nil nil nil (append (cdr command) (list archive ename))))) (or (zerop exitcode) (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (maybe-rename real-archive) + (with-current-buffer archive-superior-buffer + (revert-buffer nil t)))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -2048,12 +2061,19 @@ archive--file-desc-case-fiddled (not (eq (archive--file-desc-int-file-name fd) (archive--file-desc-ext-file-name fd)))) +(defun archive--file-name-zip-extless-p (fname) + ;; zip's rule: if the filename contains "." anywhere in the name + ;; (including obscure names like ".foo" and "bar."), then this + ;; filename is considered to have an extension. + (not (seq-contains-p (file-name-nondirectory fname) ?. #'eq))) + (defun archive-zip-write-file-member (archive descr) (archive-*-write-file-member archive descr (if (archive--file-desc-case-fiddled descr) - archive-zip-update-case archive-zip-update))) + archive-zip-update-case archive-zip-update) + (archive--file-name-zip-extless-p archive))) (defun archive-zip-chmod-entry (newmode files) (save-restriction -- 2.39.1 --=-=-= Content-Type: text/plain Best, RY --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 13 06:15:18 2023 Received: (at 61326) by debbugs.gnu.org; 13 Feb 2023 11:15:18 +0000 Received: from localhost ([127.0.0.1]:47791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRWnl-0003iY-H5 for submit@debbugs.gnu.org; Mon, 13 Feb 2023 06:15:17 -0500 Received: from netyu.xyz ([152.44.41.246]:59672 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRWnj-0003iP-Oh for 61326@debbugs.gnu.org; Mon, 13 Feb 2023 06:15:16 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 592b1d27 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 13 Feb 2023 11:15:14 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> User-agent: mu4e 1.8.13; emacs 29.0.60 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Mon, 13 Feb 2023 18:35:17 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain I believe the functionalities (both update and deletion) are done in this patch. I have not added any tests nor updates on documentation, as I am not sure what and where they should be. I have done some basic tests locally to confirm that it works: - update subfile in a zip archive named "z" - delete subfile in a zip archive named "z" - update subfile in a zip archive named "x.zip" - delete subfile in a zip archive named "x.zip" FTR, if this is of any importance: the filesystem containing the archives "z" and "x.zip" is btrfs, and /tmp is ext2 on zram. Not sure if any problems would arise in other filesystems / OSes -- hopefully someone else on those platforms can confirm that it works. Comments welcome. Particularly on my choices of naming. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-arc-mode.el-Work-around-zip-s-filename-limitati.patch >From 0766bec8071c7c793d6c81211577832d9a7a78f9 Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Thu, 9 Feb 2023 00:45:19 +0800 Subject: [PATCH] lisp/arc-mode.el Work around zip's filename limitations on extension [DRAFT PATCH] Fixes 61326. The "zip" executable requires that the named archive must have an extension, else it attaches ".zip" to the supplied file name, causing incorrect behaviors. This patch looks for such scenarios and temporarily rename extension-less archives so that "zip" would function correctly. Currently there are no tests. I might need some pointers as to where existing tests are and how to write them. --- lisp/arc-mode.el | 64 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6f3e922880d..875b3971086 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -645,6 +645,49 @@ archive-get-descr (if (not noerror) (error "Line does not describe a member of the archive"))))) ;; ------------------------------------------------------------------------- +;;; Section: Helper functions for requiring filename extensions + +(defun archive--act-files (command files) + (lambda (archive) + (apply #'call-process (car command) + nil nil nil (append (cdr command) (cons archive files))))) + +(defun archive--need-rename-p (&optional archive) + (let ((archive + (file-name-nondirectory (or archive buffer-file-name)))) + (cl-case archive-subtype + ((zip) (not (seq-contains-p archive ?. #'eq)))))) + +(defun archive--ensure-extension (archive ensure-extension) + (if ensure-extension + (make-temp-name (expand-file-name (concat archive "_tmp."))) + archive)) + +(defun archive--maybe-rename (newname need-rename-p) + ;; Operating with archive as current buffer, and protect + ;; `default-directory' from being modified in `rename-visited-file'. + (when need-rename-p + (let ((default-directory default-directory)) + (rename-visited-file newname)))) + +(defun archive--with-ensure-extension (archive proc-fn) + (let ((saved default-directory)) + (with-current-buffer (find-buffer-visiting archive) + (let ((ensure-extension (archive--need-rename-p)) + (default-directory saved)) + (unwind-protect + ;; Some archive programs (like zip) expect filenames to + ;; have an extension, so if necessary, temporarily rename + ;; an extensionless file for write accesses. + (let ((archive (archive--ensure-extension + archive ensure-extension))) + (archive--maybe-rename archive ensure-extension) + (let ((exitcode (funcall proc-fn archive))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (archive--maybe-rename archive ensure-extension) + (revert-buffer nil t))))))) +;; ------------------------------------------------------------------------- ;;; Section: the mode definition ;;;###autoload @@ -1376,16 +1419,9 @@ archive-*-write-file-member (setq ename (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir))) + (archive--with-ensure-extension + archive (archive--act-files command (list ename))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -1539,12 +1575,8 @@ archive-expunge (revert-buffer)))))) (defun archive-*-expunge (archive files command) - (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) (cons archive files)))) + (archive--with-ensure-extension + archive (archive--act-files command files))) (defun archive-rename-entry (newname) "Change the name associated with this entry in the archive file." -- 2.39.1 --=-=-= Content-Type: text/plain -- Best, RY --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 06:22:15 2023 Received: (at 61326) by debbugs.gnu.org; 4 Mar 2023 11:22:15 +0000 Received: from localhost ([127.0.0.1]:35300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYPxu-00007b-Pg for submit@debbugs.gnu.org; Sat, 04 Mar 2023 06:22:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYPxt-00007N-8d for 61326@debbugs.gnu.org; Sat, 04 Mar 2023 06:22:13 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYPxm-0003ER-CW; Sat, 04 Mar 2023 06:22:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=g8YFCJQbFbh+B7hrUFHE1ewgbeBDFBMsbYKNM1VPLss=; b=ZnVqg73X/Q06 xzhwZheEIFnfnkaqOpl17BK0HajoC5lllqXXsTMEi1a3r53YY0b9e3W0sw7hQKW5HbpWiu9XkDCjP kYMl2I+Uv0ISkrk4U8pyhIQ6KjE971yTv6Xct9TXKKR1lmdR75i52zpHW56b19ttN+vskD6LRdgqG RUYKrDU6FAkUKwR0Al086oQbatx1G/S8vtYO4gYLVI0Rm99/Spqs3dr2tVvHlyadXlLU8GHQjHbLt ZMT6ocaXtSv4kKK2ov4i3TRzv2OAaxECD0txUILivs9nb6ybLx1nZzcdvsVSs67HfacNQa0MdXny1 cirZmZ+2U/IEUXkADrIfXw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYPxl-0001bg-BZ; Sat, 04 Mar 2023 06:22:05 -0500 Date: Sat, 04 Mar 2023 13:21:52 +0200 Message-Id: <83zg8sahin.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Mon, 13 Feb 2023 18:35:17 +0800) Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Mon, 13 Feb 2023 18:35:17 +0800 > > I believe the functionalities (both update and deletion) are done in > this patch. I have not added any tests nor updates on documentation, as > I am not sure what and where they should be. Thanks. I don't think we need any updates to the documentation, as this just fixes a subtle bug. It would be nice to have a few tests, though. Please add them to test/lisp/arc-mode-tests.el. I see that you don't have a copyright assignment on file, so would you like me to send you the form to fill, which will start the legal paperwork of assigning the copyright to the FSF? Once that is completed, we can install these changes. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 09:57:30 2023 Received: (at 61326) by debbugs.gnu.org; 4 Mar 2023 14:57:30 +0000 Received: from localhost ([127.0.0.1]:37421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYTKE-0002uH-4I for submit@debbugs.gnu.org; Sat, 04 Mar 2023 09:57:30 -0500 Received: from netyu.xyz ([152.44.41.246]:41488 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYTKA-0002u6-2U for 61326@debbugs.gnu.org; Sat, 04 Mar 2023 09:57:28 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id cc5c84d2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 4 Mar 2023 14:57:24 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Sat, 04 Mar 2023 22:56:21 +0800 In-reply-to: <83zg8sahin.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Eli Zaretskii writes: >> From: Ruijie Yu >> Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org >> Date: Mon, 13 Feb 2023 18:35:17 +0800 >> >> I believe the functionalities (both update and deletion) are done in >> this patch. I have not added any tests nor updates on documentation, as >> I am not sure what and where they should be. > > Thanks. > > I don't think we need any updates to the documentation, as this just > fixes a subtle bug. It would be nice to have a few tests, though. > Please add them to test/lisp/arc-mode-tests.el. Sure, will do in a few days. > I see that you don't have a copyright assignment on file, so would you > like me to send you the form to fill, which will start the legal > paperwork of assigning the copyright to the FSF? Once that is > completed, we can install these changes. > > Thanks. Please do, thanks. -- Best, RY From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 10:12:59 2023 Received: (at 61326) by debbugs.gnu.org; 4 Mar 2023 15:12:59 +0000 Received: from localhost ([127.0.0.1]:37451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYTZD-0003JJ-7O for submit@debbugs.gnu.org; Sat, 04 Mar 2023 10:12:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYTZA-0003J5-Ut for 61326@debbugs.gnu.org; Sat, 04 Mar 2023 10:12:57 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYTZ4-0006K4-Dm; Sat, 04 Mar 2023 10:12:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aQhm00sJyvSyJrSOHH6dWzg1JYvGjydwnbxy0zlKV2g=; b=EG7159XVPzWG tSZo5iVd7e8LwRPa3B890ZDIwcf0CM6GiqplG5cs1sz6T7b+/td0uajfEoexGtmAERrg/9PBPEOWw XKaT7F1dI6SyRwzpNJ7A1QyEELPnRQkKinofy7BXdWJq2407xMYtiCCl0M9EmZbMrR3l6s3XMpe7w RsX0q4lr54HW+acGwomvmTGOk3g+0BxhBpidzjMjsheoWLyoHFiP8FiBbQ+nElmSnbTBN1hu5A57W i/DEgN5qoGTkGEChqnbgvhvYqPUXPeaJkogIjp0PXSgqItQh9vauul99e+B2Lglil9vAna+lsIFFM wHR5NOU4GHdqC2IBAHdCdA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYTZ2-00071k-8Y; Sat, 04 Mar 2023 10:12:50 -0500 Date: Sat, 04 Mar 2023 17:12:36 +0200 Message-Id: <83jzzwa6u3.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Sat, 04 Mar 2023 22:56:21 +0800) Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Sat, 04 Mar 2023 22:56:21 +0800 > > > I see that you don't have a copyright assignment on file, so would you > > like me to send you the form to fill, which will start the legal > > paperwork of assigning the copyright to the FSF? Once that is > > completed, we can install these changes. > > > > Thanks. > > Please do, thanks. Form sent off-list. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 10:38:50 2023 Received: (at 61326) by debbugs.gnu.org; 5 Mar 2023 15:38:50 +0000 Received: from localhost ([127.0.0.1]:40345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYqRl-00045z-Si for submit@debbugs.gnu.org; Sun, 05 Mar 2023 10:38:50 -0500 Received: from netyu.xyz ([152.44.41.246]:42216 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYqRj-00045r-KJ for 61326@debbugs.gnu.org; Sun, 05 Mar 2023 10:38:48 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 9a14214a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 5 Mar 2023 15:38:46 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Sun, 05 Mar 2023 23:23:59 +0800 In-reply-to: <83jzzwa6u3.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Eli Zaretskii writes: >> From: Ruijie Yu >> Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org >> Date: Sat, 04 Mar 2023 22:56:21 +0800 >> >> > I see that you don't have a copyright assignment on file, so would you >> > like me to send you the form to fill, which will start the legal >> > paperwork of assigning the copyright to the FSF? Once that is >> > completed, we can install these changes. >> > >> > Thanks. >> >> Please do, thanks. > > Form sent off-list. Response sent to assign@gnu, thanks. By the way, while writing tests, I see a need to modify `archive-expunge' to accept an additional optional argument FORCE acting as the prefix argument. I suppose if this is favored, I should probably say something in the etc/NEWS file (as well as the docstring, and maybe an info page somewhere)? FTR, previously prefix arguments are ignored for `archive-expunge'. The reason for the need of a FORCE argument is so that I want to ensure that file contents are correct after deleting a member using archive-mode functionalities without getting prompted for confirmation. However, `archive-expunge' ATM requires a user prompt via its baked-in `yes-or-no-p' call. An alternative to the above is to move the meat of said function into a new internal helper function which simply skips over prompting the user. This would keep the `archive-expunge' API untouched. A new draft iteration should be here in a few days, with the question(s) above answered. Thanks. -- Best, RY From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 10:52:32 2023 Received: (at 61326) by debbugs.gnu.org; 5 Mar 2023 15:52:32 +0000 Received: from localhost ([127.0.0.1]:40354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYqf1-0004Tp-Sg for submit@debbugs.gnu.org; Sun, 05 Mar 2023 10:52:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYqez-0004TY-As for 61326@debbugs.gnu.org; Sun, 05 Mar 2023 10:52:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYqeq-0001GB-Kl; Sun, 05 Mar 2023 10:52:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=qZxVCw7PHA6L6x3zm0ihCh2x2pzQTqr8mZdo7Z+w4Is=; b=aHF8aGn6Aysl 3bavwbLlu74l1P9BmytoX9FwvTHBkA3ZFw5KmLMRY/3TK1vYYwSScACXTxyLZt0Rg9nYbUHiIjdgj 3z8lKrVkUFs6jgSxEVGz8qBxeQ3D4g7sIgQ8kzOQROqk00QKL74BnDESzNTc0Ongk+DVBENqKSObU pMUOI94dvogNzdeuxNBisfA76h/WjXhaune5iYIVnBoDEwAdgm0/52Ud1gK56IuTe1z+hoV6JhDxm IWgOW3+m7DwVzM5C9a9gS/laM4M30pxzkCwofmjhh5Gjp4nb66VSUC4otXs1hU6ilIhY50FlgiX0L J0i9ebAiqDtzDqy2vPXQIQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYqeq-0004Jp-19; Sun, 05 Mar 2023 10:52:20 -0500 Date: Sun, 05 Mar 2023 17:52:11 +0200 Message-Id: <83h6uz8ac4.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Sun, 05 Mar 2023 23:23:59 +0800) Subject: Re: bug#61326: [DRAFT PATCH v3] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Sun, 05 Mar 2023 23:23:59 +0800 > > > Form sent off-list. > > Response sent to assign@gnu, thanks. Thanks. > By the way, while writing tests, I see a need to modify > `archive-expunge' to accept an additional optional argument FORCE acting > as the prefix argument. I suppose if this is favored, I should probably > say something in the etc/NEWS file (as well as the docstring, and maybe > an info page somewhere)? FTR, previously prefix arguments are ignored > for `archive-expunge'. > > The reason for the need of a FORCE argument is so that I want to ensure > that file contents are correct after deleting a member using > archive-mode functionalities without getting prompted for confirmation. > However, `archive-expunge' ATM requires a user prompt via its baked-in > `yes-or-no-p' call. This is a separate feature. In Dired-like user interfaces, we always ask the user for confirmation before deleting items; 'C-u x' in Dired AFAIR just avoids messages when no files are flagged for deletion, but doesn't prevent the confirmation. So if we are going to treat archive-expunge differently, I think we'll need a very good reason. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 23:47:12 2023 Received: (at 61326) by debbugs.gnu.org; 6 Mar 2023 04:47:12 +0000 Received: from localhost ([127.0.0.1]:41088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZ2kh-0006HR-7L for submit@debbugs.gnu.org; Sun, 05 Mar 2023 23:47:12 -0500 Received: from netyu.xyz ([152.44.41.246]:40566 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZ2ke-0006HI-Vd for 61326@debbugs.gnu.org; Sun, 05 Mar 2023 23:47:09 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 7b060f83 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 6 Mar 2023 04:47:07 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v4] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Mon, 06 Mar 2023 12:05:23 +0800 In-reply-to: <83h6uz8ac4.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > [...] >> By the way, while writing tests, I see a need to modify >> `archive-expunge' to accept an additional optional argument FORCE acting >> as the prefix argument. I suppose if this is favored, I should probably >> say something in the etc/NEWS file (as well as the docstring, and maybe >> an info page somewhere)? FTR, previously prefix arguments are ignored >> for `archive-expunge'. >> >> The reason for the need of a FORCE argument is so that I want to ensure >> that file contents are correct after deleting a member using >> archive-mode functionalities without getting prompted for confirmation. >> However, `archive-expunge' ATM requires a user prompt via its baked-in >> `yes-or-no-p' call. > > This is a separate feature. [...] So if we are going to treat > archive-expunge differently, I think we'll need a very good reason. I see, thanks for explaining. In the attached patches I followed the alternative approach which I described in my previous message: take the meat of the function into a separate helper function, and use that in the `archive-expunge' function and in my new test. If someone else has a good reason for using prefix argument to "force" deletion, they can ask in a new bug report. Another question regarding this change: when moving `archive-expunge' into `archive--expunge-maybe-force', I rewrote the portion that populates the list of files that are marked for deletion. Originally it was using `while' + `setq', and seeing that arc-mode.el already requires `cl-lib', I turned it into a `cl-do' construct. Do people have a preference or does it matter? I can change this portion back to the original if there's objection. To ease the review process, I have broken down the changes into two patch files. The first one is merely to take out `archive-expunge' into helper function `archive--expunge-maybe-force', and the second one is everything else, including the tests. The goal for the final patch is to combine these two into one, to make necessary indentation changes around the portions that I touched, and to only use the commit message of the second patch _verbatim_ -- so please verify that this commit message is satisfactory in emacs.git, thanks. FTR, I ran `make check' and ensured that my changes didn't introduce regressions, while also noticed that some tests in vc and eglot fail both before and after my changes. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-REVIEW-pull-out-content-of-arc-expunge-for-nonintera.patch >From 3b9196a095c6843b7c87b867a82fa7a2d930bb0b Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Mon, 6 Mar 2023 11:03:32 +0800 Subject: [PATCH 1/2] REVIEW: pull out content of arc-expunge for noninteractive deletion --- lisp/arc-mode.el | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 6f3e922880d..f8d7182597b 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -1508,23 +1508,26 @@ archive-chgrp-entry (archive-resummarize)) (error "Setting group is not supported for this archive type")))) -(defun archive-expunge () - "Do the flagged deletions." - (interactive) - (let (files) +(defun archive--expunge-maybe-force (force) + (let ((files (save-excursion (goto-char archive-file-list-start) - (while (< (point) archive-file-list-end) - (if (= (following-char) ?D) - (setq files (cons (archive--file-desc-ext-file-name + (cl-do ((files + nil + (prog1 + (if (eq (following-char) ?D) + (cons (archive--file-desc-ext-file-name (archive-get-descr)) - files))) - (forward-line 1))) - (setq files (nreverse files)) + files) + files) + (forward-line 1)))) + ((>= (point) archive-file-list-end) + (nreverse files)))))) (and files (or (not archive-read-only) (error "Archive is read-only")) - (or (yes-or-no-p (format "Really delete %d member%s? " + (or force + (yes-or-no-p (format "Really delete %d member%s? " (length files) (if (null (cdr files)) "" "s"))) (error "Operation aborted")) @@ -1538,6 +1541,11 @@ archive-expunge (archive-resummarize) (revert-buffer)))))) +(defun archive-expunge () + "Do the flagged deletions." + (interactive) + (archive--expunge-maybe-force nil)) + (defun archive-*-expunge (archive files command) (apply #'call-process (car command) -- 2.39.2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Handle-modifications-on-extensionless-zips-correctly.patch >From ba5825f9bdd323a460f4a327670d99ed34df3128 Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Thu, 9 Feb 2023 00:45:19 +0800 Subject: [PATCH 2/2] Handle modifications on extensionless zips correctly (bug#61326) * lisp/arc-mode.el: Refactor to handle extless zips * test/lisp/arc-mode-tests.el: New test for correctly handling extless zips --- lisp/arc-mode.el | 64 ++++++++++++++++++++++++++--------- test/lisp/arc-mode-tests.el | 67 +++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 16 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index f8d7182597b..47611f13b6f 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -645,6 +645,49 @@ archive-get-descr (if (not noerror) (error "Line does not describe a member of the archive"))))) ;; ------------------------------------------------------------------------- +;;; Section: Helper functions for requiring filename extensions + +(defun archive--act-files (command files) + (lambda (archive) + (apply #'call-process (car command) + nil nil nil (append (cdr command) (cons archive files))))) + +(defun archive--need-rename-p (&optional archive) + (let ((archive + (file-name-nondirectory (or archive buffer-file-name)))) + (cl-case archive-subtype + ((zip) (not (seq-contains-p archive ?. #'eq)))))) + +(defun archive--ensure-extension (archive ensure-extension) + (if ensure-extension + (make-temp-name (expand-file-name (concat archive "_tmp."))) + archive)) + +(defun archive--maybe-rename (newname need-rename-p) + ;; Operating with archive as current buffer, and protect + ;; `default-directory' from being modified in `rename-visited-file'. + (when need-rename-p + (let ((default-directory default-directory)) + (rename-visited-file newname)))) + +(defun archive--with-ensure-extension (archive proc-fn) + (let ((saved default-directory)) + (with-current-buffer (find-buffer-visiting archive) + (let ((ensure-extension (archive--need-rename-p)) + (default-directory saved)) + (unwind-protect + ;; Some archive programs (like zip) expect filenames to + ;; have an extension, so if necessary, temporarily rename + ;; an extensionless file for write accesses. + (let ((archive (archive--ensure-extension + archive ensure-extension))) + (archive--maybe-rename archive ensure-extension) + (let ((exitcode (funcall proc-fn archive))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (archive--maybe-rename archive ensure-extension) + (revert-buffer nil t))))))) +;; ------------------------------------------------------------------------- ;;; Section: the mode definition ;;;###autoload @@ -1376,16 +1419,9 @@ archive-*-write-file-member (setq ename (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir))) + (archive--with-ensure-extension + archive (archive--act-files command (list ename))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -1547,12 +1583,8 @@ archive-expunge (archive--expunge-maybe-force nil)) (defun archive-*-expunge (archive files command) - (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) (cons archive files)))) + (archive--with-ensure-extension + archive (archive--act-files command files))) (defun archive-rename-entry (newname) "Change the name associated with this entry in the archive file." diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index 32bce1b71bd..ae44ef3439c 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -46,6 +46,73 @@ arc-mode-test-zip-extract-gz (when (buffer-live-p zip-buffer) (kill-buffer zip-buffer)) (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer))))) +(ert-deftest arc-mode-test-zip-ensure-ext () + ;; Bug#61326 + (skip-unless (executable-find "zip")) + (let* ((default-directory arc-mode-tests-data-directory) + (base-zip-1 "base-1.zip") + (base-zip-2 "base-2.zip") + (content-1 '("1" "2")) + (content-2 '("3" "4")) + (make-file (lambda (name) + (with-temp-buffer + (insert name) + (write-file name)))) + (make-zip + (lambda (zip files) + (delete-file zip nil) + (funcall (archive--act-files '("zip") files) zip))) + (update-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + (save-excursion + (goto-char archive-file-list-start) + (save-current-buffer + (archive-extract) + (save-excursion + (goto-char (point-max)) + (insert ?a) + (save-buffer)) + (kill-buffer (current-buffer))) + (archive-extract) + ;; [2] must be ?a; [3] must be (eobp) + (should (eq (char-after 2) ?a)) + (should (eq (point-max) 3)))))) + (delete-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + ;; mark delete and expunge first entry + (save-excursion + (goto-char archive-file-list-start) + (should (length= archive-files 2)) + (archive-flag-deleted 1) + (archive--expunge-maybe-force t) + (should (length= archive-files 1)))))) + (test-modify + (lambda (zip mod-fn) + (let ((zip-base (concat zip ".zip")) + (tag (gensym))) + (copy-file base-zip-1 zip t) + (copy-file base-zip-2 zip-base t) + (file-has-changed-p zip tag) + (file-has-changed-p zip-base tag) + (funcall mod-fn zip) + (should-not (file-has-changed-p zip-base tag)) + (should (file-has-changed-p zip tag)))))) + ;; setup: make two zip files with different contents + (mapc make-file (append content-1 content-2)) + (mapc (lambda (args) (apply make-zip args)) + (list (list base-zip-1 content-1) + (list base-zip-2 content-2))) + ;; test 1: with "test-update" and "test-update.zip", update + ;; "test-update": (1) ensure only "test-update" is modified, (2) + ;; ensure the contents of the new member is expected. + (funcall test-modify "test-update" update-fn) + ;; test 2: with "test-delete" and "test-delete.zip", delete entry + ;; from "test-delete": (1) ensure only "test-delete" is modified, + ;; (2) ensure the file list is reduced as expected. + (funcall test-modify "test-delete" delete-fn))) + (provide 'arc-mode-tests) ;;; arc-mode-tests.el ends here -- 2.39.2 --=-=-= Content-Type: text/plain -- Best, RY --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 11 03:55:00 2023 Received: (at 61326) by debbugs.gnu.org; 11 Mar 2023 08:55:00 +0000 Received: from localhost ([127.0.0.1]:56523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pav0F-0006i6-TQ for submit@debbugs.gnu.org; Sat, 11 Mar 2023 03:55:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pav0E-0006ht-Ks for 61326@debbugs.gnu.org; Sat, 11 Mar 2023 03:54:59 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pav07-0005yI-T6; Sat, 11 Mar 2023 03:54:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=SnAHXJK1s9ZPdwqfKyr6bjMqCQQs44KQivMLFImc2wE=; b=iiGDJqokA2MQ WoslRzpkgaGHGJKSRBq2zyP5d/kWn56D9gUpTNfDGlTaK+pSQbwVzkfUkw1d7jb4/U+5FwyLnhR9p 6Ok5gbzuqFao5IAOjk70uEEZcqaoeqgxyuwZZG4KqPsozgaq6q6ohKyBUjmojDPFmM5h8TE54Qun0 Q+t9hWBnpRnYHFS8LSBaNLtk8m3bahI0pKDhzdCYOcC+WRwh1OU1jf959sskEfgOQFlubRuEoDE62 LoMjAjXGKp+HtpiCUtcuZdVnw5wo8ldjwkrP9ZV2vRrSguYQ2UBknRSYx0irbeQ4xGnsXlkAyWR0y VmKRMpEUCABSp8niO/CQgQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pav07-0002P0-9E; Sat, 11 Mar 2023 03:54:51 -0500 Date: Sat, 11 Mar 2023 10:54:36 +0200 Message-Id: <834jqry8fn.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Mon, 06 Mar 2023 12:05:23 +0800) Subject: Re: bug#61326: [DRAFT PATCH v4] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Mon, 06 Mar 2023 12:05:23 +0800 > > In the attached patches I followed the alternative approach which I > described in my previous message: take the meat of the function into a > separate helper function, and use that in the `archive-expunge' function > and in my new test. If someone else has a good reason for using prefix > argument to "force" deletion, they can ask in a new bug report. > > Another question regarding this change: when moving `archive-expunge' > into `archive--expunge-maybe-force', I rewrote the portion that > populates the list of files that are marked for deletion. Originally it > was using `while' + `setq', and seeing that arc-mode.el already requires > `cl-lib', I turned it into a `cl-do' construct. Do people have a > preference or does it matter? I can change this portion back to the > original if there's objection. I don't object in principle, but in this case it looks like the implementation based on cl-do needs much more complex code than the original? If so, I'd prefer the original, simpler and easier-to-understand code. > To ease the review process, I have broken down the changes into two > patch files. The first one is merely to take out `archive-expunge' into > helper function `archive--expunge-maybe-force', and the second one is > everything else, including the tests. > > The goal for the final patch is to combine these two into one, to make > necessary indentation changes around the portions that I touched, and to > only use the commit message of the second patch _verbatim_ -- so please > verify that this commit message is satisfactory in emacs.git, thanks. The commit log message is not detailed enough: it doesn't mention the functions you modify. Please see the conventions we follow for log messages described in CONTRIBUTE, which also mentions useful Emacs functions which will help you format the log message according to our conventions. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 11 04:04:41 2023 Received: (at 61326) by debbugs.gnu.org; 11 Mar 2023 09:04:41 +0000 Received: from localhost ([127.0.0.1]:56549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pav9d-0006zh-Eg for submit@debbugs.gnu.org; Sat, 11 Mar 2023 04:04:41 -0500 Received: from netyu.xyz ([152.44.41.246]:50144 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pav9c-0006zX-CC for 61326@debbugs.gnu.org; Sat, 11 Mar 2023 04:04:40 -0500 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 2f629992 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 11 Mar 2023 09:04:38 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [DRAFT PATCH v4] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Sat, 11 Mar 2023 16:57:08 +0800 In-reply-to: <834jqry8fn.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Eli Zaretskii writes: >> [...] I turned it into a `cl-do' construct. [...] > > I don't object in principle, but in this case it looks like the > implementation based on cl-do needs much more complex code than the > original? If so, I'd prefer the original, simpler and > easier-to-understand code. It's more that everything is buried under the let expression, so it _looks_ more complex. But I do agree that this change might introduce unnecessary cognative load for maintainers and I will revert that change in my next iteration. > The commit log message is not detailed enough: it doesn't mention the > functions you modify. Please see the conventions we follow for log > messages described in CONTRIBUTE, which also mentions useful Emacs > functions which will help you format the log message according to our > conventions. > > Thanks. Thank you for the review. I will take a closer look at etc/CONTRIBUTE -- apparently I didn't read it in enough detail. I will report back within the next few days. -- Best, RY From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 16 23:52:08 2023 Received: (at 61326) by debbugs.gnu.org; 17 Mar 2023 03:52:08 +0000 Received: from localhost ([127.0.0.1]:43423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pd18R-0008Rr-NL for submit@debbugs.gnu.org; Thu, 16 Mar 2023 23:52:08 -0400 Received: from netyu.xyz ([152.44.41.246]:58110 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pd18J-0008RJ-NX for 61326@debbugs.gnu.org; Thu, 16 Mar 2023 23:52:05 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id a6821310 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 17 Mar 2023 03:51:58 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Ruijie Yu To: Ruijie Yu Subject: Re: bug#61326: [DRAFT PATCH v5] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Fri, 17 Mar 2023 11:19:39 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: Eli Zaretskii , asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > [...] > Thank you for the review. I will take a closer look at etc/CONTRIBUTE > -- apparently I didn't read it in enough detail. I will report back > within the next few days. New iteration. As mentioned from my last message, I have reverted the part where I tried to rewrite part of `archive-expunge' using `cl-do'. Test cases for arc-mode still pass: $ make -C test arc-mode-tests Note that I mentioned the new internal helper functions in the commit message, as I saw Jo=C3=A3o too has mentioned updates to internal functions in 9d3fdf7e0. If mentioning the internal functions turns out to be unnecessary, simply removing these lines from the patch should suffice. Otherwise, if there's something else that looks wrong in the commit message, please let me know. FTR, I am still waiting for the counter signature from FSF before this can be included into emacs.git. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-modifications-on-extensionless-zips-correctly.patch >From f3b29596ef3ddfa63d6cd65fcbf8a5210e99989f Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Mon, 6 Mar 2023 11:03:32 +0800 Subject: [PATCH] Handle modifications on extensionless zips correctly (Bug#61326) * lisp/arc-mode.el (archive-*-write-file-member) (archive-*-expunge): Refactor to correctly modify extensionless zip archives. (archive-expunge): Move implementation to a separate helper function to facilitate testing. (archive--act-files): New helper function to wrap around `call-process' calls. (archive--need-rename-p): New helper function to check whether a temporary rename is necessary. (archive--ensure-extension) (archive--maybe-rename): New helper functions to rename archive if the caller deems it necessary. (archive--with-ensure-extension): New helper function to handle writing an archive while ensuring extensionless archives work correctly by temporarily renaming them. * test/lisp/arc-mode-tests.el (arc-mode-test-zip-ensure-ext): New regression test for bug#61326. --- lisp/arc-mode.el | 76 +++++++++++++++++++++++++++---------- test/lisp/arc-mode-tests.el | 67 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 20 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5e696c091b2..0a971799746 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -645,6 +645,49 @@ archive-get-descr (if (not noerror) (error "Line does not describe a member of the archive"))))) ;; ------------------------------------------------------------------------- +;;; Section: Helper functions for requiring filename extensions + +(defun archive--act-files (command files) + (lambda (archive) + (apply #'call-process (car command) + nil nil nil (append (cdr command) (cons archive files))))) + +(defun archive--need-rename-p (&optional archive) + (let ((archive + (file-name-nondirectory (or archive buffer-file-name)))) + (cl-case archive-subtype + ((zip) (not (seq-contains-p archive ?. #'eq)))))) + +(defun archive--ensure-extension (archive ensure-extension) + (if ensure-extension + (make-temp-name (expand-file-name (concat archive "_tmp."))) + archive)) + +(defun archive--maybe-rename (newname need-rename-p) + ;; Operating with archive as current buffer, and protect + ;; `default-directory' from being modified in `rename-visited-file'. + (when need-rename-p + (let ((default-directory default-directory)) + (rename-visited-file newname)))) + +(defun archive--with-ensure-extension (archive proc-fn) + (let ((saved default-directory)) + (with-current-buffer (find-buffer-visiting archive) + (let ((ensure-extension (archive--need-rename-p)) + (default-directory saved)) + (unwind-protect + ;; Some archive programs (like zip) expect filenames to + ;; have an extension, so if necessary, temporarily rename + ;; an extensionless file for write accesses. + (let ((archive (archive--ensure-extension + archive ensure-extension))) + (archive--maybe-rename archive ensure-extension) + (let ((exitcode (funcall proc-fn archive))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (archive--maybe-rename archive ensure-extension) + (revert-buffer nil t))))))) +;; ------------------------------------------------------------------------- ;;; Section: the mode definition ;;;###autoload @@ -1378,16 +1421,9 @@ archive-*-write-file-member (setq ename (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir))) + (archive--with-ensure-extension + archive (archive--act-files command (list ename))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -1510,9 +1546,7 @@ archive-chgrp-entry (archive-resummarize)) (error "Setting group is not supported for this archive type")))) -(defun archive-expunge () - "Do the flagged deletions." - (interactive) +(defun archive--expunge-maybe-force (force) (let (files) (save-excursion (goto-char archive-file-list-start) @@ -1526,7 +1560,8 @@ archive-expunge (and files (or (not archive-read-only) (error "Archive is read-only")) - (or (yes-or-no-p (format "Really delete %d member%s? " + (or force + (yes-or-no-p (format "Really delete %d member%s? " (length files) (if (null (cdr files)) "" "s"))) (error "Operation aborted")) @@ -1540,13 +1575,14 @@ archive-expunge (archive-resummarize) (revert-buffer)))))) +(defun archive-expunge () + "Do the flagged deletions." + (interactive) + (archive--expunge-maybe-force nil)) + (defun archive-*-expunge (archive files command) - (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) (cons archive files)))) + (archive--with-ensure-extension + archive (archive--act-files command files))) (defun archive-rename-entry (newname) "Change the name associated with this entry in the archive file." diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index 32bce1b71bd..ae44ef3439c 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -46,6 +46,73 @@ arc-mode-test-zip-extract-gz (when (buffer-live-p zip-buffer) (kill-buffer zip-buffer)) (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer))))) +(ert-deftest arc-mode-test-zip-ensure-ext () + ;; Bug#61326 + (skip-unless (executable-find "zip")) + (let* ((default-directory arc-mode-tests-data-directory) + (base-zip-1 "base-1.zip") + (base-zip-2 "base-2.zip") + (content-1 '("1" "2")) + (content-2 '("3" "4")) + (make-file (lambda (name) + (with-temp-buffer + (insert name) + (write-file name)))) + (make-zip + (lambda (zip files) + (delete-file zip nil) + (funcall (archive--act-files '("zip") files) zip))) + (update-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + (save-excursion + (goto-char archive-file-list-start) + (save-current-buffer + (archive-extract) + (save-excursion + (goto-char (point-max)) + (insert ?a) + (save-buffer)) + (kill-buffer (current-buffer))) + (archive-extract) + ;; [2] must be ?a; [3] must be (eobp) + (should (eq (char-after 2) ?a)) + (should (eq (point-max) 3)))))) + (delete-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + ;; mark delete and expunge first entry + (save-excursion + (goto-char archive-file-list-start) + (should (length= archive-files 2)) + (archive-flag-deleted 1) + (archive--expunge-maybe-force t) + (should (length= archive-files 1)))))) + (test-modify + (lambda (zip mod-fn) + (let ((zip-base (concat zip ".zip")) + (tag (gensym))) + (copy-file base-zip-1 zip t) + (copy-file base-zip-2 zip-base t) + (file-has-changed-p zip tag) + (file-has-changed-p zip-base tag) + (funcall mod-fn zip) + (should-not (file-has-changed-p zip-base tag)) + (should (file-has-changed-p zip tag)))))) + ;; setup: make two zip files with different contents + (mapc make-file (append content-1 content-2)) + (mapc (lambda (args) (apply make-zip args)) + (list (list base-zip-1 content-1) + (list base-zip-2 content-2))) + ;; test 1: with "test-update" and "test-update.zip", update + ;; "test-update": (1) ensure only "test-update" is modified, (2) + ;; ensure the contents of the new member is expected. + (funcall test-modify "test-update" update-fn) + ;; test 2: with "test-delete" and "test-delete.zip", delete entry + ;; from "test-delete": (1) ensure only "test-delete" is modified, + ;; (2) ensure the file list is reduced as expected. + (funcall test-modify "test-delete" delete-fn))) + (provide 'arc-mode-tests) ;;; arc-mode-tests.el ends here -- 2.39.2 --=-=-= Content-Type: text/plain -- Best, RY --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 17 04:51:24 2023 Received: (at 61326) by debbugs.gnu.org; 17 Apr 2023 08:51:24 +0000 Received: from localhost ([127.0.0.1]:53155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1poKa4-0007ZQ-1F for submit@debbugs.gnu.org; Mon, 17 Apr 2023 04:51:24 -0400 Received: from netyu.xyz ([152.44.41.246]:59836 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1poKa2-0007ZG-Oh for 61326@debbugs.gnu.org; Mon, 17 Apr 2023 04:51:23 -0400 Received: from fw.net.yu.netyu.xyz ( [14.26.19.253]) by netyu.xyz (OpenSMTPD) with ESMTPSA id fd5508e2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 17 Apr 2023 08:51:21 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> User-agent: mu4e 1.9.22; emacs 30.0.50 From: Ruijie Yu To: Ruijie Yu Subject: Re: bug#61326: [PATCH v5] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Mon, 17 Apr 2023 16:48:13 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61326 Cc: Eli Zaretskii , asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Ruijie Yu writes: > New iteration. As mentioned from my last message, I have reverted the > part where I tried to rewrite part of `archive-expunge' using `cl-do'. > > FTR, I am still waiting for the counter signature from FSF before this > can be included into emacs.git. > > [2. text/x-patch; 0001-Handle-modifications-on-extensionless-zips-correctly.patch]... Ping? Removing the "DRAFT" from subject, because I think it is probably complete. Also, my FSF process should now be complete. -- Best, RY From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 03:47:51 2023 Received: (at 61326) by debbugs.gnu.org; 20 Apr 2023 07:47:51 +0000 Received: from localhost ([127.0.0.1]:36451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppP1D-0000jz-3z for submit@debbugs.gnu.org; Thu, 20 Apr 2023 03:47:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppP18-0000iq-Mm for 61326@debbugs.gnu.org; Thu, 20 Apr 2023 03:47:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppP11-0003e1-3D; Thu, 20 Apr 2023 03:47:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=vZz9fSDzMvBTAT4fRdkp/r5GMLYSD0AZcJLn5h+SlW4=; b=VBYg38FrCHqh Pzc85hmUp5qDGIFcySuU9MtLoxoYXX2LZCutqkl33ElfA1hPVKkInrb/r0FnSIw0z1spPEEFGq1P3 mHyuLuSsB/zyoyNkjDfA7a+1+Pd47sry8eJjmJp48dUlCn/2jddGMaNrCABaSMKackrvfrQ6pHYUa OW71Lwq3O7xidUW8Ix4ObCQ6aIQZBjASJalceKkDt01iiWvDV06HZfF/pLz6Ypk2c1qRlAFz2dMul yABka9b32WRLfq9x86/b61UsQg8Rste3gEnRBpYlXFBrwCSe2xLlxpk5YN3e9YV0pCWtC1WXF5lmt GK5/dwoA4UJOXTN6/WdQGg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppP10-0002I9-G1; Thu, 20 Apr 2023 03:47:38 -0400 Date: Thu, 20 Apr 2023 10:47:50 +0300 Message-Id: <835y9r6lll.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Mon, 17 Apr 2023 16:48:13 +0800) Subject: Re: bug#61326: [PATCH v5] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326 Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: Eli Zaretskii , asjo@koldfront.dk, 61326@debbugs.gnu.org > Date: Mon, 17 Apr 2023 16:48:13 +0800 > > > Ruijie Yu writes: > > > New iteration. As mentioned from my last message, I have reverted the > > part where I tried to rewrite part of `archive-expunge' using `cl-do'. > > > > FTR, I am still waiting for the counter signature from FSF before this > > can be included into emacs.git. > > > > Ping? > > Removing the "DRAFT" from subject, because I think it is probably > complete. Also, my FSF process should now be complete. Great, then, with these two issues out of our way, we can install this now. However, the patch as posted back then no longer applies. Please rebase on the current master branch and re-post. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 05:20:16 2023 Received: (at submit) by debbugs.gnu.org; 20 Apr 2023 09:20:16 +0000 Received: from localhost ([127.0.0.1]:36563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppQSb-0003Tx-32 for submit@debbugs.gnu.org; Thu, 20 Apr 2023 05:20:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:57290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppQSX-0003Tk-AP for submit@debbugs.gnu.org; Thu, 20 Apr 2023 05:20:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQSV-0007VC-JH for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 05:20:07 -0400 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQSS-0006NG-0t; Thu, 20 Apr 2023 05:20:06 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id d74cfd90 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 20 Apr 2023 09:20:00 +0000 (UTC) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> <835y9r6lll.fsf@gnu.org> User-agent: mu4e 1.9.22; emacs 30.0.50 From: Ruijie Yu To: Eli Zaretskii Subject: Re: bug#61326: [PATCH v5] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Date: Thu, 20 Apr 2023 16:49:29 +0800 In-reply-to: <835y9r6lll.fsf@gnu.org> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: asjo@koldfront.dk, bug-gnu-emacs@gnu.org, 61326@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Ruijie Yu >> Cc: Eli Zaretskii , asjo@koldfront.dk, 61326@debbugs.gnu.org >> Date: Mon, 17 Apr 2023 16:48:13 +0800 >> >> >> Ruijie Yu writes: >> >> > New iteration. As mentioned from my last message, I have reverted the >> > part where I tried to rewrite part of `archive-expunge' using `cl-do'. >> > >> > FTR, I am still waiting for the counter signature from FSF before this >> > can be included into emacs.git. >> > >> >> Ping? >> >> Removing the "DRAFT" from subject, because I think it is probably >> complete. Also, my FSF process should now be complete. > > Great, then, with these two issues out of our way, we can install this > now. > > However, the patch as posted back then no longer applies. Please > rebase on the current master branch and re-post. > > Thanks. Thanks. I have made one change after the previous iteration: I turned the "bug#xxx" comment in the test/lisp/arc-mode-tests.el into a docstring. Also, interestingly, git-rebase finishes cleanly on my end. Here attached is a patch _without_ indentation changes. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-modifications-on-extensionless-zips-correctly.patch Content-Description: Patch *without* indentation changes >From a98a530d7a7e73404c107e77c173d8981db811ce Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Mon, 6 Mar 2023 11:03:32 +0800 Subject: [PATCH] Handle modifications on extensionless zips correctly (Bug#61326) * lisp/arc-mode.el (archive-*-write-file-member) (archive-*-expunge): Refactor to correctly modify extensionless zip archives. (archive-expunge): Move implementation to a separate helper function to facilitate testing. (archive--act-files): New helper function to wrap around `call-process' calls. (archive--need-rename-p): New helper function to check whether a temporary rename is necessary. (archive--ensure-extension) (archive--maybe-rename): New helper functions to rename archive if the caller deems it necessary. (archive--with-ensure-extension): New helper function to handle writing an archive while ensuring extensionless archives work correctly by temporarily renaming them. * test/lisp/arc-mode-tests.el (arc-mode-test-zip-ensure-ext): New regression test for bug#61326. --- lisp/arc-mode.el | 76 +++++++++++++++++++++++++++---------- test/lisp/arc-mode-tests.el | 67 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 20 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5e696c091b2..0a971799746 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -645,6 +645,49 @@ archive-get-descr (if (not noerror) (error "Line does not describe a member of the archive"))))) ;; ------------------------------------------------------------------------- +;;; Section: Helper functions for requiring filename extensions + +(defun archive--act-files (command files) + (lambda (archive) + (apply #'call-process (car command) + nil nil nil (append (cdr command) (cons archive files))))) + +(defun archive--need-rename-p (&optional archive) + (let ((archive + (file-name-nondirectory (or archive buffer-file-name)))) + (cl-case archive-subtype + ((zip) (not (seq-contains-p archive ?. #'eq)))))) + +(defun archive--ensure-extension (archive ensure-extension) + (if ensure-extension + (make-temp-name (expand-file-name (concat archive "_tmp."))) + archive)) + +(defun archive--maybe-rename (newname need-rename-p) + ;; Operating with archive as current buffer, and protect + ;; `default-directory' from being modified in `rename-visited-file'. + (when need-rename-p + (let ((default-directory default-directory)) + (rename-visited-file newname)))) + +(defun archive--with-ensure-extension (archive proc-fn) + (let ((saved default-directory)) + (with-current-buffer (find-buffer-visiting archive) + (let ((ensure-extension (archive--need-rename-p)) + (default-directory saved)) + (unwind-protect + ;; Some archive programs (like zip) expect filenames to + ;; have an extension, so if necessary, temporarily rename + ;; an extensionless file for write accesses. + (let ((archive (archive--ensure-extension + archive ensure-extension))) + (archive--maybe-rename archive ensure-extension) + (let ((exitcode (funcall proc-fn archive))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (archive--maybe-rename archive ensure-extension) + (revert-buffer nil t))))))) +;; ------------------------------------------------------------------------- ;;; Section: the mode definition ;;;###autoload @@ -1378,16 +1421,9 @@ archive-*-write-file-member (setq ename (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir))) + (archive--with-ensure-extension + archive (archive--act-files command (list ename))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -1510,9 +1546,7 @@ archive-chgrp-entry (archive-resummarize)) (error "Setting group is not supported for this archive type")))) -(defun archive-expunge () - "Do the flagged deletions." - (interactive) +(defun archive--expunge-maybe-force (force) (let (files) (save-excursion (goto-char archive-file-list-start) @@ -1526,7 +1560,8 @@ archive-expunge (and files (or (not archive-read-only) (error "Archive is read-only")) - (or (yes-or-no-p (format "Really delete %d member%s? " + (or force + (yes-or-no-p (format "Really delete %d member%s? " (length files) (if (null (cdr files)) "" "s"))) (error "Operation aborted")) @@ -1540,13 +1575,14 @@ archive-expunge (archive-resummarize) (revert-buffer)))))) +(defun archive-expunge () + "Do the flagged deletions." + (interactive) + (archive--expunge-maybe-force nil)) + (defun archive-*-expunge (archive files command) - (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) (cons archive files)))) + (archive--with-ensure-extension + archive (archive--act-files command files))) (defun archive-rename-entry (newname) "Change the name associated with this entry in the archive file." diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index 32bce1b71bd..b6e06a563fe 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -46,6 +46,73 @@ arc-mode-test-zip-extract-gz (when (buffer-live-p zip-buffer) (kill-buffer zip-buffer)) (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer))))) +(ert-deftest arc-mode-test-zip-ensure-ext () + "Regression test for bug#61326." + (skip-unless (executable-find "zip")) + (let* ((default-directory arc-mode-tests-data-directory) + (base-zip-1 "base-1.zip") + (base-zip-2 "base-2.zip") + (content-1 '("1" "2")) + (content-2 '("3" "4")) + (make-file (lambda (name) + (with-temp-buffer + (insert name) + (write-file name)))) + (make-zip + (lambda (zip files) + (delete-file zip nil) + (funcall (archive--act-files '("zip") files) zip))) + (update-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + (save-excursion + (goto-char archive-file-list-start) + (save-current-buffer + (archive-extract) + (save-excursion + (goto-char (point-max)) + (insert ?a) + (save-buffer)) + (kill-buffer (current-buffer))) + (archive-extract) + ;; [2] must be ?a; [3] must be (eobp) + (should (eq (char-after 2) ?a)) + (should (eq (point-max) 3)))))) + (delete-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + ;; mark delete and expunge first entry + (save-excursion + (goto-char archive-file-list-start) + (should (length= archive-files 2)) + (archive-flag-deleted 1) + (archive--expunge-maybe-force t) + (should (length= archive-files 1)))))) + (test-modify + (lambda (zip mod-fn) + (let ((zip-base (concat zip ".zip")) + (tag (gensym))) + (copy-file base-zip-1 zip t) + (copy-file base-zip-2 zip-base t) + (file-has-changed-p zip tag) + (file-has-changed-p zip-base tag) + (funcall mod-fn zip) + (should-not (file-has-changed-p zip-base tag)) + (should (file-has-changed-p zip tag)))))) + ;; setup: make two zip files with different contents + (mapc make-file (append content-1 content-2)) + (mapc (lambda (args) (apply make-zip args)) + (list (list base-zip-1 content-1) + (list base-zip-2 content-2))) + ;; test 1: with "test-update" and "test-update.zip", update + ;; "test-update": (1) ensure only "test-update" is modified, (2) + ;; ensure the contents of the new member is expected. + (funcall test-modify "test-update" update-fn) + ;; test 2: with "test-delete" and "test-delete.zip", delete entry + ;; from "test-delete": (1) ensure only "test-delete" is modified, + ;; (2) ensure the file list is reduced as expected. + (funcall test-modify "test-delete" delete-fn))) + (provide 'arc-mode-tests) ;;; arc-mode-tests.el ends here -- 2.40.0 --=-=-= Content-Type: text/plain Here attached is a patch _with_ indentation changes (on functions which I have touched) -- I simply re-indented these functions without tabs. Not sure if you want this, so I provided the other patch file as an alternative. Please choose whichever you prefer to install. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-modifications-on-extensionless-zips-correctly.patch Content-Description: Patch *with* indentation changes >From 36c5f839042e39b3d49e7939543b988142103033 Mon Sep 17 00:00:00 2001 From: Ruijie Yu Date: Mon, 6 Mar 2023 11:03:32 +0800 Subject: [PATCH] Handle modifications on extensionless zips correctly (Bug#61326) * lisp/arc-mode.el (archive-*-write-file-member) (archive-*-expunge): Refactor to correctly modify extensionless zip archives. (archive-expunge): Move implementation to a separate helper function to facilitate testing. (archive--act-files): New helper function to wrap around `call-process' calls. (archive--need-rename-p): New helper function to check whether a temporary rename is necessary. (archive--ensure-extension) (archive--maybe-rename): New helper functions to rename archive if the caller deems it necessary. (archive--with-ensure-extension): New helper function to handle writing an archive while ensuring extensionless archives work correctly by temporarily renaming them. * test/lisp/arc-mode-tests.el (arc-mode-test-zip-ensure-ext): New regression test for bug#61326. --- lisp/arc-mode.el | 144 ++++++++++++++++++++++-------------- test/lisp/arc-mode-tests.el | 67 +++++++++++++++++ 2 files changed, 157 insertions(+), 54 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5e696c091b2..89b3e720ed9 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -645,6 +645,49 @@ archive-get-descr (if (not noerror) (error "Line does not describe a member of the archive"))))) ;; ------------------------------------------------------------------------- +;;; Section: Helper functions for requiring filename extensions + +(defun archive--act-files (command files) + (lambda (archive) + (apply #'call-process (car command) + nil nil nil (append (cdr command) (cons archive files))))) + +(defun archive--need-rename-p (&optional archive) + (let ((archive + (file-name-nondirectory (or archive buffer-file-name)))) + (cl-case archive-subtype + ((zip) (not (seq-contains-p archive ?. #'eq)))))) + +(defun archive--ensure-extension (archive ensure-extension) + (if ensure-extension + (make-temp-name (expand-file-name (concat archive "_tmp."))) + archive)) + +(defun archive--maybe-rename (newname need-rename-p) + ;; Operating with archive as current buffer, and protect + ;; `default-directory' from being modified in `rename-visited-file'. + (when need-rename-p + (let ((default-directory default-directory)) + (rename-visited-file newname)))) + +(defun archive--with-ensure-extension (archive proc-fn) + (let ((saved default-directory)) + (with-current-buffer (find-buffer-visiting archive) + (let ((ensure-extension (archive--need-rename-p)) + (default-directory saved)) + (unwind-protect + ;; Some archive programs (like zip) expect filenames to + ;; have an extension, so if necessary, temporarily rename + ;; an extensionless file for write accesses. + (let ((archive (archive--ensure-extension + archive ensure-extension))) + (archive--maybe-rename archive ensure-extension) + (let ((exitcode (funcall proc-fn archive))) + (or (zerop exitcode) + (error "Updating was unsuccessful (%S)" exitcode)))) + (progn (archive--maybe-rename archive ensure-extension) + (revert-buffer nil t))))))) +;; ------------------------------------------------------------------------- ;;; Section: the mode definition ;;;###autoload @@ -1357,37 +1400,30 @@ archive-*-write-file-member (ename (archive--file-desc-ext-file-name descr)) (tmpfile (expand-file-name ename archive-tmpdir)) (top (directory-file-name (file-name-as-directory archive-tmpdir))) - (default-directory (file-name-as-directory top))) + (default-directory (file-name-as-directory top))) (unwind-protect (progn (make-directory (file-name-directory tmpfile) t) - ;; If the member is itself an archive, write it without - ;; the dired-like listing we created. - (if (eq major-mode 'archive-mode) - (archive-write-file tmpfile) - (write-region nil nil tmpfile nil 'nomessage)) - ;; basic-save-buffer needs last-coding-system-used to have - ;; the value used to write the file, so save it before any - ;; further processing clobbers it (we restore it in - ;; archive-write-file-member, above). - (setq archive-member-coding-system last-coding-system-used) - (if (archive--file-desc-mode descr) - ;; Set the file modes, but make sure we can read it. - (set-file-modes tmpfile - (logior ?\400 (archive--file-desc-mode descr)))) - (setq ename - (encode-coding-string ename archive-file-name-coding-system)) + ;; If the member is itself an archive, write it without + ;; the dired-like listing we created. + (if (eq major-mode 'archive-mode) + (archive-write-file tmpfile) + (write-region nil nil tmpfile nil 'nomessage)) + ;; basic-save-buffer needs last-coding-system-used to have + ;; the value used to write the file, so save it before any + ;; further processing clobbers it (we restore it in + ;; archive-write-file-member, above). + (setq archive-member-coding-system last-coding-system-used) + (if (archive--file-desc-mode descr) + ;; Set the file modes, but make sure we can read it. + (set-file-modes tmpfile + (logior ?\400 (archive--file-desc-mode descr)))) + (setq ename + (encode-coding-string ename archive-file-name-coding-system)) (let* ((coding-system-for-write 'no-conversion) - (default-directory (file-name-as-directory archive-tmpdir)) - (exitcode (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) - (list archive ename))))) - (or (zerop exitcode) - (error "Updating was unsuccessful (%S)" exitcode)))) + (default-directory (file-name-as-directory archive-tmpdir))) + (archive--with-ensure-extension + archive (archive--act-files command (list ename))))) (archive-delete-local tmpfile)))) (defun archive-write-file (&optional file) @@ -1510,43 +1546,43 @@ archive-chgrp-entry (archive-resummarize)) (error "Setting group is not supported for this archive type")))) -(defun archive-expunge () - "Do the flagged deletions." - (interactive) +(defun archive--expunge-maybe-force (force) (let (files) (save-excursion (goto-char archive-file-list-start) (while (< (point) archive-file-list-end) (if (= (following-char) ?D) - (setq files (cons (archive--file-desc-ext-file-name - (archive-get-descr)) - files))) + (setq files (cons (archive--file-desc-ext-file-name + (archive-get-descr)) + files))) (forward-line 1))) (setq files (nreverse files)) (and files - (or (not archive-read-only) - (error "Archive is read-only")) - (or (yes-or-no-p (format "Really delete %d member%s? " - (length files) - (if (null (cdr files)) "" "s"))) - (error "Operation aborted")) - (let ((archive (archive-maybe-copy (buffer-file-name))) - (expunger (archive-name "expunge"))) - (if (fboundp expunger) - (funcall expunger archive files) - (archive-*-expunge archive files (symbol-value expunger))) - (archive-maybe-update nil) - (if archive-remote - (archive-resummarize) - (revert-buffer)))))) + (or (not archive-read-only) + (error "Archive is read-only")) + (or force + (yes-or-no-p (format "Really delete %d member%s? " + (length files) + (if (null (cdr files)) "" "s"))) + (error "Operation aborted")) + (let ((archive (archive-maybe-copy (buffer-file-name))) + (expunger (archive-name "expunge"))) + (if (fboundp expunger) + (funcall expunger archive files) + (archive-*-expunge archive files (symbol-value expunger))) + (archive-maybe-update nil) + (if archive-remote + (archive-resummarize) + (revert-buffer)))))) + +(defun archive-expunge () + "Do the flagged deletions." + (interactive) + (archive--expunge-maybe-force nil)) (defun archive-*-expunge (archive files command) - (apply #'call-process - (car command) - nil - nil - nil - (append (cdr command) (cons archive files)))) + (archive--with-ensure-extension + archive (archive--act-files command files))) (defun archive-rename-entry (newname) "Change the name associated with this entry in the archive file." diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index 32bce1b71bd..b6e06a563fe 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -46,6 +46,73 @@ arc-mode-test-zip-extract-gz (when (buffer-live-p zip-buffer) (kill-buffer zip-buffer)) (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer))))) +(ert-deftest arc-mode-test-zip-ensure-ext () + "Regression test for bug#61326." + (skip-unless (executable-find "zip")) + (let* ((default-directory arc-mode-tests-data-directory) + (base-zip-1 "base-1.zip") + (base-zip-2 "base-2.zip") + (content-1 '("1" "2")) + (content-2 '("3" "4")) + (make-file (lambda (name) + (with-temp-buffer + (insert name) + (write-file name)))) + (make-zip + (lambda (zip files) + (delete-file zip nil) + (funcall (archive--act-files '("zip") files) zip))) + (update-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + (save-excursion + (goto-char archive-file-list-start) + (save-current-buffer + (archive-extract) + (save-excursion + (goto-char (point-max)) + (insert ?a) + (save-buffer)) + (kill-buffer (current-buffer))) + (archive-extract) + ;; [2] must be ?a; [3] must be (eobp) + (should (eq (char-after 2) ?a)) + (should (eq (point-max) 3)))))) + (delete-fn + (lambda (zip-nonempty) + (with-current-buffer (find-file-noselect zip-nonempty) + ;; mark delete and expunge first entry + (save-excursion + (goto-char archive-file-list-start) + (should (length= archive-files 2)) + (archive-flag-deleted 1) + (archive--expunge-maybe-force t) + (should (length= archive-files 1)))))) + (test-modify + (lambda (zip mod-fn) + (let ((zip-base (concat zip ".zip")) + (tag (gensym))) + (copy-file base-zip-1 zip t) + (copy-file base-zip-2 zip-base t) + (file-has-changed-p zip tag) + (file-has-changed-p zip-base tag) + (funcall mod-fn zip) + (should-not (file-has-changed-p zip-base tag)) + (should (file-has-changed-p zip tag)))))) + ;; setup: make two zip files with different contents + (mapc make-file (append content-1 content-2)) + (mapc (lambda (args) (apply make-zip args)) + (list (list base-zip-1 content-1) + (list base-zip-2 content-2))) + ;; test 1: with "test-update" and "test-update.zip", update + ;; "test-update": (1) ensure only "test-update" is modified, (2) + ;; ensure the contents of the new member is expected. + (funcall test-modify "test-update" update-fn) + ;; test 2: with "test-delete" and "test-delete.zip", delete entry + ;; from "test-delete": (1) ensure only "test-delete" is modified, + ;; (2) ensure the file list is reduced as expected. + (funcall test-modify "test-delete" delete-fn))) + (provide 'arc-mode-tests) ;;; arc-mode-tests.el ends here -- 2.40.0 --=-=-= Content-Type: text/plain -- Best, RY [Please note that this mail might go to spam due to some misconfiguration in my mail server -- will fix soon.] --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 05:29:05 2023 Received: (at 61326-done) by debbugs.gnu.org; 20 Apr 2023 09:29:05 +0000 Received: from localhost ([127.0.0.1]:36573 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppQbA-0003hc-RU for submit@debbugs.gnu.org; Thu, 20 Apr 2023 05:29:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppQb7-0003h4-I4 for 61326-done@debbugs.gnu.org; Thu, 20 Apr 2023 05:29:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQau-0000ce-6w; Thu, 20 Apr 2023 05:28:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=i/i6llS8jgElEK8WZimr0JXczigc0WVbiZDgrE+k4So=; b=RmK+0PCI1INd YW3P1ncrqf7rDbTdcKBSQM49xn9l3BhLiAHvzEi4SDW4cJKRtJ/UQtc//B1Zq7l4oS83mLBjgwNXg Xbi3SuNKjOFTUyGhNIm4WDEFo/588hosbEi9Cm6LHwlTFjVw4iE5sCanIvvKnDb4bdpIUvmY3qtc0 uAGXkuPvMz78WSgnGhuSp7Z4zWorYvyKXSqD7jMb3aUmb3rdxfQ3QRWBNvYlZYhLban+GwC3Nt30u O/kPyv0yC1vxPeaHsInX40cgzCHjkmwIhIcz7k5a2GQDwhnKm9j8UuJsTGkkVlNes0xiax18mtQVp 8/b2ujN9YEfApxy1mgROgg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQat-0003di-AF; Thu, 20 Apr 2023 05:28:47 -0400 Date: Thu, 20 Apr 2023 12:29:00 +0300 Message-Id: <83v8hq6gwz.fsf@gnu.org> From: Eli Zaretskii To: Ruijie Yu In-Reply-To: (message from Ruijie Yu on Thu, 20 Apr 2023 16:49:29 +0800) Subject: Re: bug#61326: [PATCH v5] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) References: <87ilgeoc4w.fsf@tullinup.koldfront.dk> <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> <83k00up32i.fsf@gnu.org> <83bkm4nihw.fsf@gnu.org> <83zg8sahin.fsf@gnu.org> <83jzzwa6u3.fsf@gnu.org> <83h6uz8ac4.fsf@gnu.org> <834jqry8fn.fsf@gnu.org> <835y9r6lll.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61326-done Cc: asjo@koldfront.dk, 61326-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ruijie Yu > Cc: asjo@koldfront.dk, 61326@debbugs.gnu.org, bug-gnu-emacs@gnu.org > Date: Thu, 20 Apr 2023 16:49:29 +0800 > > Eli Zaretskii writes: > > > However, the patch as posted back then no longer applies. Please > > rebase on the current master branch and re-post. > > > > Thanks. > > Thanks. I have made one change after the previous iteration: I turned > the "bug#xxx" comment in the test/lisp/arc-mode-tests.el into a > docstring. Also, interestingly, git-rebase finishes cleanly on my end. > > Here attached is a patch _without_ indentation changes. Thanks, the first patch applied cleanly, so I've now pushed this to the master branch, and I'm closing this bug. From unknown Fri Aug 15 15:34:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 18 May 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator