From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: Re: suggestion for set-file-modes Date: Mon, 11 Feb 2008 18:41:56 -0500 Organization: Epita/LRDE Message-ID: <87r6fjoybf.fsf@cadilhac.name> References: <200801201812.m0KICxYl009632@sallyv1.ics.uci.edu> <871w7jqiic.fsf@cadilhac.name> <200802112200.m1BM0pke028675@sallyv1.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1202773657 24402 80.91.229.12 (11 Feb 2008 23:47:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Feb 2008 23:47:37 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 12 00:47:59 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JOiNP-000153-V7 for ged-emacs-devel@m.gmane.org; Tue, 12 Feb 2008 00:47:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOiMw-0001G7-C7 for ged-emacs-devel@m.gmane.org; Mon, 11 Feb 2008 18:47:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JOiMs-0001FB-Qb for emacs-devel@gnu.org; Mon, 11 Feb 2008 18:47:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JOiMs-0001Es-4i for emacs-devel@gnu.org; Mon, 11 Feb 2008 18:47:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOiMs-0001Ep-25 for emacs-devel@gnu.org; Mon, 11 Feb 2008 18:47:22 -0500 Original-Received: from py-out-1112.google.com ([64.233.166.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JOiMr-0001tm-UR for emacs-devel@gnu.org; Mon, 11 Feb 2008 18:47:22 -0500 Original-Received: by py-out-1112.google.com with SMTP id u52so5194086pyb.1 for ; Mon, 11 Feb 2008 15:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:organization:references:x-website:face:date:in-reply-to:message-id:user-agent:mime-version:content-type:sender; bh=gDkzZwKMF3JvI3OKKeg4QOayit9M2yCjZxzxBHLFUig=; b=OsS9geDY+qPU7qSv936vGoFAow2T+0DtckqDR5XSMwlAxSzraquDoRR/kBhfGcoLgBSBmKxQQmQ/WoZ/7UtIvMEbysYca0ZvQXRHstYA5oBaTp0+jbfNCvtaBDvjzvjRKPXA78+mmtMgoIN90qH65IVK09YeulkHUEFRIKiPXkw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:organization:references:x-website:face:date:in-reply-to:message-id:user-agent:mime-version:content-type:sender; b=uIiqWwZNumKU8tiokCz71D7E0IU+xw+qjPuIb5jzSxSn3Q2i7FaqJF0sLEbIfLubukplvFD8lvaERa6DqPi3ADLc8qYAtfOdmIMWPutCSu4diKhTYKHOwRkYVUuDKTIHeUyCEwzDvOeYdSfTruNEx89U6kw23iBUbZxr0WzPziQ= Original-Received: by 10.35.32.3 with SMTP id k3mr669781pyj.18.1202773639394; Mon, 11 Feb 2008 15:47:19 -0800 (PST) Original-Received: from localhost ( [76.68.148.67]) by mx.google.com with ESMTPS id v55sm23422675pyh.39.2008.02.11.15.47.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Feb 2008 15:47:18 -0800 (PST) X-Website: http://michael.cadilhac.name Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEU/JREXDATg1LV8UCao i1fQpmoP3Nd6AAACa0lEQVQ4jWWUQW7jMAxFqZEPICJzAjXeM6W8dyNqX9ji/a8yn04xnWIEJLD9 LJH85DcJFyJV3erqPty8ExHfBikXSdn0WVezC0hOAQiA2nCsAHOqEnPe4k+puU8zw/t+xquqjRKA 4lHsmQBT8C5pDtBwfwH8VdcHI5+FHtjRxrQRwZsf3hNjZRKAPEzHEdH9mFNSYb5dQK3r8KM6ftNy KikAirDZFWdVkDqbxjGFbAcwbQCxxc8mPRHUGOcCIMgMACV23RfJTch3gC6ofT3qCdG0NyUUPfYF yQrKCIAnuYsgX2qPzW2i9sNrfSOSPPZQiygtCNlCjlpXJV38lIKshF/AZzsAMoArdCKNHfXukPuJ ImbLh+9J2gXwap0QpZ7NjZ7ekdkFcDiqPiLGcHmuvaG/AHgy62s52Lae1ABoA7D6d2kDoAvgbnyD ZutEd6lTHOXfYPHVJDH1K8a1+oyrjoZpAGn1x5pfwPr2E9yjxSpk50/gEyKgD/+BD/KzN3tQ13b8 Cx5loF0AgnZf5IUny9hRHQOYBllHDM+6s3oviZBu77mFjDm621Np3hkjR90wE1BkTYvhdDgDgCmR xWChFfcYAOqMm5NZkVWMur8AL5+oeMQOob2FmY76FiM+PrDDZypwGdqokSlAaQOmGH6mW8KpsOwl 0YOLedjSITr6scNRF8D4PesH33QmLrx8AzjpV/3kkg025w2gfAFYKCLluJAc4Ap+h18oo4S8wzaY klDsBUTiY8EZFkg5Iass75FubC9wd8qa0u9+gRxAsAKEaRAo6iB+vwCMGmdBjvgidQGA1ntMX4CS ZYGV/wADyL80LIX/UAAAAABJRU5ErkJggg== In-Reply-To: <200802112200.m1BM0pke028675@sallyv1.ics.uci.edu> (Dan Nicolaescu's message of "Mon, 11 Feb 2008 14:00:51 -0800") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:88803 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Dan Nicolaescu writes: > michael@cadilhac.name (Micha=EBl Cadilhac) writes: > > > Dan Nicolaescu writes: > >=20 > > > I think it would be good if set-file-modes would display the current > > > modes in symbolic form in the prompt for changing them. > >=20 > > Displaying the current modes is probably a good thing to do, but putt= ing > > it in the prompt in order to be changed seems weird: when the modes a= re > > expressed in symbolic notation, they are used as a *mask* against the > > current modes, not a simple modification. > > Maybe a more intuitive thing we can do is to prompt the following=A0: > >=20 > > "File modes, octal or symbolic (current: -r-xrw---):" > > This form is exactly what I had in mind. This format is familiar to > people from "ls -l". If users request something else, it can be changed > later, but this should do for now. Obviously, this is all IMHO... Following that proposition, on which we agreed, here's a patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=files.patch Content-Transfer-Encoding: quoted-printable Index: files.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.959 diff -b -u -w -r1.959 files.el =2D-- files.el 30 Jan 2008 21:25:08 -0000 1.959 +++ files.el 11 Feb 2008 23:38:35 -0000 @@ -5464,7 +5464,7 @@ (t (apply operation arguments))))) =2D;; Symbolic modes and read-file-modes. +;; Symbolic modes, ls-type modes, and read-file-modes. =20 (defun file-modes-char-to-who (char) "Convert CHAR to a who-mask from a symbolic mode notation. @@ -5543,13 +5543,38 @@ (error "Parse error in modes near `%s'" (substring modes 0)))) num-modes))) =20 +(defun file-modes-number-to-ls (modes) + "Convert the numerical MODES into the `ls' notation." + (let (string) + (dotimes (i 3 string) + (let* ((is-executable (/=3D 0 (logand modes 1))) + (exec-bit + (or (cond ((and (=3D i 0) ;; Sticky. + (/=3D 0 (logand modes #o1000))) + (if is-executable "t" "T")) + ((or (and (=3D i 1) ;; Set-gid. + (/=3D 0 (logand modes #o200))) + (and (=3D i 2) ;; Set-uid. + (/=3D 0 (logand modes #o40)))) + (if is-executable "s" "S"))) + (if is-executable "x" "-")))) + (setq string (concat (if (/=3D 0 (logand modes 4)) "r" "-") + (if (/=3D 0 (logand modes 2)) "w" "-") + exec-bit string)) + (setq modes (lsh modes -3)))))) + (defun read-file-modes (&optional prompt orig-file) "Read file modes in octal or symbolic notation. =2DPROMPT is used as the prompt, default to `File modes (octal or symbolic)= : '. =2DORIG-FILE is the original file of which modes will be change." +PROMPT is used as the prompt, default to `File modes, octal or symbolic' +followed by the current modes of ORIG-FILE. +ORIG-FILE is the file of which modes will be changed." (let* ((modes (or (if orig-file (file-modes orig-file) 0) (error "File not found"))) =2D (value (read-string (or prompt "File modes (octal or symbolic): ")))) + (ls-type-modes (when orig-file + (concat " (current: " (file-modes-number-to-ls modes) + ")"))) + (value (read-string (or prompt (concat "File modes, octal or symbolic" + ls-type-modes ": "))))) (save-match-data (if (string-match "^[0-7]+" value) (string-to-number value 8) Diffs between working revision and workfile end here. --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable If there's no complain in a few days, I'll install it. =2D-=20 | Micha=EBl `Micha' Cadilhac | Si j'=E9tais sous-secr=E9taire d'= =C9tat | | http://michael.cadilhac.name | aux choux farcis, vous entendriez = | | JID/MSN: | beaucoup parler des choux farcis ! = | `---- michael.cadilhac@gmail.com | -- Nicolas Sarkozy - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.2 (GNU/Linux) iD8DBQFHsN1RUJhDmOfFA3URAr7qAJ98gIegnIWv1/7dIWBK/olXrc5adACgniIm G3imVIT/TJoAjka5ZVjZgFQ= =NDj4 -----END PGP SIGNATURE----- --==-=-=--