all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Interactive specs of C functions.
@ 2007-09-07 14:58 Michaël Cadilhac
  2007-09-07 18:01 ` Stefan Monnier
  2007-09-08  7:01 ` Richard Stallman
  0 siblings, 2 replies; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-07 14:58 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1129 bytes --]

In the thread http://thread.gmane.org/gmane.emacs.devel/44339 (starting
with <87hdbdxo94.fsf@mahaena.lrde>) we discussed ways to add interactive
specs to a C function.

Kim F. Storm proposed good-looking solutions, but they were discarded
because the specs were specified in another file, or something like
that.  It wasn't clear if it really was a bad idea (in fact, I liked
it ;-)) but AFAICS, the problem is still there.

The last patch he proposed was in <m3ll0i568y.fsf@kfs-l.imdomain.dk>
(but this one accepts that two aliases have different interactive specs,
and RMS didn't like that.)

The starting point of this thread was to turn set-file-modes interactive
so that it can call an annex Lisp function to translate "a+rx"
to... well, numeric.


Can we think about that now?

-- 
 |   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 #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-07 14:58 Interactive specs of C functions Michaël Cadilhac
@ 2007-09-07 18:01 ` Stefan Monnier
  2007-09-07 21:52   ` Johan Bockgård
  2007-09-08  7:01 ` Richard Stallman
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2007-09-07 18:01 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-devel

> In the thread http://thread.gmane.org/gmane.emacs.devel/44339 (starting
> with <87hdbdxo94.fsf@mahaena.lrde>) we discussed ways to add interactive
> specs to a C function.

Check etc/NEWS:

** The interactive-form of a function can be added post-facto via the
`interactive-form' symbol property.  Mostly useful to add complex interactive
forms to subroutines.


        Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-07 18:01 ` Stefan Monnier
@ 2007-09-07 21:52   ` Johan Bockgård
  2007-09-08  2:18     ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Johan Bockgård @ 2007-09-07 21:52 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Check etc/NEWS:
>
> ** The interactive-form of a function can be added post-facto via the
> `interactive-form' symbol property.  Mostly useful to add complex interactive
> forms to subroutines.

The current implementation doesn't work for subrs/compiled functions
though.


[Fcall_interactively]

    if (SUBRP (fun))
        ...
    else if (COMPILEDP (fun))
        ...
    else
        <---- `Finteractive_form' is only called on this branch

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-07 21:52   ` Johan Bockgård
@ 2007-09-08  2:18     ` Stefan Monnier
  2007-09-08 19:48       ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2007-09-08  2:18 UTC (permalink / raw)
  To: emacs-devel

>> ** The interactive-form of a function can be added post-facto via the
>> `interactive-form' symbol property.  Mostly useful to add complex interactive
>> forms to subroutines.

> The current implementation doesn't work for subrs/compiled functions
> though.


> [Fcall_interactively]

>     if (SUBRP (fun))
>         ...
>     else if (COMPILEDP (fun))
>         ...
>     else
>         <---- `Finteractive_form' is only called on this branch

Indeed.  How 'bout the patch below?


        Stefan


--- orig/src/callint.c
+++ mod/src/callint.c
@@ -331,22 +331,6 @@
   /* Decode the kind of function.  Either handle it and return,
      or go to `lose' if not interactive, or set either STRING or SPECS.  */
 
-  if (SUBRP (fun))
-    {
-      string = (unsigned char *) XSUBR (fun)->prompt;
-      if (!string)
-	{
-	lose:
-	  wrong_type_argument (Qcommandp, function);
-	}
-    }
-  else if (COMPILEDP (fun))
-    {
-      if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_INTERACTIVE)
-	goto lose;
-      specs = AREF (fun, COMPILED_INTERACTIVE);
-    }
-  else
     {
       Lisp_Object form;
       GCPRO2 (function, prefix_arg);
@@ -355,7 +339,7 @@
       if (CONSP (form))
 	specs = filter_specs = Fcar (XCDR (form));
       else
-	goto lose;
+      wrong_type_argument (Qcommandp, function);
     }
 
   /* If either SPECS or STRING is set to a string, use it.  */

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-07 14:58 Interactive specs of C functions Michaël Cadilhac
  2007-09-07 18:01 ` Stefan Monnier
@ 2007-09-08  7:01 ` Richard Stallman
  2007-09-08  9:06   ` Michaël Cadilhac
  1 sibling, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2007-09-08  7:01 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-devel

    Kim F. Storm proposed good-looking solutions, but they were discarded
    because the specs were specified in another file, or something like
    that.  It wasn't clear if it really was a bad idea (in fact, I liked
    it=A0;-)) but AFAICS, the problem is still there.

An idea that occurs to me: if the interactive string of a subr starts
with `(', read it to get a sexp and then eval that sexp.

This way, we could write the expression in the C function definition.
It may require some inconvenient quoting, but it's still better
than having the sexp in another file.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-08  7:01 ` Richard Stallman
@ 2007-09-08  9:06   ` Michaël Cadilhac
       [not found]     ` <E1IUCIK-0008Ck-2z@fencepost.gnu.org>
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-08  9:06 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 261 bytes --]

Richard Stallman <rms@gnu.org> writes:

> An idea that occurs to me: if the interactive string of a subr starts
> with `(', read it to get a sexp and then eval that sexp.

This would be cool indeed!  Something like that?  (fileio.c is changed
for the example)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: c-interactive.patch --]
[-- Type: text/x-patch, Size: 1669 bytes --]

? keyboard.c.M-o
Index: callint.c
===================================================================
RCS file: /sources/emacs/emacs/src/callint.c,v
retrieving revision 1.153
diff -c -B -w -r1.153 callint.c
*** callint.c	26 Jul 2007 05:27:48 -0000	1.153
--- callint.c	8 Sep 2007 09:05:34 -0000
***************
*** 340,345 ****
--- 340,353 ----
  	lose:
  	  wrong_type_argument (Qcommandp, function);
  	}
