unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: schwab@suse.de, michael.cadilhac-@t-lrde.epita.fr,
	emacs-devel@gnu.org, monnier@iro.umontreal.ca, eliz@gnu.org,
	snogglethorpe@gmail.com, miles@gnu.org
Subject: Re: File modes facilities.
Date: Wed, 26 Oct 2005 10:52:47 +0200	[thread overview]
Message-ID: <m3d5lsslr4.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <m34q7546ww.fsf@kfs-l.imdomain.dk> (Kim F. Storm's message of "Tue, 25 Oct 2005 23:34:55 +0200")

storm@cua.dk (Kim F. Storm) writes:

> My trivial changes provide a simple, efficient, flexible,
> user-extensible solution which can be applied to all existing
> functions and commands.

.. and it easily forms the foundation for implementing your
preferred approach, i.e. include the lisp form directly in the C
source file like this:

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).


My approach also allow aliases to be defined with a different
interactive spec like this:

(defalias 'chmod 'set-file-modes
  "Interactive frontend to `set-file-modes'."
  "fFile: \nnModes: ")


So besides being simple, efficient, flexible, and user-extensible,
it is also a clean solution (with the additional patches below).


Here are the necessary additions to my previous patch to
implement these two features:

*** lread.c	23 Oct 2005 23:02:21 +0200	1.341
--- lread.c	26 Oct 2005 10:19:02 +0200
***************
*** 3450,3455 ****
--- 3450,3465 ----
    read_buffer = (char *) xmalloc (read_buffer_size);
  }
  \f
+
+ static Lisp_Object
+ defsubr_error_handler (data)
+      Lisp_Object data;
+ {
+
+   return Qerror;
+ }
+
+
  void
  defsubr (sname)
       struct Lisp_Subr *sname;
***************
*** 3457,3462 ****
--- 3467,3487 ----
    Lisp_Object sym;
    sym = intern (sname->symbol_name);
    XSETSUBR (XSYMBOL (sym)->function, sname);
+   if (sname->prompt && sname->prompt[0] == '(')
+     {
+       /* Parse inline interactive Lisp expression.  */
+       int len = strlen (sname->prompt);
+       if (sname->prompt[len - 1] == ')')
+ 	{
+ 	  Lisp_Object specs;
+ 	  specs = internal_condition_case_1 (Fread,
+ 					     make_string (sname->prompt, len),
+ 					     Qt, defsubr_error_handler);
+ 	  if (EQ (specs, Qerror))
+ 	    fatal ("invalid interactive spec for `%s'", sname->symbol_name);
+ 	  Fput (sym, Qinteractive, specs);
+ 	}
+     }
  }

  #ifdef NOTDEF /* use fset in subr.el now */

*** data.c	19 Sep 2005 00:24:45 +0200	1.254
--- data.c	26 Oct 2005 09:27:17 +0200
***************
*** 710,723 ****

  extern Lisp_Object Qfunction_documentation;

! DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0,
         doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION.
  Associates the function with the current load file, if any.
  The optional third argument DOCSTRING specifies the documentation string
  for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
