From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#61708: 28.2; file-modes-symbolic-to-number inconsistency Date: Thu, 23 Feb 2023 04:44:10 +0000 Message-ID: <87cz61ufrf.fsf@posteo.net> References: <878rgp244x.fsf@posteo.net> <87356xybtx.fsf@posteo.net> <87y1opwrxj.fsf@posteo.net> <87ttzdwplt.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34631"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andreas Schwab , 61708@debbugs.gnu.org To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 23 06:13:36 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pV3vE-0008nB-A1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Feb 2023 06:13:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV3ui-0002OQ-8Z; Thu, 23 Feb 2023 00:13:04 -0500 Original-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 1pV3ug-0002Nm-KV for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 00:13:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV3ug-0004BD-BY for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 00:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pV3ug-0003IX-6a for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 00:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Feb 2023 05:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61708 X-GNU-PR-Package: emacs Original-Received: via spool by 61708-submit@debbugs.gnu.org id=B61708.167712916312605 (code B ref 61708); Thu, 23 Feb 2023 05:13:02 +0000 Original-Received: (at 61708) by debbugs.gnu.org; 23 Feb 2023 05:12:43 +0000 Original-Received: from localhost ([127.0.0.1]:60904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pV3uM-0003HF-O4 for submit@debbugs.gnu.org; Thu, 23 Feb 2023 00:12:43 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:42871) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pV3uH-0003Gp-Hl for 61708@debbugs.gnu.org; Thu, 23 Feb 2023 00:12:41 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 11115240410 for <61708@debbugs.gnu.org>; Thu, 23 Feb 2023 06:12:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1677129151; bh=wCelpuShsIz85GvBg8/lQI4lEk9rM/t9eJo+2rqqTWo=; h=From:To:Cc:Subject:Date:Autocrypt:OpenPGP:From; b=DjA1iKrxOCuZBpOINci5jURVOXdzethEPrTMn/Uz2otzVZ9CElVqC4cUHCxAUcsEq H19v0UYKTr0ano7uKpR5ISqEQtN+dy0gNMb0FLcmPIpyh2rYwfxCtJ9vRJdPO2XGhv ROOGunwUncPzGF9/Ov/P8qYjZUnlHi8Mq9fFU0zyWFBF2PjaUT/UNaWnxOND8lbNkl ULOVOxC9pb0Ph/yHbp3iUreRVGEFxTI1Y2PtbrqfVvyA9hQOnUZ+aT2Rdb2Ht6Vndc XBuJxbmuLbWZvyBbfj/Ce3Fx/dKyODrT8871X5N3eQkdNp/uNk3ThrUbSP7rr7QW3D fxjPJAwDmunjg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PMh3b29Vgz9rxH; Thu, 23 Feb 2023 06:12:26 +0100 (CET) In-reply-to: Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata=xsDNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MAedi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0pkcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfbtG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQGVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqCWcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEAAc0SdGhpZXZvbEBwb3N0ZW8ubmV0wsEOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8hBp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslxhU46VSz1Z83NwIG3mpdYNV5WUTUdgzx ExHTNTFCd7NKv0nlHKQaAtdXm5bYnSHsnL7cx8z OpenPGP: url=https://posteo.de/keys/thievol@posteo.net.asc; preference=encrypt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256415 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Gregory Heytings writes: >>>> How one convert the output of (nth 8 (file-attributes >>>> "/home/user")) to numeric mode? >>> >>> (file-modes "/home/user") >> >> Yes, thanks I know this one, what I want to convert is >> e.g. "-rwxr-x---" to number. >> > > (defun symbolic-mode-to-number (mode) > (string-to-number > (replace-regexp-in-string > "[^0]" "1" > (string-replace "-" "0" mode)) > 2)) Nice! I never used the BASE argument of string-to-number probably due to my catastrophic math level :-), however this is very basic and doesn't cover modes like "-rwxrwxrwt" or "-rwsr-xr-x". I already wrote the needed functions for my needs (helm), however what I had like is to clarify the usage of `file-modes-symbolic-to-number' in docstring (examples?). As Andrea pointed the MODES argument handle (+-=3D) like chmod would do i.e. the function returns the numeric mode that for example chmod would set= on a file. Once you know it that's fine , you remove the "-" in MODES like read-file-modes does otherwise you may think it interpret the mode that a file already has. Thanks. =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmP29bQTHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvk2EbC/wMGvzbqgxG7Nmlbn/qfg9Wz6nn0rdb iD1zP8Clncw9K2O2i13ImzAw8v5DXHtiz6ILKDd0dUmSQ//TFSGRnquFUjDVKiDb O5Aj/tXZRgvOauBvVSA/ld2cUeSnEb8E0H3F0UA38bxvwuXImnI3k9CEdtm7GkNP wMGL/zfhJ9QE7W+tAb/KUF/m+af/59KrsKQFc4+BITAB5jpe6CURE68u6SgYJvHC 2ZKnuaDuNIEf8GiRy48bbaqWB0HaDyBfX6XAY3p4gVMb0DEo3Ciev7ly3OLZ86bW kQEOkxYjnhMgfI1XQT6X8iKTSh9BISK45SHC4Olseq/o/4nX0VO4CcYfDk7WpjiF OVeTbd9x4ijZoMwNH8YYb6E33OmmRc645XPCgPefxzHyqpCx4P0H0yyPMz0bsAQo MRoy8cjVFQJKWhnDkvEenq5L493VgzgR3Zx9ks7AoBxItWdiH0LG78epibfBkDzB OudSnnRD/86ZTq8+6N4+Ls+p/t4OfpGWcpo= =J+bY -----END PGP SIGNATURE----- --=-=-=--