From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: File modes facilities. Date: Wed, 26 Oct 2005 10:52:47 +0200 Message-ID: References: <87hdbdxo94.fsf@mahaena.lrde> <877jc92o37.fsf@mahaena.lrde> <17238.50816.352274.312799@kahikatea.snap.net.nz> <87u0fd9let.fsf@mahaena.lrde> <87oe5jmu9j.fsf-monnier+emacs@gnu.org> <87y84n81q2.fsf@mahaena.lrde> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1130322248 25142 80.91.229.2 (26 Oct 2005 10:24:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Oct 2005 10:24:08 +0000 (UTC) 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 Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 26 12:24:03 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EUiPo-0001ri-Or for ged-emacs-devel@m.gmane.org; Wed, 26 Oct 2005 12:21:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EUiPn-0000ty-OH for ged-emacs-devel@m.gmane.org; Wed, 26 Oct 2005 06:21:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EUh8F-0000B2-Nf for emacs-devel@gnu.org; Wed, 26 Oct 2005 04:59:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EUh7d-0008JN-7c for emacs-devel@gnu.org; Wed, 26 Oct 2005 04:59:02 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EUh5U-0007jz-8f for emacs-devel@gnu.org; Wed, 26 Oct 2005 04:56:49 -0400 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EUh5R-0002KO-GV; Wed, 26 Oct 2005 04:56:45 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepa.post.tele.dk (Postfix) with SMTP id 8C0F147FE26; Wed, 26 Oct 2005 10:53:37 +0200 (CEST) Original-To: rms@gnu.org In-Reply-To: (Kim F. Storm's message of "Tue, 25 Oct 2005 23:34:55 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:44892 Archived-At: 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); } + + 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 http://www.cua.dk