+       /* The function has an interactive spec to evaluate.  */
+       if (*string == '(')
+ 	{
+ 	  specs =
+ 	    Fcar (Fread_from_string (make_string (string, strlen (string)),
+ 				     Qnil, Qnil));
+ 	  string = 0;
+ 	}
      }
    else if (COMPILEDP (fun))
      {
Index: fileio.c
===================================================================
RCS file: /sources/emacs/emacs/src/fileio.c,v
retrieving revision 1.588
diff -c -B -w -r1.588 fileio.c
*** fileio.c	13 Aug 2007 13:41:17 -0000	1.588
--- fileio.c	8 Sep 2007 09:05:36 -0000
***************
*** 3433,3439 ****
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, 0,
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)
--- 3433,3441 ----
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2,
!        "(list (read-file-name \"File: \") \
! 	      (read-number \"Modes: \"))",
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)

[-- Attachment #1.1.3: Type: text/plain, Size: 327 bytes --]


-- 
 |   Michaël `Micha' Cadilhac       |  I cannot reproduce this bug,          |
 |   http://michael.cadilhac.name   |    but I have installed a change       |
 |   JID/MSN:                       |      which I think will fix it.        |
 `----  michael.cadilhac@gmail.com  |          -- Kim F. Storm          -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-08  2:18     ` Stefan Monnier
@ 2007-09-08 19:48       ` Richard Stallman
  2007-09-09 20:45         ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2007-09-08 19:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

    Indeed.  How 'bout the patch below?

    -  if (SUBRP (fun))
    -    {
    -      string = (unsigned char *) XSUBR (fun)->prompt;
    -      if (!string)
    -	{
    -	lose:
    -	  wrong_type_argument (Qcommandp, function);
    -	}

That would be a slowdown in very important cases.  It would be better
to keep that code, but have it fall through when it doesn't find an
interactive string in the special way, into the general case.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-08 19:48       ` Richard Stallman
@ 2007-09-09 20:45         ` Stefan Monnier
  2007-09-10  1:13           ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2007-09-09 20:45 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>     Indeed.  How 'bout the patch below?
>     -  if (SUBRP (fun))
>     -    {
>     -      string = (unsigned char *) XSUBR (fun)->prompt;
>     -      if (!string)
>     -	{
>     -	lose:
>     -	  wrong_type_argument (Qcommandp, function);
>     -	}

> That would be a slowdown in very important cases.

Finteractive_form takes an absolutely negligible amount of time.  So I have
no idea what you mean by "a slowdown".  The only "problem" I could imagine
is that Finteractive_form allocates a Lisp string whereas the above code
doesn't.  It's easy to work around it: make an `interactive_form' function
(used by Finteractive_form') which takes an additional char** argument into
which it can return the C string so as to avoid allocating the Lisp string
when called from Fcall_interactively.

> It would be better to keep that code, but have it fall through when it
> doesn't find an interactive string in the special way, into the
> general case.

That would prevent overriding a pre-existing interactive form.


        Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
       [not found]     ` <E1IUCIK-0008Ck-2z@fencepost.gnu.org>
@ 2007-09-09 20:46       ` Michaël Cadilhac
  2007-09-09 21:19         ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-09 20:46 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 281 bytes --]

Richard Stallman <rms@gnu.org> writes:

> Your change in callint.c is the right idea.  How about writing
> documentation and then installing it in the trunk?

I made the doc change in lisp.h, and renamed the `prompt' field of the
Lisp_Subr struct to `intspec' (interactive spec):


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: callint.patch --]
[-- Type: text/x-patch, Size: 6270 bytes --]

Index: lisp.h
===================================================================
RCS file: /sources/emacs/emacs/src/lisp.h,v
retrieving revision 1.583
diff -c -r1.583 lisp.h
*** lisp.h	29 Aug 2007 21:50:08 -0000	1.583
--- lisp.h	9 Sep 2007 20:37:51 -0000
***************
*** 891,897 ****
      Lisp_Object (*function) ();
      short min_args, max_args;
      char *symbol_name;
!     char *prompt;
      char *doc;
    };
  
--- 891,897 ----
      Lisp_Object (*function) ();
      short min_args, max_args;
      char *symbol_name;
!     char *intspec;
      char *doc;
    };
  
***************
*** 1669,1698 ****
  	 followed by the address of a vector of Lisp_Objects
  	 which contains the argument values.
      UNEVALLED means pass the list of unevaluated arguments
!  `prompt' says how to read arguments for an interactive call.
!     See the doc string for `interactive'.
      A null string means call interactively with no arguments.
   `doc' is documentation for the user.  */
  
  #if (!defined (__STDC__) && !defined (PROTOTYPES)) \
      || defined (USE_NONANSI_DEFUN)
  
! #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc)	\
    Lisp_Object fnname ();						\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, prompt, 0};			\
    Lisp_Object fnname
  
  #else
  
  /* This version of DEFUN declares a function prototype with the right
     arguments, so we can catch errors with maxargs at compile-time.  */
! #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc)	\
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;				\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, prompt, 0};			\
    Lisp_Object fnname
  
  /* Note that the weird token-substitution semantics of ANSI C makes
--- 1669,1701 ----
  	 followed by the address of a vector of Lisp_Objects
  	 which contains the argument values.
      UNEVALLED means pass the list of unevaluated arguments
!  `intspec' says how interactive arguments are to be fetched.
!     If the string starts with a `(', `intspec' is evaluated and the resulting
!     list is the list of arguments.
!     If it's a string that doesn't start with `(', the value should follow
!     the one of the doc string for `interactive'.
      A null string means call interactively with no arguments.
   `doc' is documentation for the user.  */
  
  #if (!defined (__STDC__) && !defined (PROTOTYPES)) \
      || defined (USE_NONANSI_DEFUN)
  
! #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)	\
    Lisp_Object fnname ();						\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, intspec, 0};			\
    Lisp_Object fnname
  
  #else
  
  /* This version of DEFUN declares a function prototype with the right
     arguments, so we can catch errors with maxargs at compile-time.  */
