~ubuntu-branches/ubuntu/vivid/howm/vivid

« back to all changes in this revision

Viewing changes to gfunc.el

  • Committer: Package Import Robot
  • Author(s): Youhei SASAKI
  • Date: 2014-03-09 15:58:58 UTC
  • mfrom: (1.1.5) (0.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20140309155858-3jqurl36z3kbxq53
Tags: 1.4.2-2
* Handling new emacsen-common
  - Install a compat file with emacsen-compat                               |
  - Add conflicts: emacsen-common (<< 2.0.0)                                |
  - Add postinst/prerm

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; gfunc.el --- support for generic function
2
 
;;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 
2
;;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
3
3
;;;   HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
4
4
;;; $Id: gfunc.el,v 1.16 2011-12-31 15:07:29 hira Exp $
5
5
;;;
95
95
       ,desc-str
96
96
       (gfunc-call (quote ,base-name) ,dispatchers-var args))))
97
97
 
98
 
(put 'gfunc-def 'lisp-indent-hook 2)
99
98
(defmacro gfunc-def (base-name args-declaration &optional description)
100
99
  "Define generic function like `gfunc-define-function'.
101
100
The only difference is omission of dispatchers; it must be specified
102
101
by `gfunc-with' outside."
 
102
  (declare (indent 2))
103
103
  `(gfunc-define-function ,base-name ,args-declaration ,*gfunc-dispatchers-var*
104
104
                          ,description))
105
105
 
106
 
(put 'gfunc-with 'lisp-indent-hook 1)
107
106
(defmacro gfunc-with (dispatchers-var &rest body)
108
107
  "With the defalut DISPATCHERS-VAR, execute BODY.
109
108
BODY is typically a set of `gfunc-def', and DISPATCHERS-VAR is used
110
109
as their dispatchers.
111
110
This macro cannot be nested."
 
111
  (declare (indent 1))
 
112
  ;; Be careful to etc/NEWS in Emacs 24.3 or
 
113
  ;; http://www.masteringemacs.org/articles/2013/03/11/whats-new-emacs-24-3/
 
114
  ;; "Emacs tries to macroexpand interpreted (non-compiled) files during load."
 
115
  (setq *gfunc-dispatchers-var* dispatchers-var)
112
116
  `(eval-and-compile
113
 
     ;; I want to use let instead of setq.
114
 
     ;; But, let doesn't work when this file is byte-compiled.
115
 
     ;; I don't understand the problem around macro and byte-compilation.
116
 
     (setq *gfunc-dispatchers-var* (quote ,dispatchers-var))
117
117
     ,@body))
118
 
;;      (let ((*gfunc-dispatchers-var* (quote ,dispatchers-var)))
119
 
;;        ,@body)))
120
118
 
121
119
(provide 'gfunc)
122
120