From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: master 3a284e5: Combine archive-int-to-mode and tar-grind-file-mode
Date: Thu, 14 May 2020 15:51:05 -0400 [thread overview]
Message-ID: <jwvv9kymhsy.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20200514164505.2F26320A29@vcs0.savannah.gnu.org> (Tino Calancha's message of "Thu, 14 May 2020 12:45:04 -0400 (EDT)")
> +(defun file-modes-number-to-symbolic (mode)
> + (string
> + (if (zerop (logand 8192 mode))
> + (if (zerop (logand 16384 mode)) ?- ?d)
> + ?c) ; completeness
BTW, I was looking at how to get rid of `tar-grind-file-mode` and along
the way I saw that this first char is really representing the file type
and there is no real standard for how a "modes" number can represent the
file type. IOW the 8192/16484 above are fairly arbitrary (I suspect they
correspond to what happens to be used in `.zip` files and probably
won't match what's used in any other circumstance, e.g. they don't match
what Git uses, IIUC).
How 'bout the patch below?
Stefan
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 6ce64fe24b3..82a79af8931 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -563,8 +563,13 @@ archive-l-e
(aref str (- len i)))))
result))
-(define-obsolete-function-alias 'archive-int-to-mode
- 'file-modes-number-to-symbolic "28.1")
+(defun archive-int-to-mode (mode)
+ ;; FIXME: Make this obsolete. For this, we will need to clarify
+ ;; where those 8192/16384 come from and what to do about them.
+ (file-modes-number-to-symbolic
+ mode (if (zerop (logand 8192 mode))
+ (if (zerop (logand 16384 mode)) ?- ?d)
+ ?c)))
(defun archive-calc-mode (oldmode newmode)
"From the integer OLDMODE and the string NEWMODE calculate a new file mode.
@@ -626,7 +631,8 @@ archive-get-descr
(let ((item (aref archive-files no)))
(if (and (archive--file-desc-p item)
(let ((mode (archive--file-desc-mode item)))
- (zerop (logand 16384 mode))))
+ ;; FIXME: Why 16384? See comment in archive-int-to-mode.
+ (or (null mode) (zerop (logand 16384 mode)))))
item
(if (not noerror)
(user-error "Entry is not a regular member of the archive"))))
@@ -2119,7 +2125,6 @@ archive-7z-write-file-member
;; not the GNU nor the BSD extensions. As it turns out, this is sufficient
;; for .deb packages.
-(autoload 'tar-grind-file-mode "tar-mode")
(defconst archive-ar-file-header-re
"\\(.\\{16\\}\\)\\([ 0-9]\\{12\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-7]\\{8\\}\\)\\([ 0-9]\\{10\\}\\)`\n")
diff --git a/lisp/files.el b/lisp/files.el
index dba704f7a4b..cfbe085f9c1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -441,6 +441,7 @@ auto-save-visited-mode
#'save-some-buffers :no-prompt
(lambda ()
(and buffer-file-name
+ auto-save-visited-mode
(not (and buffer-auto-save-file-name
auto-save-visited-file-name))))))))
@@ -7552,11 +7553,14 @@ file-modes-rights-to-number
op char-right)))
num-rights))
-(defun file-modes-number-to-symbolic (mode)
+(defun file-modes-number-to-symbolic (mode &optional filetype)
+ "Return a string describing a a file's MODE.
+For instance, if MODE is #o700, then it produces `-rwx------'.
+FILETYPE if provided should be a character denoting the type of file,
+such as `?d' for a directory, or `?l' for a symbolic link and will replace
+the leading `-' char."
(string
- (if (zerop (logand 8192 mode))
- (if (zerop (logand 16384 mode)) ?- ?d)
- ?c) ; completeness
+ (or filetype ?-)
(if (zerop (logand 256 mode)) ?- ?r)
(if (zerop (logand 128 mode)) ?- ?w)
(if (zerop (logand 64 mode))
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index 73978ffc4a7..75ffb5647e1 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -482,6 +482,7 @@ tar-grind-file-mode
"Construct a `rw-r--r--' string indicating MODE.
MODE should be an integer which is a file mode value.
For instance, if mode is #o700, then it produces `rwx------'."
+ (declare (obsolete file-modes-number-to-symbolic "28.1"))
(substring (file-modes-number-to-symbolic mode) 1))
(defun tar-header-block-summarize (tar-hblock &optional mod-p)
@@ -497,25 +498,26 @@ tar-header-block-summarize
;; (ck (tar-header-checksum tar-hblock))
(type (tar-header-link-type tar-hblock))
(link-name (tar-header-link-name tar-hblock)))
- (format "%c%c%s %7s/%-7s %7s%s %s%s"
+ (format "%c%s %7s/%-7s %7s%s %s%s"
(if mod-p ?* ? )
- (cond ((or (eq type nil) (eq type 0)) ?-)
- ((eq type 1) ?h) ; link
- ((eq type 2) ?l) ; symlink
- ((eq type 3) ?c) ; char special
- ((eq type 4) ?b) ; block special
- ((eq type 5) ?d) ; directory
- ((eq type 6) ?p) ; FIFO/pipe
- ((eq type 20) ?*) ; directory listing
- ((eq type 28) ?L) ; next has longname
- ((eq type 29) ?M) ; multivolume continuation
- ((eq type 35) ?S) ; sparse
- ((eq type 38) ?V) ; volume header
- ((eq type 55) ?H) ; pax global extended header
- ((eq type 72) ?X) ; pax extended header
- (t ?\s)
- )
- (tar-grind-file-mode mode)
+ (file-modes-number-to-symbolic
+ (tar-grind-file-mode mode)
+ (cond ((or (eq type nil) (eq type 0)) ?-)
+ ((eq type 1) ?h) ; link
+ ((eq type 2) ?l) ; symlink
+ ((eq type 3) ?c) ; char special
+ ((eq type 4) ?b) ; block special
+ ((eq type 5) ?d) ; directory
+ ((eq type 6) ?p) ; FIFO/pipe
+ ((eq type 20) ?*) ; directory listing
+ ((eq type 28) ?L) ; next has longname
+ ((eq type 29) ?M) ; multivolume continuation
+ ((eq type 35) ?S) ; sparse
+ ((eq type 38) ?V) ; volume header
+ ((eq type 55) ?H) ; pax global extended header
+ ((eq type 72) ?X) ; pax extended header
+ (t ?\s)
+ ))
(if (= 0 (length uname)) uid uname)
(if (= 0 (length gname)) gid gname)
size
parent reply other threads:[~2020-05-14 19:51 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20200514164505.2F26320A29@vcs0.savannah.gnu.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvv9kymhsy.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=tino.calancha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).