diff options
| author | Tino Calancha | 2020-05-08 22:14:03 +0200 |
|---|---|---|
| committer | Tino Calancha | 2020-05-14 18:43:15 +0200 |
| commit | 3a284e578625e617fdc6085ae11da2b4e41bb59b (patch) | |
| tree | ff6c8708cc3cd9d892d2433be5adbf9156584157 /lisp | |
| parent | 4af8b17149ee04655f038229c6103963f247ff87 (diff) | |
| download | emacs-3a284e578625e617fdc6085ae11da2b4e41bb59b.tar.gz emacs-3a284e578625e617fdc6085ae11da2b4e41bb59b.zip | |
Combine archive-int-to-mode and tar-grind-file-modebug27952_combine-tar-grind-file-mode_archive-int-to-mode
Add a new function, file-modes-number-to-symbolic.
Make archive-int-to-mode and obsolete alias of it; use it
to define tar-grind-file-mode (Bug#27952).
* lisp/files.el (file-modes-number-to-symbolic): New defun.
* lisp/arc-mode.el (archive-int-to-mode): Make it an obsolete alias.
* lisp/tar-mode.el (tar-grind-file-mode):
Use file-modes-number-to-symbolic.
* test/lisp/arc-mode-tests.el (arc-mode-test-archive-int-to-mode)
* test/lisp/tar-mode-tests.el (tar-mode-test-tar-grind-file-mode):
Update test.
* test/lisp/files-tests.el (files-tests-file-modes-symbolic-to-number)
(files-tests-file-modes-number-to-symbolic): New tests.
* doc/lispref/files.texi (Changing Files): Document the new funtion.
* etc/NEWS (Lisp Changes in Emacs 28.1): Announce it.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/arc-mode.el | 24 | ||||
| -rw-r--r-- | lisp/files.el | 21 | ||||
| -rw-r--r-- | lisp/tar-mode.el | 20 |
3 files changed, 26 insertions, 39 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index c918f06c80e..6ce64fe24b3 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el | |||
| @@ -563,28 +563,8 @@ in which case a second argument, length LEN, should be supplied." | |||
| 563 | (aref str (- len i))))) | 563 | (aref str (- len i))))) |
| 564 | result)) | 564 | result)) |
| 565 | 565 | ||
| 566 | (defun archive-int-to-mode (mode) | 566 | (define-obsolete-function-alias 'archive-int-to-mode |
| 567 | "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------." | 567 | 'file-modes-number-to-symbolic "28.1") |
| 568 | ;; FIXME: merge with tar-grind-file-mode. | ||
| 569 | (if (null mode) | ||
| 570 | "??????????" | ||
| 571 | (string | ||
| 572 | (if (zerop (logand 8192 mode)) | ||
| 573 | (if (zerop (logand 16384 mode)) ?- ?d) | ||
| 574 | ?c) ; completeness | ||
| 575 | (if (zerop (logand 256 mode)) ?- ?r) | ||
| 576 | (if (zerop (logand 128 mode)) ?- ?w) | ||
| 577 | (if (zerop (logand 64 mode)) | ||
| 578 | (if (zerop (logand 2048 mode)) ?- ?S) | ||
| 579 | (if (zerop (logand 2048 mode)) ?x ?s)) | ||
| 580 | (if (zerop (logand 32 mode)) ?- ?r) | ||
| 581 | (if (zerop (logand 16 mode)) ?- ?w) | ||
| 582 | (if (zerop (logand 8 mode)) | ||
| 583 | (if (zerop (logand 1024 mode)) ?- ?S) | ||
| 584 | (if (zerop (logand 1024 mode)) ?x ?s)) | ||
| 585 | (if (zerop (logand 4 mode)) ?- ?r) | ||
| 586 | (if (zerop (logand 2 mode)) ?- ?w) | ||
| 587 | (if (zerop (logand 1 mode)) ?- ?x)))) | ||
| 588 | 568 | ||
| 589 | (defun archive-calc-mode (oldmode newmode) | 569 | (defun archive-calc-mode (oldmode newmode) |
| 590 | "From the integer OLDMODE and the string NEWMODE calculate a new file mode. | 570 | "From the integer OLDMODE and the string NEWMODE calculate a new file mode. |
diff --git a/lisp/files.el b/lisp/files.el index c34fe003880..dba704f7a4b 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -7552,6 +7552,27 @@ as in \"og+rX-w\"." | |||
| 7552 | op char-right))) | 7552 | op char-right))) |
| 7553 | num-rights)) | 7553 | num-rights)) |
| 7554 | 7554 | ||
| 7555 | (defun file-modes-number-to-symbolic (mode) | ||
| 7556 | (string | ||
| 7557 | (if (zerop (logand 8192 mode)) | ||
| 7558 | (if (zerop (logand 16384 mode)) ?- ?d) | ||
| 7559 | ?c) ; completeness | ||
| 7560 | (if (zerop (logand 256 mode)) ?- ?r) | ||
| 7561 | (if (zerop (logand 128 mode)) ?- ?w) | ||
| 7562 | (if (zerop (logand 64 mode)) | ||
| 7563 | (if (zerop (logand 2048 mode)) ?- ?S) | ||
| 7564 | (if (zerop (logand 2048 mode)) ?x ?s)) | ||
| 7565 | (if (zerop (logand 32 mode)) ?- ?r) | ||
| 7566 | (if (zerop (logand 16 mode)) ?- ?w) | ||
| 7567 | (if (zerop (logand 8 mode)) | ||
| 7568 | (if (zerop (logand 1024 mode)) ?- ?S) | ||
| 7569 | (if (zerop (logand 1024 mode)) ?x ?s)) | ||
| 7570 | (if (zerop (logand 4 mode)) ?- ?r) | ||
| 7571 | (if (zerop (logand 2 mode)) ?- ?w) | ||
| 7572 | (if (zerop (logand 512 mode)) | ||
| 7573 | (if (zerop (logand 1 mode)) ?- ?x) | ||
| 7574 | (if (zerop (logand 1 mode)) ?T ?t)))) | ||
| 7575 | |||
| 7555 | (defun file-modes-symbolic-to-number (modes &optional from) | 7576 | (defun file-modes-symbolic-to-number (modes &optional from) |
| 7556 | "Convert symbolic file modes to numeric file modes. | 7577 | "Convert symbolic file modes to numeric file modes. |
| 7557 | MODES is the string to convert, it should match | 7578 | MODES is the string to convert, it should match |
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index a3c1715b1e1..73978ffc4a7 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el | |||
| @@ -480,23 +480,9 @@ checksum before doing the check." | |||
| 480 | 480 | ||
| 481 | (defun tar-grind-file-mode (mode) | 481 | (defun tar-grind-file-mode (mode) |
| 482 | "Construct a `rw-r--r--' string indicating MODE. | 482 | "Construct a `rw-r--r--' string indicating MODE. |
| 483 | MODE should be an integer which is a file mode value." | 483 | MODE should be an integer which is a file mode value. |
| 484 | (string | 484 | For instance, if mode is #o700, then it produces `rwx------'." |
| 485 | (if (zerop (logand 256 mode)) ?- ?r) | 485 | (substring (file-modes-number-to-symbolic mode) 1)) |
| 486 | (if (zerop (logand 128 mode)) ?- ?w) | ||
| 487 | (if (zerop (logand 2048 mode)) | ||
| 488 | (if (zerop (logand 64 mode)) ?- ?x) | ||
| 489 | (if (zerop (logand 64 mode)) ?S ?s)) | ||
| 490 | (if (zerop (logand 32 mode)) ?- ?r) | ||
| 491 | (if (zerop (logand 16 mode)) ?- ?w) | ||
| 492 | (if (zerop (logand 1024 mode)) | ||
| 493 | (if (zerop (logand 8 mode)) ?- ?x) | ||
| 494 | (if (zerop (logand 8 mode)) ?S ?s)) | ||
| 495 | (if (zerop (logand 4 mode)) ?- ?r) | ||
| 496 | (if (zerop (logand 2 mode)) ?- ?w) | ||
| 497 | (if (zerop (logand 512 mode)) | ||
| 498 | (if (zerop (logand 1 mode)) ?- ?x) | ||
| 499 | (if (zerop (logand 1 mode)) ?T ?t)))) | ||
| 500 | 486 | ||
| 501 | (defun tar-header-block-summarize (tar-hblock &optional mod-p) | 487 | (defun tar-header-block-summarize (tar-hblock &optional mod-p) |
| 502 | "Return a line similar to the output of `tar -vtf'." | 488 | "Return a line similar to the output of `tar -vtf'." |