[Top][All Lists]
[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: |
Wed, 26 Oct 2005 10:52:47 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
address@hidden (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 <address@hidden> http://www.cua.dk
- Re: File modes facilities., (continued)
- Re: File modes facilities., Stefan Monnier, 2005/10/24
- Re: File modes facilities., Kim F. Storm, 2005/10/24
- Re: File modes facilities., Stefan Monnier, 2005/10/24
- Re: File modes facilities., Kim F. Storm, 2005/10/25
- Re: File modes facilities., Richard M. Stallman, 2005/10/25
- Re: File modes facilities., Richard M. Stallman, 2005/10/25
- Re: File modes facilities., Kim F. Storm, 2005/10/25
- Re: File modes facilities.,
Kim F. Storm <=
- Re: File modes facilities., Richard M. Stallman, 2005/10/26
- Re: File modes facilities., Richard M. Stallman, 2005/10/26
- Re: File modes facilities., Kim F. Storm, 2005/10/21
- Re: File modes facilities., Stefan Monnier, 2005/10/21
- Re: File modes facilities., Kim F. Storm, 2005/10/21
- Re: File modes facilities., Richard M. Stallman, 2005/10/21
- Re: File modes facilities., Stefan Monnier, 2005/10/21
- Re: File modes facilities., Richard M. Stallman, 2005/10/22
- RE: File modes facilities., Drew Adams, 2005/10/22
- Re: File modes facilities., Miles Bader, 2005/10/22