diff options
author | forcer <forcer> | 2005-09-14 21:56:00 +0000 |
---|---|---|
committer | forcer <mwolson@gnu.org> | 2005-09-14 21:56:00 +0000 |
commit | ea1212c32b170340cd2158545bc98bb3d74e7112 (patch) | |
tree | 5c64321336e5048210a33ebfa59db82768ae9a5c | |
parent | f3e2073b312f954940d9fab944525b23f22fc926 (diff) |
ogg-comment.el: Define macros before using them.
darcs-hash:20050914215657-2189f-6138e4593adb14f5ae2553b3819510ae03e2cd3c.gz
-rw-r--r-- | ogg-comment.el | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/ogg-comment.el b/ogg-comment.el index 39a490a..f8d9f8d 100644 --- a/ogg-comment.el +++ b/ogg-comment.el @@ -74,6 +74,33 @@ (defconst oggc-version "$Revision: 1.5 $" "Ogg-comment's version number.") +(defmacro with-part-of-file (file-spec &rest body) + "Execute BODY in a buffer containing part of FILE. + +BEG and END are as `insert-file-contents' (q.v.). + +\(fn (FILE &optional BEG END) &rest BODY)" + (let (file beg end) + (setq file (pop file-spec)) + (and file-spec (setq beg (pop file-spec))) + (and file-spec (setq end (pop file-spec))) + `(with-temp-buffer + (insert-file-contents-literally ,file nil ,beg ,end) + (goto-char (point-min)) + ,@body))) + +(defmacro aif (test-form then &rest else) + "Like `if', but with `it' bound to the result of TEST-FORM. +`it' is accessible in the THEN and ELSE clauses. + +Warning, non-hygienic by design. + +\(fn TEST-FORM THEN &rest ELSE)" + `(let ((it ,test-form)) + (if it + ,then + ,@else))) + (defun oggc-split-comment (comment) "Split Ogg COMMENT into a (name, value) pair. @@ -239,33 +266,6 @@ COMMENTS should be an alist of the form: (interactive "FFile: ") (oggc-pretty-print-header (oggc-read-header file))) -(defmacro with-part-of-file (file-spec &rest body) - "Execute BODY in a buffer containing part of FILE. - -BEG and END are as `insert-file-contents' (q.v.). - -\(fn (FILE &optional BEG END) &rest BODY)" - (let (file beg end) - (setq file (pop file-spec)) - (and file-spec (setq beg (pop file-spec))) - (and file-spec (setq end (pop file-spec))) - `(with-temp-buffer - (insert-file-contents-literally ,file nil ,beg ,end) - (goto-char (point-min)) - ,@body))) - -(defmacro aif (test-form then &rest else) - "Like `if', but with `it' bound to the result of TEST-FORM. -`it' is accessible in the THEN and ELSE clauses. - -Warning, non-hygienic by design. - -\(fn TEST-FORM THEN &rest ELSE)" - `(let ((it ,test-form)) - (if it - ,then - ,@else))) - (provide 'ogg-comment) ;;; ogg-comment.el ends here |