! #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)	\
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;				\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, intspec, 0};			\
    Lisp_Object fnname
  
  /* Note that the weird token-substitution semantics of ANSI C makes
Index: callint.c
===================================================================
RCS file: /sources/emacs/emacs/src/callint.c,v
retrieving revision 1.154
diff -c -r1.154 callint.c
*** callint.c	29 Aug 2007 05:27:56 -0000	1.154
--- callint.c	9 Sep 2007 20:37:52 -0000
***************
*** 334,345 ****
  
    if (SUBRP (fun))
      {
!       string = (unsigned char *) XSUBR (fun)->prompt;
        if (!string)
  	{
  	lose:
  	  wrong_type_argument (Qcommandp, function);
  	}
      }
    else if (COMPILEDP (fun))
      {
--- 334,353 ----
  
    if (SUBRP (fun))
      {
!       string = (unsigned char *) XSUBR (fun)->intspec;
        if (!string)
  	{
  	lose:
  	  wrong_type_argument (Qcommandp, function);
  	}
+       /* The function has an interactive spec to evaluate.  */
+       if (*string == '(')
+ 	{
+ 	  specs =
+ 	    Fcar (Fread_from_string (make_string (string, strlen (string)),
+ 				     Qnil, Qnil));
+ 	  string = 0;
+ 	}
      }
    else if (COMPILEDP (fun))
      {
Index: data.c
===================================================================
RCS file: /sources/emacs/emacs/src/data.c,v
retrieving revision 1.277
diff -c -r1.277 data.c
*** data.c	29 Aug 2007 05:27:58 -0000	1.277
--- data.c	9 Sep 2007 20:37:53 -0000
***************
*** 770,777 ****
  
    if (SUBRP (fun))
      {
!       if (XSUBR (fun)->prompt)
! 	return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
      }
    else if (COMPILEDP (fun))
      {
--- 770,777 ----
  
    if (SUBRP (fun))
      {
!       if (XSUBR (fun)->intspec)
! 	return list2 (Qinteractive, build_string (XSUBR (fun)->intspec));
      }
    else if (COMPILEDP (fun))
      {
Index: eval.c
===================================================================
RCS file: /sources/emacs/emacs/src/eval.c,v
retrieving revision 1.287
diff -c -r1.287 eval.c
*** eval.c	29 Aug 2007 05:27:57 -0000	1.287
--- eval.c	9 Sep 2007 20:37:54 -0000
***************
*** 2078,2084 ****
    /* Emacs primitives are interactive if their DEFUN specifies an
       interactive spec.  */
    if (SUBRP (fun))
!     return XSUBR (fun)->prompt ? Qt : if_prop;
  
    /* Bytecode objects are interactive if they are long enough to
       have an element whose index is COMPILED_INTERACTIVE, which is
--- 2078,2084 ----
    /* Emacs primitives are interactive if their DEFUN specifies an
       interactive spec.  */
    if (SUBRP (fun))
!     return XSUBR (fun)->intspec ? Qt : if_prop;
  
    /* Bytecode objects are interactive if they are long enough to
       have an element whose index is COMPILED_INTERACTIVE, which is

[-- Attachment #1.1.3: Type: text/plain, Size: 288 bytes --]


> As for Fset_file_modes, if we want to make it interactive it really
> should handle chmod-style args to specify the modes, not just numbers.

I revamped the code I first proposed (which was my very first proposal
to Emacs! :-)), here are the changes to files.el and fileio.c :


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.4: chmod.patch --]
[-- Type: text/x-patch, Size: 5487 bytes --]

Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.927
diff -c -B -w -r1.927 files.el
*** lisp/files.el	31 Aug 2007 13:29:34 -0000	1.927
--- lisp/files.el	9 Sep 2007 20:42:43 -0000
***************
*** 5407,5412 ****
--- 5407,5503 ----
  	  (t
  	   (apply operation arguments)))))
  
+ \f
+ ;; Symbolic modes and read-file-modes.
+ 
+ (defun char-to-who (char)
+   "Convert CHAR to a who-mask from a symbolic mode notation.
+ CHAR is in [ugoa] and represents the users on which rights are applied."
+   (cond ((= char ?u) #o4700)
+ 	((= char ?g) #o2070)
+ 	((= char ?o) #o1007)
+ 	((= char ?a) #o7777)
+ 	(t (error "%c: bad `who' character" char))))
+ 
+ (defun char-to-right (char &optional from)
+   "Convert CHAR to a right-mask from a symbolic mode notation.
+ CHAR is in [rwxXstugo] and represents a right.
+ If CHAR is in [Xugo], the value is extracted from FROM (or 0 if nil)."
+   (or from (setq from 0))
+   (cond ((= char ?r) #o0444)
+ 	((= char ?w) #o0222)
+ 	((= char ?x) #o0111)
+ 	((= char ?s) #o1000)
+ 	((= char ?t) #o6000)
+ 	;; Rights relative to the previous file modes.
+ 	((= char ?X) (if (= (logand from #o111) 0) 0 #o0111))
+ 	((= char ?u) (let ((uright (logand #o4700 from)))
+ 		       (+ uright (/ uright #o10) (/ uright #o100))))
+ 	((= char ?g) (let ((gright (logand #o2070 from)))
+ 		       (+ gright (/ gright #o10) (* gright #o10))))
+ 	((= char ?o) (let ((oright (logand #o1007 from)))
+ 		       (+ oright (* oright #o10) (* oright #o100))))
+ 	(t (error "%c: bad right character" char))))
+ 
+ (defun right-string-to-number (rights who-mask &optional from)
+   "Convert a right string to a right-mask from a symbolic modes notation.
+ RIGHTS is the right string, it should match \"([+=-][rwxXstugo]+)+\".
+ WHO-MASK is the mask number of the users on which the rights are to be applied.
+ FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed."
+   (let* ((num-rights (or from 0))
+ 	 (list-rights (string-to-list rights))
+ 	 (op (pop list-rights)))
+     (while (memq op '(?+ ?- ?=))
+       (let ((num-right 0)
+ 	    char-right)
+ 	(while (memq (setq char-right (pop list-rights))
+ 		     '(?r ?w ?x ?X ?s ?t ?u ?g ?o))
+ 	  (setq num-right
+ 		(logior num-right (char-to-right char-right num-rights))))
+ 	(setq num-right (logand who-mask num-right)
+ 	      num-rights
+ 	      (cond ((= op ?+) (logior num-rights num-right))
+ 		    ((= op ?-) (logand num-rights (lognot num-right)))
+ 		    (t (logior (logand num-rights (lognot who-mask)) num-right)))
+ 	      op char-right)))
+     num-rights))
+ 
+ (defun symbolic-file-modes-to-number (modes &optional from)
+   "Convert symbolic file modes to numeric file modes.
+ MODES is the string to convert, it should match
+ \"[ugoa]*([+-=][rwxXstugo]+)+,...\".
+ See (info \"(coreutils)File permissions\") for more information on this
+ notation.
+ FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed."
+   (save-match-data
+     (let ((case-fold-search nil)
+ 	  (num-modes (or from 0)))
+       (while (/= (string-to-char modes) 0)
+ 	(if (string-match "^\\([ugoa]*\\)\\([+=-][rwxXstugo]+\\)+\\(,\\|\\)" modes)
+ 	    (let ((num-who (apply 'logior 0
+ 				  (mapcar 'char-to-who (match-string 1 modes)))))
+ 	      (when (= num-who 0)
+ 		(setq num-who (default-file-modes)))
+ 	      (setq num-modes
+ 		    (right-string-to-number (substring modes (match-end 1))
+ 					    num-who num-modes)
+ 		    modes (substring modes (match-end 3))))
+ 	  (error "Parse error in modes near %s" (substring modes 0))))
+       num-modes)))
+ 
+ (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."
+   (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)
+ 	(symbolic-file-modes-to-number value modes)))))
+ 
+ \f
  (define-key ctl-x-map "\C-f" 'find-file)
  (define-key ctl-x-map "\C-r" 'find-file-read-only)
  (define-key ctl-x-map "\C-v" 'find-alternate-file)
Index: src/fileio.c
===================================================================
RCS file: /sources/emacs/emacs/src/fileio.c,v
retrieving revision 1.590
diff -c -B -w -r1.590 fileio.c
*** src/fileio.c	29 Aug 2007 05:27:58 -0000	1.590
--- src/fileio.c	9 Sep 2007 20:42:46 -0000
***************
*** 3435,3441 ****
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, 0,
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)
--- 3435,3443 ----
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2,
!        "(let ((file (read-file-name \"File: \")))			\
! 	  (list file (read-file-modes nil file)))",
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)

[-- Attachment #1.1.5: Type: text/plain, Size: 109 bytes --]


And why not change dired-do-chmod to use set-file-modes together with
the symbolic mode parsing functions?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.6: dired.patch --]
[-- Type: text/x-patch, Size: 1370 bytes --]

Index: lisp/dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.154
diff -c -r1.154 dired-aux.el
*** lisp/dired-aux.el	13 Aug 2007 13:41:07 -0000	1.154
--- lisp/dired-aux.el	9 Sep 2007 20:23:25 -0000
***************
*** 253,261 ****
  ;;;###autoload
  (defun dired-do-chmod (&optional arg)
    "Change the mode of the marked (or next ARG) files.
! This calls chmod, thus symbolic modes like `g+w' are allowed."
    (interactive "P")
!   (dired-do-chxxx "Mode" dired-chmod-program 'chmod arg))
  
  ;;;###autoload
  (defun dired-do-chgrp (&optional arg)
--- 253,272 ----
  ;;;###autoload
  (defun dired-do-chmod (&optional arg)
    "Change the mode of the marked (or next ARG) files.
! 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)
!       (set-file-modes
!        file
!        (if num-modes num-modes
! 	 (symbolic-file-modes-to-number modes (file-modes file)))))
!     (dired-do-redisplay arg)))
  
  ;;;###autoload
  (defun dired-do-chgrp (&optional arg)

[-- Attachment #1.1.7: Type: text/plain, Size: 327 bytes --]


-- 
 |   Michaël `Micha' Cadilhac       |   An error can become exact            |
 |   http://michael.cadilhac.name   |     as the one who committed it        |
 |   JID/MSN:                       |  made a mistake or not.                |
 `----  michael.cadilhac@gmail.com  |          -- Pierre Dac            -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-09 20:46       ` Michaël Cadilhac
@ 2007-09-09 21:19         ` Stefan Monnier
  2007-09-09 22:34           ` Michaël Cadilhac
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2007-09-09 21:19 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: rms, emacs-devel

> ***************
> *** 770,777 ****
  
>     if (SUBRP (fun))
>       {
> !       if (XSUBR (fun)->prompt)
> ! 	return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
>       }
>     else if (COMPILEDP (fun))
>       {
> --- 770,777 ----
  
>     if (SUBRP (fun))
>       {
> !       if (XSUBR (fun)->intspec)
> ! 	return list2 (Qinteractive, build_string (XSUBR (fun)->intspec));
>       }
>     else if (COMPILEDP (fun))
>       {

This doesn't look right.  It should do the Fread_from_string thingy as well.

> + (defun char-to-who (char)
> +   "Convert CHAR to a who-mask from a symbolic mode notation.
> + CHAR is in [ugoa] and represents the users on which rights are applied."
[...]
> + (defun char-to-right (char &optional from)
> +   "Convert CHAR to a right-mask from a symbolic mode notation.
> + CHAR is in [rwxXstugo] and represents a right.
> + If CHAR is in [Xugo], the value is extracted from FROM (or 0 if nil)."
[...]
> + (defun right-string-to-number (rights who-mask &optional from)
> +   "Convert a right string to a right-mask from a symbolic modes notation.
> + RIGHTS is the right string, it should match \"([+=-][rwxXstugo]+)+\".
> + WHO-MASK is the mask number of the users on which the rights are to be applied.
> + FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed."

These names are too generic compared to the job they do.  I'd add
a "file-modes" prefix or somesuch.


        Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-09 21:19         ` Stefan Monnier
@ 2007-09-09 22:34           ` Michaël Cadilhac
  2007-09-10  1:13             ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-09 22:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: rms, emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 627 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> !       if (XSUBR (fun)->prompt)
>> ! 	return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));

> This doesn't look right.  It should do the Fread_from_string thingy as
> well.

Indeed, you're right!

>> + (defun char-to-who (char)
>> + (defun char-to-right (char &optional from)
>> + (defun right-string-to-number (rights who-mask &optional from)

> These names are too generic compared to the job they do.  I'd add
> a "file-modes" prefix or somesuch.

Thanks again :-)

The two first patches (the modifications to dired-aux are the same):


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: callint.patch --]
[-- Type: text/x-patch, Size: 6418 bytes --]

Index: src/lisp.h
===================================================================
RCS file: /sources/emacs/emacs/src/lisp.h,v
retrieving revision 1.583
diff -c -B -w -r1.583 lisp.h
*** src/lisp.h	29 Aug 2007 21:50:08 -0000	1.583
--- src/lisp.h	9 Sep 2007 22:34:00 -0000
***************
*** 891,897 ****
      Lisp_Object (*function) ();
      short min_args, max_args;
      char *symbol_name;
!     char *prompt;
      char *doc;
    };
  
--- 891,897 ----
      Lisp_Object (*function) ();
      short min_args, max_args;
      char *symbol_name;
!     char *intspec;
      char *doc;
    };
  
***************
*** 1669,1698 ****
  	 followed by the address of a vector of Lisp_Objects
  	 which contains the argument values.
      UNEVALLED means pass the list of unevaluated arguments
!  `prompt' says how to read arguments for an interactive call.
!     See the doc string for `interactive'.
      A null string means call interactively with no arguments.
   `doc' is documentation for the user.  */
  
  #if (!defined (__STDC__) && !defined (PROTOTYPES)) \
      || defined (USE_NONANSI_DEFUN)
  
! #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc)	\
    Lisp_Object fnname ();						\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, prompt, 0};			\
    Lisp_Object fnname
  
  #else
  
  /* This version of DEFUN declares a function prototype with the right
     arguments, so we can catch errors with maxargs at compile-time.  */
! #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc)	\
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;				\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, prompt, 0};			\
    Lisp_Object fnname
  
  /* Note that the weird token-substitution semantics of ANSI C makes
--- 1669,1701 ----
  	 followed by the address of a vector of Lisp_Objects
  	 which contains the argument values.
      UNEVALLED means pass the list of unevaluated arguments
!  `intspec' says how interactive arguments are to be fetched.
!     If the string starts with a `(', `intspec' is evaluated and the resulting
!     list is the list of arguments.
!     If it's a string that doesn't start with `(', the value should follow
!     the one of the doc string for `interactive'.
      A null string means call interactively with no arguments.
   `doc' is documentation for the user.  */
  
  #if (!defined (__STDC__) && !defined (PROTOTYPES)) \
      || defined (USE_NONANSI_DEFUN)
  
! #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)	\
    Lisp_Object fnname ();						\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, intspec, 0};			\
    Lisp_Object fnname
  
  #else
  
  /* This version of DEFUN declares a function prototype with the right
     arguments, so we can catch errors with maxargs at compile-time.  */