! determined by DEFINITION.  */)
!      (symbol, definition, docstring)
!      register Lisp_Object symbol, definition, docstring;
  {
    CHECK_SYMBOL (symbol);
    if (CONSP (XSYMBOL (symbol)->function)
--- 710,725 ----

  extern Lisp_Object Qfunction_documentation;

! DEFUN ("defalias", Fdefalias, Sdefalias, 2, 4, 0,
         doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION.
  Associates the function with the current load file, if any.
  The optional third argument DOCSTRING specifies the documentation string
  for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
! determined by DEFINITION.
! The optional fourth argument INTERACTIVE-FORM specifies how to read the
! arguments for command SYMBOL when called interactively.  See `interactive'.  */)
!   (symbol, definition, docstring, interactive_form)
!      register Lisp_Object symbol, definition, docstring, interactive_form;
  {
    CHECK_SYMBOL (symbol);
    if (CONSP (XSYMBOL (symbol)->function)
***************
*** 727,732 ****
--- 729,742 ----
    LOADHIST_ATTACH (Fcons (Qdefun, symbol));
    if (!NILP (docstring))
      Fput (symbol, Qfunction_documentation, docstring);
+   if (!NILP (interactive_form))
+     {
+       /* Accept (interactive ARGS) as well as just ARGS.  */
+       if (CONSP (interactive_form)
+ 	  && EQ (XCAR (interactive_form), Qinteractive))
+ 	interactive_form = Fcar (XCDR (interactive_form));
+       Fput (symbol, Qinteractive, interactive_form);
+     }
    return definition;
  }




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

  reply	other threads:[~2005-10-26  8:52 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-19 20:09 File modes facilities Michael Cadilhac
2005-10-19 20:35 ` Stefan Monnier
2005-10-19 21:28   ` Michael Cadilhac
2005-10-19 22:19     ` Nick Roberts
2005-10-19 22:44       ` Michael Cadilhac
2005-10-19 22:48         ` Kim F. Storm
2005-10-19 22:57           ` Edward O'Connor
2005-10-19 23:00           ` Michael Cadilhac
2005-10-20  9:04         ` Eli Zaretskii
2005-10-20 10:41           ` Michael Cadilhac
2005-10-20 11:51             ` Romain Francoise
2005-10-20 12:41             ` Eli Zaretskii
2005-10-20 14:18               ` Michael Cadilhac
2005-10-20 16:15           ` Stefan Monnier
2005-10-20 22:16             ` Kim F. Storm
2005-10-21  3:21               ` Stefan Monnier
2005-10-21  8:44                 ` Andreas Schwab
2005-10-21 12:59                   ` Michael Cadilhac
2005-10-21 14:14                     ` Miles Bader
2005-10-21 14:43                       ` Kim F. Storm
2005-10-21 16:42                         ` Michael Cadilhac
2005-10-21 22:19                         ` Richard M. Stallman
2005-10-24 14:02                           ` Kim F. Storm
2005-10-24 14:16                             ` David Kastrup
2005-10-24 16:02                               ` Andreas Schwab
2005-10-24 21:00                               ` Kim F. Storm
2005-10-24 14:46                             ` Stefan Monnier
2005-10-24 22:14                               ` Kim F. Storm
2005-10-24 23:02                                 ` Stefan Monnier
2005-10-25  8:51                                   ` Kim F. Storm
2005-10-25 20:29                                     ` Richard M. Stallman
2005-10-25 15:58                             ` Richard M. Stallman
2005-10-25 21:34                               ` Kim F. Storm
2005-10-26  8:52                                 ` Kim F. Storm [this message]
2005-10-27  1:31                                   ` Richard M. Stallman
2005-10-27  1:29                                 ` Richard M. Stallman
2005-10-21 10:58                 ` Kim F. Storm
2005-10-21 11:05                 ` Kim F. Storm
2005-10-21 15:07                   ` Stefan Monnier
2005-10-21 17:51                 ` Richard M. Stallman
2005-10-21 18:43                   ` Stefan Monnier
2005-10-22  4:18                     ` Richard M. Stallman
2005-10-22  5:39                       ` Drew Adams
2005-10-22  6:17                         ` Miles Bader
2005-10-22  6:32                           ` Drew Adams
2005-10-22  7:33                             ` Miles Bader
2005-10-22  7:45                               ` Drew Adams
2005-10-23 18:05                         ` Stefan Monnier
2005-10-23 18:27                           ` Drew Adams
2005-10-24 13:37                             ` Richard M. Stallman
2005-10-24 13:40                             ` Stefan Monnier
2005-10-24 16:41                               ` Drew Adams
2005-10-24 16:59                                 ` Stefan Monnier
2005-10-24 17:13                                   ` Drew Adams
2005-10-20 23:38             ` Richard M. Stallman
2005-10-21  0:58               ` Michael Cadilhac
2005-10-21  1:06                 ` Miles Bader
2005-10-21  1:24                   ` Michael Cadilhac
2005-10-21 17:51                     ` Richard M. Stallman
2005-10-23 23:42                       ` Michael Cadilhac
2005-10-24 14:09                         ` Kim F. Storm
2005-10-25 15:58                           ` Richard M. Stallman
2005-10-20  1:42 ` Kevin Ryde
2005-10-20  2:01   ` Miles Bader
2005-10-20  7:12     ` Michael Cadilhac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d5lsslr4.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.cadilhac-@t-lrde.epita.fr \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=schwab@suse.de \
    --cc=snogglethorpe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).