emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File modes facilities.


From: Kim F. Storm
Subject: Re: File modes facilities.
Date: Fri, 21 Oct 2005 16:43:19 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Miles Bader <address@hidden> writes:

> Still, adding lisp interactive specs to C functions would be very
> useful, and much cleaner than having 2*n functions, especially if it's
> as simple as Kim suggested.

Well almost..., I forgot about changing call-interactvely.  

Below is a complete patch (including the necessary patch to
Fset_file_modes).

Here is an example of how to set the interactive form.
Of course, it should be changed to recognize octal and ascii forms,
as the current base 10 form is useless for interactive use:

(put 'set-file-modes 'interactive '(list (read-file-name "File: ")
                                         (read-number "Modes: ")))


*** callint.c   14 Aug 2005 14:47:25 +0200      1.140
--- callint.c   21 Oct 2005 16:38:22 +0200      
***************
*** 346,351 ****
--- 346,356 ----
          function = wrong_type_argument (Qcommandp, function);
          goto retry;
        }
+       else if (*string == '#')
+       {
+         string = 0;
+         goto get_interactive_form;
+       }
      }
    else if (COMPILEDP (fun))
      {
***************
*** 356,361 ****
--- 361,367 ----
    else
      {
        Lisp_Object form;
+     get_interactive_form:
        GCPRO2 (function, prefix_arg);
        form = Finteractive_form (function);
        UNGCPRO;

*** data.c      19 Sep 2005 00:24:45 +0200      1.254
--- data.c      21 Oct 2005 13:04:24 +0200      
***************
*** 787,793 ****
    if (SUBRP (fun))
      {
        if (XSUBR (fun)->prompt)
!       return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
      }
    else if (COMPILEDP (fun))
      {
--- 787,801 ----
    if (SUBRP (fun))
      {
        if (XSUBR (fun)->prompt)
!       {
!         Lisp_Object spec;
!         if (XSUBR (fun)->prompt[0] != '#')
!           return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
! 
!         if ((spec = Fget (intern (XSUBR (fun)->symbol_name), Qinteractive),
!              !NILP (spec)))
!           return list2 (Qinteractive, spec);
!       }
      }
    else if (COMPILEDP (fun))
      {

*** fileio.c    20 Oct 2005 16:48:05 +0200      1.557
--- fileio.c    21 Oct 2005 16:21:25 +0200      
***************
*** 3462,3468 ****
    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)
--- 3462,3468 ----
    return make_number (st.st_mode & 07777);
  }
  
! DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, "#",
         doc: /* Set mode bits of file named FILENAME to MODE (an integer).
  Only the 12 low bits of MODE are used.  */)
    (filename, mode)

--
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]