! #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)	\
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;				\
    DECL_ALIGN (struct Lisp_Subr, sname) =				\
      { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),	\
!       fnname, minargs, maxargs, lname, intspec, 0};			\
    Lisp_Object fnname
  
  /* Note that the weird token-substitution semantics of ANSI C makes
Index: src/callint.c
===================================================================
RCS file: /sources/emacs/emacs/src/callint.c,v
retrieving revision 1.154
diff -c -B -w -r1.154 callint.c
*** src/callint.c	29 Aug 2007 05:27:56 -0000	1.154
--- src/callint.c	9 Sep 2007 22:34:00 -0000
***************
*** 334,345 ****
  
    if (SUBRP (fun))
      {
!       string = (unsigned char *) XSUBR (fun)->prompt;
        if (!string)
  	{
  	lose:
  	  wrong_type_argument (Qcommandp, function);
  	}
      }
    else if (COMPILEDP (fun))
      {
--- 334,351 ----
  
    if (SUBRP (fun))
      {
!       string = (unsigned char *) XSUBR (fun)->intspec;
        if (!string)
  	{
  	lose:
  	  wrong_type_argument (Qcommandp, function);
  	}
+       /* The function has an interactive spec to evaluate.  */
+       if (*string == '(')
+ 	{
+ 	  specs = Fcar (Fread_from_string (build_string (string), Qnil, Qnil));
+ 	  string = 0;
+ 	}
      }
    else if (COMPILEDP (fun))
      {
Index: src/data.c
===================================================================
RCS file: /sources/emacs/emacs/src/data.c,v
retrieving revision 1.277
diff -c -B -w -r1.277 data.c
*** src/data.c	29 Aug 2007 05:27:58 -0000	1.277
--- src/data.c	9 Sep 2007 22:34:01 -0000
***************
*** 770,777 ****
  
    if (SUBRP (fun))
      {
!       if (XSUBR (fun)->prompt)
! 	return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
      }
    else if (COMPILEDP (fun))
      {
--- 770,780 ----
  
    if (SUBRP (fun))
      {
!       char *spec = XSUBR (fun)->intspec;
!       if (spec)
! 	return list2 (Qinteractive,
! 		      (*spec != '(') ? build_string (spec) :
! 		      Fcar (Fread_from_string (build_string (spec), Qnil, Qnil)));
      }
    else if (COMPILEDP (fun))
      {
Index: src/eval.c
===================================================================
RCS file: /sources/emacs/emacs/src/eval.c,v
retrieving revision 1.287
diff -c -B -w -r1.287 eval.c
*** src/eval.c	29 Aug 2007 05:27:57 -0000	1.287
--- src/eval.c	9 Sep 2007 22:34:03 -0000
***************
*** 2078,2084 ****
    /* Emacs primitives are interactive if their DEFUN specifies an
       interactive spec.  */
    if (SUBRP (fun))
!     return XSUBR (fun)->prompt ? Qt : if_prop;
  
    /* Bytecode objects are interactive if they are long enough to
       have an element whose index is COMPILED_INTERACTIVE, which is
--- 2078,2084 ----
    /* Emacs primitives are interactive if their DEFUN specifies an
       interactive spec.  */
    if (SUBRP (fun))
!     return XSUBR (fun)->intspec ? Qt : if_prop;
  
    /* Bytecode objects are interactive if they are long enough to
       have an element whose index is COMPILED_INTERACTIVE, which is

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.3: chmod.patch --]
[-- Type: text/x-patch, Size: 5557 bytes --]

Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.927
diff -c -B -w -r1.927 files.el
*** lisp/files.el	31 Aug 2007 13:29:34 -0000	1.927
--- lisp/files.el	9 Sep 2007 22:23:28 -0000
***************
*** 5407,5412 ****
--- 5407,5505 ----
  	  (t
  	   (apply operation arguments)))))
  
+ \f
+ ;; Symbolic modes and read-file-modes.
+ 
+ (defun file-modes-char-to-who (char)
+   "Convert CHAR to a who-mask from a symbolic mode notation.
+ CHAR is in [ugoa] and represents the users on which rights are applied."
+   (cond ((= char ?u) #o4700)
+ 	((= char ?g) #o2070)
+ 	((= char ?o) #o1007)
+ 	((= char ?a) #o7777)
+ 	(t (error "%c: bad `who' character" char))))
+ 
+ (defun file-modes-char-to-right (char &optional from)
+   "Convert CHAR to a right-mask from a symbolic mode notation.
+ CHAR is in [rwxXstugo] and represents a right.
+ If CHAR is in [Xugo], the value is extracted from FROM (or 0 if nil)."
+   (or from (setq from 0))
+   (cond ((= char ?r) #o0444)
+ 	((= char ?w) #o0222)
+ 	((= char ?x) #o0111)
+ 	((= char ?s) #o1000)
+ 	((= char ?t) #o6000)
+ 	;; Rights relative to the previous file modes.
+ 	((= char ?X) (if (= (logand from #o111) 0) 0 #o0111))
+ 	((= char ?u) (let ((uright (logand #o4700 from)))
+ 		       (+ uright (/ uright #o10) (/ uright #o100))))
+ 	((= char ?g) (let ((gright (logand #o2070 from)))
+ 		       (+ gright (/ gright #o10) (* gright #o10))))
+ 	((= char ?o) (let ((oright (logand #o1007 from)))
+ 		       (+ oright (* oright #o10) (* oright #o100))))
+ 	(t (error "%c: bad right character" char))))
+ 
+ (defun file-modes-rights-to-number (rights who-mask &optional from)
+   "Convert a right string to a right-mask from a symbolic modes notation.
+ RIGHTS is the right string, it should match \"([+=-][rwxXstugo]+)+\".
+ WHO-MASK is the mask number of the users on which the rights are to be applied.
+ FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed."
+   (let* ((num-rights (or from 0))
+ 	 (list-rights (string-to-list rights))
+ 	 (op (pop list-rights)))
+     (while (memq op '(?+ ?- ?=))
+       (let ((num-right 0)
+ 	    char-right)
+ 	(while (memq (setq char-right (pop list-rights))
+ 		     '(?r ?w ?x ?X ?s ?t ?u ?g ?o))
+ 	  (setq num-right
+ 		(logior num-right
+ 			(file-modes-char-to-right char-right num-rights))))
+ 	(setq num-right (logand who-mask num-right)
+ 	      num-rights
+ 	      (cond ((= op ?+) (logior num-rights num-right))
+ 		    ((= op ?-) (logand num-rights (lognot num-right)))
+ 		    (t (logior (logand num-rights (lognot who-mask)) num-right)))
+ 	      op char-right)))
+     num-rights))
+ 
+ (defun symbolic-file-modes-to-number (modes &optional from)
+   "Convert symbolic file modes to numeric file modes.
+ MODES is the string to convert, it should match
+ \"[ugoa]*([+-=][rwxXstugo]+)+,...\".
+ See (info \"(coreutils)File permissions\") for more information on this
+ notation.
+ FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed."
+   (save-match-data
+     (let ((case-fold-search nil)
+ 	  (num-modes (or from 0)))
+       (while (/= (string-to-char modes) 0)
+ 	(if (string-match "^\\([ugoa]*\\)\\([+=-][rwxXstugo]+\\)+\\(,\\|\\)" modes)
+ 	    (let ((num-who (apply 'logior 0
+ 				  (mapcar 'file-modes-char-to-who
+ 					  (match-string 1 modes)))))
+ 	      (when (= num-who 0)
+ 		(setq num-who (default-file-modes)))
+ 	      (setq num-modes
+ 		    (file-modes-rights-to-number (substring modes (match-end 1))
+ 						 num-who num-modes)
+ 		    modes (substring modes (match-end 3))))
+ 	  (error "Parse error in modes near `%s'" (substring modes 0))))
+       num-modes)))
+ 
+ (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."
+   (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)
+ 	(symbolic-file-modes-to-number value modes)))))
+ 
+ \f
  (define-key ctl-x-map "\C-f" 'find-file)
  (define-key ctl-x-map "\C-r" 'find-file-read-only)
  (define-key ctl-x-map "\C-v" 'find-alternate-file)
Index: src/fileio.c
===================================================================
RCS file: /sources/emacs/emacs/src/fileio.c,v
retrieving revision 1.590
diff -c -B -w -r1.590 fileio.c
*** src/fileio.c	29 Aug 2007 05:27:58 -0000	1.590
--- src/fileio.c	9 Sep 2007 22:23:30 -0000
***************
*** 3435,3441 ****
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, 0,
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)
--- 3435,3443 ----
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2,
!        "(let ((file (read-file-name \"File: \")))			\
! 	  (list file (read-file-modes nil file)))",
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)

[-- Attachment #1.1.4: Type: text/plain, Size: 327 bytes --]


-- 
 |   Michaël `Micha' Cadilhac       |  «Tu aimeras ton prochain.»            |
 |   http://michael.cadilhac.name   |    D'abord, Dieu ou pas,               |
 |   JID/MSN:                       |       j'ai horreur qu'on me tutoie.    |
 `----  michael.cadilhac@gmail.com  |           -- P. Desproges         -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-09 22:34           ` Michaël Cadilhac
@ 2007-09-10  1:13             ` Richard Stallman
  2007-09-10 11:06               ` Michaël Cadilhac
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2007-09-10  1:13 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: monnier, emacs-devel

It looks good, but please write a full NEWS entry before you install
this.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-09 20:45         ` Stefan Monnier
@ 2007-09-10  1:13           ` Richard Stallman
  2007-09-10  2:29             ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2007-09-10  1:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

    > That would be a slowdown in very important cases.

    Finteractive_form takes an absolutely negligible amount of time.  So I have
    no idea what you mean by "a slowdown".  The only "problem" I could imagine
    is that Finteractive_form allocates a Lisp string whereas the above code
    doesn't.

Sorry, you're right about that.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10  1:13           ` Richard Stallman
@ 2007-09-10  2:29             ` Stefan Monnier
  2007-09-12 23:59               ` Johan Bockgård
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2007-09-10  2:29 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>> That would be a slowdown in very important cases.
>     Finteractive_form takes an absolutely negligible amount of time.  So I have
>     no idea what you mean by "a slowdown".  The only "problem" I could imagine
>     is that Finteractive_form allocates a Lisp string whereas the above code
>     doesn't.

> Sorry, you're right about that.

OK, installed,


        Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10  1:13             ` Richard Stallman
@ 2007-09-10 11:06               ` Michaël Cadilhac
  2007-09-10 14:52                 ` Dan Nicolaescu
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-10 11:06 UTC (permalink / raw)
  To: rms; +Cc: monnier, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

Richard Stallman <rms@gnu.org> writes:

> It looks good, but please write a full NEWS entry before you install
> this.

All the changes have been installed (except the one to callint.c which
was unneeded thanks to Stefan's change).  Two NEWS entries added:

** Built-in functions (subr) can now have an interactive specification
that is not a prompt string.  If the `intspec' parameter of a `DEFUN'
starts with a `(', the string is evaluated as a Lisp form.

** set-file-modes is now interactive and can take the mode value in
symbolic notation thanks to auxiliary functions.


-- 
 |   Michaël `Micha' Cadilhac       |  Mieux vaut se taire                   |
 |   http://michael.cadilhac.name   |   Que de parler trop fort.             |
 |   JID/MSN:                       |           -- As de trèfle              |
 `----  michael.cadilhac@gmail.com  |                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 11:06               ` Michaël Cadilhac
@ 2007-09-10 14:52                 ` Dan Nicolaescu
  2007-09-10 15:05                   ` Michaël Cadilhac
  0 siblings, 1 reply; 22+ messages in thread
From: Dan Nicolaescu @ 2007-09-10 14:52 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-devel, rms, monnier

michael@cadilhac.name (Michaël Cadilhac) writes:

  > ** set-file-modes is now interactive and can take the mode value in
  > symbolic notation thanks to auxiliary functions.

This is great! Can you please add handling of the 'X' format? Right now
it is silently ignored. And so is "-R" 

Thanks!

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 14:52                 ` Dan Nicolaescu
@ 2007-09-10 15:05                   ` Michaël Cadilhac
  2007-09-10 15:13                     ` Dan Nicolaescu
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-10 15:05 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel, rms, monnier


[-- Attachment #1.1: Type: text/plain, Size: 1242 bytes --]

Dan Nicolaescu <dann@ics.uci.edu> writes:

> michael@cadilhac.name (Michaël Cadilhac) writes:
>
>   > ** set-file-modes is now interactive and can take the mode value in
>   > symbolic notation thanks to auxiliary functions.
>
> This is great!

Isn't it? :-) Wow, this patch concludes my very first post in
emacs.devel :-)

> Can you please add handling of the 'X' format?

  $ touch /dd/test && chmod 100 /dd/test && la /dd/test
---x------ 1 micha micha 0 2007-09-10 16:57 /dd/test

  M-x set-file-modes RET /dd/test RET o+X

  $ la /dd/test
---x-----x 1 micha micha 0 2007-09-10 16:57 /dd/test

In which case is it ignored?

> And so is "-R"

The (info "(coreutils)Symbolic Modes") node doesn't know about that.  Do
you mean the recursive feature of chmod?  In which case, I don't think
it really is the job of `set-file-modes' to handle this.  Maybe it could
be a feature of dired.

-- 
 |   Michaël `Micha' Cadilhac       |       One user is enough.              |
 |   http://michael.cadilhac.name   |    People suck.                        |
 |   JID/MSN:                       |                                        |
 `----  michael.cadilhac@gmail.com  |          -- Tuomo Valkonen        -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 15:05                   ` Michaël Cadilhac
@ 2007-09-10 15:13                     ` Dan Nicolaescu
  2007-09-10 15:27                       ` Michaël Cadilhac
  0 siblings, 1 reply; 22+ messages in thread
From: Dan Nicolaescu @ 2007-09-10 15:13 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-devel, rms, monnier

michael@cadilhac.name (Michaël Cadilhac) writes:

  > Dan Nicolaescu <dann@ics.uci.edu> writes:
  > 
  > > michael@cadilhac.name (Michaël Cadilhac) writes:
  > >
  > >   > ** set-file-modes is now interactive and can take the mode value in
  > >   > symbolic notation thanks to auxiliary functions.
  > >
  > > This is great!
  > 
  > Isn't it? :-) Wow, this patch concludes my very first post in
  > emacs.devel :-)
  > 
  > > Can you please add handling of the 'X' format?
  > 
  >   $ touch /dd/test && chmod 100 /dd/test && la /dd/test
  > ---x------ 1 micha micha 0 2007-09-10 16:57 /dd/test
  > 
  >   M-x set-file-modes RET /dd/test RET o+X
  > 
  >   $ la /dd/test
  > ---x-----x 1 micha micha 0 2007-09-10 16:57 /dd/test
  > 
  > In which case is it ignored?

ls -l data.o
-rw-------    1 dann     dann   143196 Sep 10 07:39 data.o

M-x set-file-modes RET data.o RET a+rX RET

ls -l data.o
-rw-r--r--    1 dann     dann   143196 Sep 10 07:39 data.o

  > 
  > > And so is "-R"
  > 
  > The (info "(coreutils)Symbolic Modes") node doesn't know about that.  Do
  > you mean the recursive feature of chmod?  In which case, I don't think
  > it really is the job of `set-file-modes' to handle this.  

My point is that if set-file-modes does not handle -R, it should not
just ignore it.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 15:13                     ` Dan Nicolaescu
@ 2007-09-10 15:27                       ` Michaël Cadilhac
  2007-09-10 15:39                         ` Dan Nicolaescu
  0 siblings, 1 reply; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-10 15:27 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel, rms, monnier


[-- Attachment #1.1: Type: text/plain, Size: 1423 bytes --]

Dan Nicolaescu <dann@ics.uci.edu> writes:

>   > > Can you please add handling of the 'X' format?

> ls -l data.o
> -rw-------    1 dann     dann   143196 Sep 10 07:39 data.o
>
> M-x set-file-modes RET data.o RET a+rX RET
>
> ls -l data.o
> -rw-r--r--    1 dann     dann   143196 Sep 10 07:39 data.o

And this is utterly fine, isn't it?

   $ la /dd/temp
-rw------- 1 micha micha 0 2007-09-10 17:23 /dd/temp
   $ chmod a+rX /dd/temp
-rw-r--r-- 1 micha micha 0 2007-09-10 17:23 /dd/temp

The X flags means that if some user (u g or o) had a `x' flag, the new
mode should have it too.

>   > The (info "(coreutils)Symbolic Modes") node doesn't know about that.  Do
>   > you mean the recursive feature of chmod?  In which case, I don't think
>   > it really is the job of `set-file-modes' to handle this.  
>
> My point is that if set-file-modes does not handle -R, it should not
> just ignore it.

And it doesn't :
  M-x set-file-modes RET /dd/temp RET -R RET
yields 
  file-modes-symbolic-to-number: Parse error in modes near `-R'

Don't you have this message?

-- 
 |   Michaël `Micha' Cadilhac       |   An error can become exact            |
 |   http://michael.cadilhac.name   |     as the one who committed it        |
 |   JID/MSN:                       |  made a mistake or not.                |
 `----  michael.cadilhac@gmail.com  |          -- Pierre Dac            -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 15:27                       ` Michaël Cadilhac
@ 2007-09-10 15:39                         ` Dan Nicolaescu
  2007-09-10 15:55                           ` Michaël Cadilhac
  0 siblings, 1 reply; 22+ messages in thread
From: Dan Nicolaescu @ 2007-09-10 15:39 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-devel, rms, monnier

michael@cadilhac.name (Michaël Cadilhac) writes:

  > Dan Nicolaescu <dann@ics.uci.edu> writes:
  > 
  > >   > > Can you please add handling of the 'X' format?
  > 
  > > ls -l data.o
  > > -rw-------    1 dann     dann   143196 Sep 10 07:39 data.o
  > >
  > > M-x set-file-modes RET data.o RET a+rX RET
  > >
  > > ls -l data.o
  > > -rw-r--r--    1 dann     dann   143196 Sep 10 07:39 data.o
  > 
  > And this is utterly fine, isn't it?

Sure it is, I realized that in the shower, too early in the morning to
think straight. Sorry about that. 

  > >   > The (info "(coreutils)Symbolic Modes") node doesn't know about that.  Do
  > >   > you mean the recursive feature of chmod?  In which case, I don't think
  > >   > it really is the job of `set-file-modes' to handle this.  
  > >
  > > My point is that if set-file-modes does not handle -R, it should not
  > > just ignore it.
  > 
  > And it doesn't :
  >   M-x set-file-modes RET /dd/temp RET -R RET
  > yields 
  >   file-modes-symbolic-to-number: Parse error in modes near `-R'
  > 
  > Don't you have this message?

Hmm, not sure what I did, I didn't get that message before, but I got
it now. Might be early morning brain malfunction :-(

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10 15:39                         ` Dan Nicolaescu
@ 2007-09-10 15:55                           ` Michaël Cadilhac
  0 siblings, 0 replies; 22+ messages in thread
From: Michaël Cadilhac @ 2007-09-10 15:55 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel, rms, monnier


[-- Attachment #1.1: Type: text/plain, Size: 807 bytes --]

Dan Nicolaescu <dann@ics.uci.edu> writes:

> Sure it is, I realized that in the shower, too early in the morning to
> think straight.

You know you are a researcher when you can only think straight not
*after* the shower but *during* it.

> Hmm, not sure what I did, I didn't get that message before, but I got
> it now. Might be early morning brain malfunction :-(

Well, if you can reproduce it, tell us!  But the regexp seems pretty
darn restrictive to allow a R.

-- 
 |   Michaël `Micha' Cadilhac       |  Une erreur peut devenir exacte        |
 |   http://michael.cadilhac.name   |     selon que celui qui l'a commise    |
 |   JID/MSN:                       |  s'est trompé ou non.                  |
 `----  michael.cadilhac@gmail.com  |          -- Pierre Dac            -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Interactive specs of C functions.
  2007-09-10  2:29             ` Stefan Monnier
@ 2007-09-12 23:59               ` Johan Bockgård
  0 siblings, 0 replies; 22+ messages in thread
From: Johan Bockgård @ 2007-09-12 23:59 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> OK, installed,


2007-09-10  Johan Bockgård  <bojohan@gnu.org>

	* callint.c (Fcall_interactively): Remove unused var `fun'.


Index: src/callint.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/callint.c,v
retrieving revision 1.155
diff -u -r1.155 callint.c
--- src/callint.c	10 Sep 2007 02:29:42 -0000	1.155
+++ src/callint.c	10 Sep 2007 07:44:50 -0000
@@ -263,7 +263,6 @@
      Lisp_Object function, record_flag, keys;
 {
   Lisp_Object *args, *visargs;
-  Lisp_Object fun;
   Lisp_Object specs;
   Lisp_Object filter_specs;
   Lisp_Object teml;
@@ -317,8 +316,6 @@
   else
     enable = Qnil;
 
-  fun = indirect_function (function);
-
   specs = Qnil;
   string = 0;
   /* The idea of FILTER_SPECS is to provide away to

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2007-09-12 23:59 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-07 14:58 Interactive specs of C functions Michaël Cadilhac
2007-09-07 18:01 ` Stefan Monnier
2007-09-07 21:52   ` Johan Bockgård
2007-09-08  2:18     ` Stefan Monnier
2007-09-08 19:48       ` Richard Stallman
2007-09-09 20:45         ` Stefan Monnier
2007-09-10  1:13           ` Richard Stallman
2007-09-10  2:29             ` Stefan Monnier
2007-09-12 23:59               ` Johan Bockgård
2007-09-08  7:01 ` Richard Stallman
2007-09-08  9:06   ` Michaël Cadilhac
     [not found]     ` <E1IUCIK-0008Ck-2z@fencepost.gnu.org>
2007-09-09 20:46       ` Michaël Cadilhac
2007-09-09 21:19         ` Stefan Monnier
2007-09-09 22:34           ` Michaël Cadilhac
2007-09-10  1:13             ` Richard Stallman
2007-09-10 11:06               ` Michaël Cadilhac
2007-09-10 14:52                 ` Dan Nicolaescu
2007-09-10 15:05                   ` Michaël Cadilhac
2007-09-10 15:13                     ` Dan Nicolaescu
2007-09-10 15:27                       ` Michaël Cadilhac
2007-09-10 15:39                         ` Dan Nicolaescu
2007-09-10 15:55                           ` Michaël Cadilhac

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.