* Re: suggestion for set-file-modes
[not found] ` <200802112200.m1BM0pke028675@sallyv1.ics.uci.edu>
@ 2008-02-11 23:41 ` Michaël Cadilhac
2008-02-16 19:19 ` Juri Linkov
0 siblings, 1 reply; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-11 23:41 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 1028 bytes --]
Dan Nicolaescu <dann@ics.uci.edu> writes:
> michael@cadilhac.name (Michaël Cadilhac) writes:
>
> > Dan Nicolaescu <dann@ics.uci.edu> writes:
> >
> > > I think it would be good if set-file-modes would display the current
> > > modes in symbolic form in the prompt for changing them.
> >
> > Displaying the current modes is probably a good thing to do, but putting
> > it in the prompt in order to be changed seems weird: when the modes are
> > 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 :
> >
> > "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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: files.patch --]
[-- Type: text/x-patch, Size: 2372 bytes --]
Index: files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.959
diff -b -u -w -r1.959 files.el
--- 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)))))
\f
-;; Symbolic modes and read-file-modes.
+;; Symbolic modes, ls-type modes, and read-file-modes.
(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)))
+(defun file-modes-number-to-ls (modes)
+ "Convert the numerical MODES into the `ls' notation."
+ (let (string)
+ (dotimes (i 3 string)
+ (let* ((is-executable (/= 0 (logand modes 1)))
+ (exec-bit
+ (or (cond ((and (= i 0) ;; Sticky.
+ (/= 0 (logand modes #o1000)))
+ (if is-executable "t" "T"))
+ ((or (and (= i 1) ;; Set-gid.
+ (/= 0 (logand modes #o200)))
+ (and (= i 2) ;; Set-uid.
+ (/= 0 (logand modes #o40))))
+ (if is-executable "s" "S")))
+ (if is-executable "x" "-"))))
+ (setq string (concat (if (/= 0 (logand modes 4)) "r" "-")
+ (if (/= 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.
-PROMPT is used as the prompt, default to `File modes (octal or symbolic): '.
-ORIG-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")))
- (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.
[-- Attachment #1.3: Type: text/plain, Size: 385 bytes --]
If there's no complain in a few days, I'll install it.
--
| Michaël `Micha' Cadilhac | Si j'étais sous-secrétaire d'État |
| http://michael.cadilhac.name | aux choux farcis, vous entendriez |
| JID/MSN: | beaucoup parler des choux farcis ! |
`---- michael.cadilhac@gmail.com | -- Nicolas Sarkozy - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-11 23:41 ` suggestion for set-file-modes Michaël Cadilhac
@ 2008-02-16 19:19 ` Juri Linkov
2008-02-16 23:07 ` Michaël Cadilhac
0 siblings, 1 reply; 19+ messages in thread
From: Juri Linkov @ 2008-02-16 19:19 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Dan Nicolaescu, emacs-devel
>> > Maybe a more intuitive thing we can do is to prompt the following :
>> >
>> > "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.
This is very nice, but why you don't accept this string in the same format
allowing the user to enter it in the minibuffer (i.e. why you didn't
implement `file-modes-ls-to-number')?
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-16 19:19 ` Juri Linkov
@ 2008-02-16 23:07 ` Michaël Cadilhac
2008-02-16 23:27 ` Juri Linkov
0 siblings, 1 reply; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-16 23:07 UTC (permalink / raw)
To: Juri Linkov; +Cc: Dan Nicolaescu, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
Juri Linkov <juri@jurta.org> writes:
>>> > Maybe a more intuitive thing we can do is to prompt the following :
>>> >
>>> > "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.
>
> This is very nice, but why you don't accept this string in the same format
> allowing the user to enter it in the minibuffer (i.e. why you didn't
> implement `file-modes-ls-to-number')?
Well, I've never seen anyone (or any tool) using that notation to *set*
file modes. Yes, it will allow Emacs to tend to more completeness, but
I think Emacs goal lays more in usefulness.
Do you have any practical case in which that notation could be more
natural?
--
| Michaël `Micha' Cadilhac | (\(\ This is the cute bunny virus, |
| http://michael.cadilhac.name | (^.^) please copy this into your |
| JID/MSN: | (")") sig so it can spread. |
`---- michael.cadilhac@gmail.com | - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-16 23:07 ` Michaël Cadilhac
@ 2008-02-16 23:27 ` Juri Linkov
2008-02-17 0:14 ` Michaël Cadilhac
0 siblings, 1 reply; 19+ messages in thread
From: Juri Linkov @ 2008-02-16 23:27 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Dan Nicolaescu, emacs-devel
>> This is very nice, but why you don't accept this string in the same format
>> allowing the user to enter it in the minibuffer (i.e. why you didn't
>> implement `file-modes-ls-to-number')?
>
> Well, I've never seen anyone (or any tool) using that notation to *set*
> file modes. Yes, it will allow Emacs to tend to more completeness, but
> I think Emacs goal lays more in usefulness.
>
> Do you have any practical case in which that notation could be more
> natural?
Wdired mode allows editing such file permissions in the dired buffer
(when `wdired-allow-to-change-permissions' is non-nil), so it would be
natural to allow entering file permission in the same notation in
the minibuffer. There already exists a function that converts
that notation to the number: `wdired-perms-to-number'.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-16 23:27 ` Juri Linkov
@ 2008-02-17 0:14 ` Michaël Cadilhac
2008-02-17 0:48 ` Juri Linkov
0 siblings, 1 reply; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-17 0:14 UTC (permalink / raw)
To: Juri Linkov; +Cc: Dan Nicolaescu, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]
Juri Linkov <juri@jurta.org> writes:
>>> This is very nice, but why you don't accept this string in the same format
>>> allowing the user to enter it in the minibuffer (i.e. why you didn't
>>> implement `file-modes-ls-to-number')?
>>
>> Well, I've never seen anyone (or any tool) using that notation to *set*
>> file modes. Yes, it will allow Emacs to tend to more completeness, but
>> I think Emacs goal lays more in usefulness.
>>
>> Do you have any practical case in which that notation could be more
>> natural?
>
> Wdired mode allows editing such file permissions in the dired buffer
> (when `wdired-allow-to-change-permissions' is non-nil), so it would be
(BTW thanks, looking at this variable allowed me to remove all
references to `dired-chmod-program'.)
> natural to allow entering file permission in the same notation in
> the minibuffer.
I still don't think really so ; the rational for Wdired to permit that
is that the bits are *toggled*, not arbitrary set.
> There already exists a function that converts that notation to the
> number: `wdired-perms-to-number'.
For instance, that function doesn't check for error (it should,
however). The so-said `advanced' mode is only useful for mass chmod-ing
(using replace-string and like), which is not the purpose of
`read-file-modes'.
I'd really prefer not to have two symbolic notations in here.
--
| Michaël `Micha' Cadilhac | I am very sad for you |
| http://michael.cadilhac.name | that you are running |
| JID/MSN: | Windows Vista. |
`---- michael.cadilhac@gmail.com | -- RMS - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 0:14 ` Michaël Cadilhac
@ 2008-02-17 0:48 ` Juri Linkov
2008-02-17 1:08 ` Miles Bader
2008-02-17 1:39 ` Michaël Cadilhac
0 siblings, 2 replies; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 0:48 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Dan Nicolaescu, emacs-devel
>> natural to allow entering file permission in the same notation in
>> the minibuffer.
>
> I still don't think really so; the rational for Wdired to permit that
> is that the bits are *toggled*, not arbitrary set.
The standard convention when reading a value in the minibuffer is to put
the default value in the prompt and make it available for editing by M-n.
When the permission bits are retrieved in such notation from the default
value then editing them is just like toggling that is convenient.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 0:48 ` Juri Linkov
@ 2008-02-17 1:08 ` Miles Bader
2008-02-17 1:31 ` Juri Linkov
2008-07-29 17:43 ` Juri Linkov
2008-02-17 1:39 ` Michaël Cadilhac
1 sibling, 2 replies; 19+ messages in thread
From: Miles Bader @ 2008-02-17 1:08 UTC (permalink / raw)
To: Juri Linkov; +Cc: Nicolaescu, Michaël Cadilhac, emacs-devel
Juri Linkov <juri@jurta.org> writes:
> The standard convention when reading a value in the minibuffer is to put
> the default value in the prompt and make it available for editing by M-n.
> When the permission bits are retrieved in such notation from the default
> value then editing them is just like toggling that is convenient.
Soooo, why not convert it to an appropriate "input form" for putting in
the prompt/default ?
E.g., -rwxrwxrw- => "ug=rwx,o=rw"
That has the advantage that such "input forms" are a bit more robust,
because they aren't fixed-width with position-senstive fields. They're
also somewhat more self-documenting.
[Also, of course, it's more consistent with other programs, none of
which use the "ls forms" for input.]
It shouldn't be very hard to do.
-Miles
--
The automobile has not merely taken over the street, it has dissolved the
living tissue of the city. Its appetite for space is absolutely insatiable;
moving and parked, it devours urban land, leaving the buildings as mere islands
of habitable space in a sea of dangerous and ugly traffic.
[James Marston Fitch, New York Times, 1 May 1960]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 1:08 ` Miles Bader
@ 2008-02-17 1:31 ` Juri Linkov
2008-02-17 2:04 ` Michaël Cadilhac
2008-07-29 17:43 ` Juri Linkov
1 sibling, 1 reply; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 1:31 UTC (permalink / raw)
To: Miles Bader; +Cc: Nicolaescu, Michaël Cadilhac, emacs-devel
>> The standard convention when reading a value in the minibuffer is to put
>> the default value in the prompt and make it available for editing by M-n.
>> When the permission bits are retrieved in such notation from the default
>> value then editing them is just like toggling that is convenient.
>
> Soooo, why not convert it to an appropriate "input form" for putting in
> the prompt/default ?
>
> E.g., -rwxrwxrw- => "ug=rwx,o=rw"
>
> That has the advantage that such "input forms" are a bit more robust,
> because they aren't fixed-width with position-senstive fields. They're
> also somewhat more self-documenting.
That would be nice, maybe with separating every part even with the same
permissions, e.g. "u=rwx,g=rwx,o=rw" for less editing when the user and
group part need different permissions.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 0:48 ` Juri Linkov
2008-02-17 1:08 ` Miles Bader
@ 2008-02-17 1:39 ` Michaël Cadilhac
2008-02-17 20:29 ` Richard Stallman
2008-02-17 21:55 ` Juri Linkov
1 sibling, 2 replies; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-17 1:39 UTC (permalink / raw)
To: Juri Linkov; +Cc: Dan Nicolaescu, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]
Juri Linkov <juri@jurta.org> writes:
>>> natural to allow entering file permission in the same notation in
>>> the minibuffer.
>>
>> I still don't think really so; the rational for Wdired to permit that
>> is that the bits are *toggled*, not arbitrary set.
>
> The standard convention when reading a value in the minibuffer is to put
> the default value in the prompt and make it available for editing by
> M-n.
First, if we have three different notations, why this one should be
preferred as the default one?
> When the permission bits are retrieved in such notation from the default
> value then editing them is just like toggling that is convenient.
Second, from `-------' to `-rw-rwxr-x', there is 5 times `space' and
three `right' when we talk about toggling, while it's `right, C-d, r,
C-d, w, right, C-d, r, C-d, w, C-d, x, C-d, r, right, C-d, x' when
editing, which is a lot more cumbersome. And typing `-rw-rwxr-x'
(which, you'd agree, is not natural) is best replaced by `a+r,ug+w,go+x'
or `675' if you're bit-oriented. The `ls -l' notation has the drawback
that you have not only to precise the modes the file have, but also the
modes the file doesn't have.
But of course, if there're people that actually want to use that, we can
add it I guess.
--
| Michaël `Micha' Cadilhac | Le copillage-collage |
| http://michael.cadilhac.name | tue le programmeur. |
| JID/MSN: | -- Dictons LRDE |
`---- michael.cadilhac@gmail.com | - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 1:31 ` Juri Linkov
@ 2008-02-17 2:04 ` Michaël Cadilhac
2008-02-17 2:21 ` Miles Bader
2008-02-17 21:54 ` Juri Linkov
0 siblings, 2 replies; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-17 2:04 UTC (permalink / raw)
To: Juri Linkov; +Cc: Dan Nicolaescu, emacs-devel, Miles Bader
[-- Attachment #1: Type: text/plain, Size: 1710 bytes --]
Juri Linkov <juri@jurta.org> writes:
>> Soooo, why not convert it to an appropriate "input form" for putting in
>> the prompt/default ?
>>
>> E.g., -rwxrwxrw- => "ug=rwx,o=rw"
As I said to Dan before, I think symbolic notation is about applying a
mask to the existing file's modes, not editing them. Of course, after
`u=rwx,g=rwx,o=rw' I can (more or less comfortably) add my mask `,a-w',
but still, I don't see any case when I'd want to *edit* modes.
> That would be nice, maybe with separating every part even with the same
> permissions, e.g. "u=rwx,g=rwx,o=rw" for less editing when the user and
> group part need different permissions.
Well, what if I need to remove writing rights for everybody? There's
no canonical notation (why not `ugo=rw,ug+x', or `ugo=rwx,o-x'?), and
it'd be painful for the user to first read the mode to see if it fits
his needs, modify them if it's the case or apply a `,a-w' mask after if
it isn't.
I'm pretty much convinced we should not take an arbitrary decision
about that canonical form (the only canonical form I can think of is the
octal version). Well, all this is my own point of view: when I want to
remove write rights for everyone, I think about `a-w', not about going
through a description and editing it.
But again, if enough people think it could be useful, there's no
problem adding it.
--
| Michaël `Micha' Cadilhac | 21 seems like a good value: half of |
| http://michael.cadilhac.name | of 42 and just old enough to drink! |
| JID/MSN: | Why would you want to change it? |
`---- michael.cadilhac@gmail.com | -- Stefan Monnier - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 2:04 ` Michaël Cadilhac
@ 2008-02-17 2:21 ` Miles Bader
2008-02-17 21:54 ` Juri Linkov
1 sibling, 0 replies; 19+ messages in thread
From: Miles Bader @ 2008-02-17 2:21 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Juri Linkov, Dan Nicolaescu, emacs-devel
michael@cadilhac.name (Michaël Cadilhac) writes:
>> That would be nice, maybe with separating every part even with the same
>> permissions, e.g. "u=rwx,g=rwx,o=rw" for less editing when the user and
>> group part need different permissions.
>
> Well, what if I need to remove writing rights for everybody? There's
> no canonical notation (why not `ugo=rw,ug+x', or `ugo=rwx,o-x'?), and
> it'd be painful for the user to first read the mode to see if it fits
> his needs, modify them if it's the case or apply a `,a-w' mask after if
> it isn't.
Geez, don't over-complicate things.
There's a perfectly good symbolic mode-input notation, easy to use and
easy enough to parse, we should use it. If we want to restrict it to
the absolute forms (using "=", not + or -) for simplicity, that's fine
too.
-Miles
--
Defenceless, adj. Unable to attack.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 1:39 ` Michaël Cadilhac
@ 2008-02-17 20:29 ` Richard Stallman
2008-02-18 3:01 ` Michaël Cadilhac
2008-02-17 21:55 ` Juri Linkov
1 sibling, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2008-02-17 20:29 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: juri, dann, emacs-devel
> The standard convention when reading a value in the minibuffer is to put
> the default value in the prompt and make it available for editing by
> M-n.
First, if we have three different notations, why this one should be
preferred as the default one?
Because I made the decision that way. This is a general policy
I have adopted for Emacs.
What format the input should have is a separate question.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 2:04 ` Michaël Cadilhac
2008-02-17 2:21 ` Miles Bader
@ 2008-02-17 21:54 ` Juri Linkov
1 sibling, 0 replies; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 21:54 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Dan Nicolaescu, emacs-devel, Miles Bader
>>> Soooo, why not convert it to an appropriate "input form" for putting in
>>> the prompt/default ?
>>>
>>> E.g., -rwxrwxrw- => "ug=rwx,o=rw"
>
> As I said to Dan before, I think symbolic notation is about applying a
> mask to the existing file's modes, not editing them. Of course, after
> `u=rwx,g=rwx,o=rw' I can (more or less comfortably) add my mask `,a-w',
> but still, I don't see any case when I'd want to *edit* modes.
You don't need to add a mask `,a-w' after `u=rwx,g=rwx,o=rw',
because unless you want to retrieve the default value `u=rwx,g=rwx,o=rw'
for editing, you can start typing `a-w' in the empty minibuffer.
Typing M-n in the minibuffer to retrieve the default value is intended
only for users who what to edit the existing permissions based on
the absolute forms using "=".
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 1:39 ` Michaël Cadilhac
2008-02-17 20:29 ` Richard Stallman
@ 2008-02-17 21:55 ` Juri Linkov
2008-02-17 22:18 ` Miles Bader
1 sibling, 1 reply; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 21:55 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: Dan Nicolaescu, emacs-devel
>> The standard convention when reading a value in the minibuffer is to put
>> the default value in the prompt and make it available for editing by
>> M-n.
>
> First, if we have three different notations, why this one should be
> preferred as the default one?
There is no need to prefer only one notation because there can be more
than one default notation.
>> When the permission bits are retrieved in such notation from the default
>> value then editing them is just like toggling that is convenient.
>
> Second, from `-------' to `-rw-rwxr-x', there is 5 times `space' and
> three `right' when we talk about toggling, while it's `right, C-d, r,
> C-d, w, right, C-d, r, C-d, w, C-d, x, C-d, r, right, C-d, x' when
> editing, which is a lot more cumbersome. And typing `-rw-rwxr-x'
> (which, you'd agree, is not natural) is best replaced by `a+r,ug+w,go+x'
> or `675' if you're bit-oriented. The `ls -l' notation has the drawback
> that you have not only to precise the modes the file have, but also the
> modes the file doesn't have.
`-rw-rwxr-x' seems easier to type than `a+r,ug+w,go+x' but we don't need
decide what notation is preferable as we can support all of them.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-18 3:01 ` Michaël Cadilhac
@ 2008-02-17 21:57 ` Juri Linkov
0 siblings, 0 replies; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 21:57 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: dann, rms, emacs-devel
>> What format the input should have is a separate question.
>
> My question was about the three different notations for file modes, and
> why this one (-rwxrwx-wx) should be preferred as the one to express the
> default value. I wasn't questioning the way values are entered in the
> minibuffer at all. I was referring to what you call the format.
We can add the existing permissions in all three notations to the list
of minibuffer default values, so the user could relieve them by using M-n
for editing, or type a new one without retrieving the default values.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 21:55 ` Juri Linkov
@ 2008-02-17 22:18 ` Miles Bader
2008-02-17 22:59 ` Juri Linkov
0 siblings, 1 reply; 19+ messages in thread
From: Miles Bader @ 2008-02-17 22:18 UTC (permalink / raw)
To: Juri Linkov; +Cc: Nicolaescu, Michaël Cadilhac, emacs-devel
Juri Linkov <juri@jurta.org> writes:
> `-rw-rwxr-x' seems easier to type than `a+r,ug+w,go+x'
You needn't type that, of course; I'd probably use "ug=rwx,o=rx".
Familiar, easy to type, and to understand.
> but we don't need decide what notation is preferable as we can
> support all of them.
Why complicate the code to support the "-rw-rwxr-x" format though? It's
not used by any other software, and offers no obvious advantage in
usability.
-Miles
--
Idiot, n. A member of a large and powerful tribe whose influence in human
affairs has always been dominant and controlling.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 22:18 ` Miles Bader
@ 2008-02-17 22:59 ` Juri Linkov
0 siblings, 0 replies; 19+ messages in thread
From: Juri Linkov @ 2008-02-17 22:59 UTC (permalink / raw)
To: Miles Bader; +Cc: Nicolaescu, Michaël Cadilhac, emacs-devel
>> `-rw-rwxr-x' seems easier to type than `a+r,ug+w,go+x'
>
> You needn't type that, of course; I'd probably use "ug=rwx,o=rx".
> Familiar, easy to type, and to understand.
>
>> but we don't need decide what notation is preferable as we can
>> support all of them.
>
> Why complicate the code to support the "-rw-rwxr-x" format though? It's
> not used by any other software, and offers no obvious advantage in
> usability.
The only software I know that supports reading the "-rw-rwxr-x" format is
Wdired. Supporting it in set-file-modes is not very necessary, but the
problem came from the patch proposed by Michaël where the prompt is
displayed as:
File modes, octal or symbolic (current: -r-xrw---):
The string inside parentheses before the colon looks very like the default
value, so it invites the user to type a new value in the same format.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 20:29 ` Richard Stallman
@ 2008-02-18 3:01 ` Michaël Cadilhac
2008-02-17 21:57 ` Juri Linkov
0 siblings, 1 reply; 19+ messages in thread
From: Michaël Cadilhac @ 2008-02-18 3:01 UTC (permalink / raw)
To: rms; +Cc: juri, dann, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
Richard Stallman <rms@gnu.org> writes:
> > The standard convention when reading a value in the minibuffer is to put
> > the default value in the prompt and make it available for editing by
> > M-n.
>
> First, if we have three different notations, why this one should be
> preferred as the default one?
>
> Because I made the decision that way. This is a general policy
> I have adopted for Emacs.
>
> What format the input should have is a separate question.
My question was about the three different notations for file modes, and
why this one (-rwxrwx-wx) should be preferred as the one to express the
default value. I wasn't questioning the way values are entered in the
minibuffer at all. I was referring to what you call the format.
--
| Michaël `Micha' Cadilhac | La culture c'est comme la confiture, |
| http://michael.cadilhac.name | c'est meilleur avec du pain. |
| JID/MSN: | -- MOI59 |
`---- michael.cadilhac@gmail.com | - --'
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: suggestion for set-file-modes
2008-02-17 1:08 ` Miles Bader
2008-02-17 1:31 ` Juri Linkov
@ 2008-07-29 17:43 ` Juri Linkov
1 sibling, 0 replies; 19+ messages in thread
From: Juri Linkov @ 2008-07-29 17:43 UTC (permalink / raw)
To: emacs-devel
>> The standard convention when reading a value in the minibuffer is to put
>> the default value in the prompt and make it available for editing by M-n.
>> When the permission bits are retrieved in such notation from the default
>> value then editing them is just like toggling that is convenient.
>
> Soooo, why not convert it to an appropriate "input form" for putting in
> the prompt/default ?
>
> E.g., -rwxrwxrw- => "ug=rwx,o=rw"
>
> That has the advantage that such "input forms" are a bit more robust,
> because they aren't fixed-width with position-senstive fields. They're
> also somewhat more self-documenting.
>
> [Also, of course, it's more consistent with other programs, none of
> which use the "ls forms" for input.]
>
> It shouldn't be very hard to do.
It seems there was consensus on the notation proposed by Miles.
The following patch implements it by adding the absolute mode form "=" to
the minibuffer's default value in `read-file-modes' and `dired-do-chmod'.
It requires adding a new arg `default' to `dired-mark-read-string'
(similar to `dired-mark-read-file-name' that already has the last
argument `default').
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.987
diff -c -r1.987 files.el
*** lisp/files.el 11 Jul 2008 23:08:07 -0000 1.987
--- lisp/files.el 29 Jul 2008 17:38:51 -0000
***************
*** 5786,5792 ****
ORIG-FILE is the original file of which modes will be change."
(let* ((modes (or (if orig-file (file-modes orig-file) 0)
(error "File not found")))
! (value (read-string (or prompt "File modes (octal or symbolic): "))))
(save-match-data
(if (string-match "^[0-7]+" value)
(string-to-number value 8)
--- 5786,5804 ----
ORIG-FILE is the original file of which modes will be change."
(let* ((modes (or (if orig-file (file-modes orig-file) 0)
(error "File not found")))
! (modestr (and (stringp orig-file)
! (nth 8 (file-attributes orig-file))))
! (default
! (and (stringp modestr)
! (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
! (replace-regexp-in-string
! "-" ""
! (format "u=%s,g=%s,o=%s"
! (match-string 1 modestr)
! (match-string 2 modestr)
! (match-string 3 modestr)))))
! (value (read-string (or prompt "File modes (octal or symbolic): ")
! nil nil default)))
(save-match-data
(if (string-match "^[0-7]+" value)
(string-to-number value 8)
Index: lisp/dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.175
diff -c -r1.175 dired-aux.el
*** lisp/dired-aux.el 29 Jul 2008 16:36:42 -0000 1.175
--- lisp/dired-aux.el 29 Jul 2008 17:37:42 -0000
***************
*** 255,263 ****
Symbolic modes like `g+w' are allowed."
(interactive "P")
(let* ((files (dired-get-marked-files t arg))
(modes (dired-mark-read-string
"Change mode of %s to: " nil
! 'chmod arg files))
(num-modes (if (string-match "^[0-7]+" modes)
(string-to-number modes 8))))
(dolist (file files)
--- 255,274 ----
Symbolic modes like `g+w' are allowed."
(interactive "P")
(let* ((files (dired-get-marked-files t arg))
+ (modestr (and (stringp (car files))
+ (nth 8 (file-attributes (car files)))))
+ (default
+ (and (stringp modestr)
+ (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
+ (replace-regexp-in-string
+ "-" ""
+ (format "u=%s,g=%s,o=%s"
+ (match-string 1 modestr)
+ (match-string 2 modestr)
+ (match-string 3 modestr)))))
(modes (dired-mark-read-string
"Change mode of %s to: " nil
! 'chmod arg files default))
(num-modes (if (string-match "^[0-7]+" modes)
(string-to-number modes 8))))
(dolist (file files)
***************
*** 358,371 ****
;; If the current file was used, the list has but one element and ARG
;; does not matter. (It is non-nil, non-integer in that case, namely '(4)).
! (defun dired-mark-read-string (prompt initial op-symbol arg files)
! ;; PROMPT for a string, with INITIAL input.
;; Other args are used to give user feedback and pop-up:
;; OP-SYMBOL of command, prefix ARG, marked FILES.
(dired-mark-pop-up
nil op-symbol files
(function read-string)
! (format prompt (dired-mark-prompt arg files)) initial))
\f
;;; Cleaning a directory: flagging some backups for deletion.
--- 369,382 ----
;; If the current file was used, the list has but one element and ARG
;; does not matter. (It is non-nil, non-integer in that case, namely '(4)).
! (defun dired-mark-read-string (prompt initial op-symbol arg files &optional default)
! ;; PROMPT for a string, with INITIAL input and DEFAULT value.
;; Other args are used to give user feedback and pop-up:
;; OP-SYMBOL of command, prefix ARG, marked FILES.
(dired-mark-pop-up
nil op-symbol files
(function read-string)
! (format prompt (dired-mark-prompt arg files)) initial nil default))
\f
;;; Cleaning a directory: flagging some backups for deletion.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2008-07-29 17:43 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200801201812.m0KICxYl009632@sallyv1.ics.uci.edu>
[not found] ` <871w7jqiic.fsf@cadilhac.name>
[not found] ` <200802112200.m1BM0pke028675@sallyv1.ics.uci.edu>
2008-02-11 23:41 ` suggestion for set-file-modes Michaël Cadilhac
2008-02-16 19:19 ` Juri Linkov
2008-02-16 23:07 ` Michaël Cadilhac
2008-02-16 23:27 ` Juri Linkov
2008-02-17 0:14 ` Michaël Cadilhac
2008-02-17 0:48 ` Juri Linkov
2008-02-17 1:08 ` Miles Bader
2008-02-17 1:31 ` Juri Linkov
2008-02-17 2:04 ` Michaël Cadilhac
2008-02-17 2:21 ` Miles Bader
2008-02-17 21:54 ` Juri Linkov
2008-07-29 17:43 ` Juri Linkov
2008-02-17 1:39 ` Michaël Cadilhac
2008-02-17 20:29 ` Richard Stallman
2008-02-18 3:01 ` Michaël Cadilhac
2008-02-17 21:57 ` Juri Linkov
2008-02-17 21:55 ` Juri Linkov
2008-02-17 22:18 ` Miles Bader
2008-02-17 22:59 ` Juri Linkov
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).