summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Ferrier <nferrier@ferrier.me.uk>2013-08-25 11:48:10 +0100
committerNic Ferrier <nferrier@ferrier.me.uk>2013-08-25 11:48:10 +0100
commita9f1bbeb3bc231f554570e6a8c6cb67f05966d25 (patch)
tree7797c5b4634317f835fd2046395b6e78bc59d061
parentfe47fc29b1153c5614dcd40a07189181e90725fc (diff)
update the README with details about cl style arg lists.
-rw-r--r--README.creole61
1 files changed, 61 insertions, 0 deletions
diff --git a/README.creole b/README.creole
index a3240e8..b7c4d8a 100644
--- a/README.creole
+++ b/README.creole
@@ -48,3 +48,64 @@ definition of these common Emacs functions.
This overrides {{{find-file}}} to set a local variable. There are
surely better ways to do it than this but it illustrates the point.
+
+=== todo ===
+
+It would be nice to have a noflet that could work with Emacs/CL style
+arg lists, like {{{defun*}}}.
+
+This would allow something like:
+
+{{{
+(noflet* ((get-buffer (name &key regex)
+ (if name
+ (funcall this-fn name)
+ (regex-find-buffer-function regex))))
+ ...)
+}}}
+
+Doing this looks easy enough to implement with the
+{{{cl--transform-lambda}}} function:
+
+{{{
+(cl--transform-lambda
+ '((fp &key blah) ; the arglist
+ "My function" ; the doc string
+ (setq blah :1)) ; the function body
+ 'nic-func) ; the name of the function you're assigning
+}}}
+
+this returns something like this:
+
+{{{
+(nil (fp &rest --cl-rest--) "My function
+
+(fn FP &key BLAH)"
+(let*
+ ((blah
+ (car
+ (cdr
+ (memq ':blah --cl-rest--)))))
+ (let
+ ((--cl-keys-- --cl-rest--))
+ (while --cl-keys--
+ (cond
+ ((memq
+ (car --cl-keys--)
+ '(:blah :allow-other-keys))
+ (setq --cl-keys--
+ (cdr
+ (cdr --cl-keys--))))
+ ((car
+ (cdr
+ (memq ':allow-other-keys --cl-rest--)))
+ (setq --cl-keys-- nil))
+ (t
+ (error "Keyword argument %s not one of (:blah)"
+ (car --cl-keys--))))))
+ (cl-block nic-func
+ (setq blah :1))))
+}}}
+
+And obviously you can take the CDR of this and use it as a lambda form
+or some such.