summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorJoakim Verona <joakim@verona.se>2015-01-25 02:11:31 +0100
committerJoakim Verona <joakim@verona.se>2015-01-25 02:11:31 +0100
commite5087278b9bcab5847ce63d80c0d74c27f50e719 (patch)
treec9ad8959e81033cb3423a25496ea4c411b212461 /lisp/emacs-lisp
parentbdd672b275034e8c1c65992f2e21dac7cc6eba60 (diff)
parentbce27d884521832a62837b113f4e681974cdaccb (diff)
downloademacs-e5087278b9bcab5847ce63d80c0d74c27f50e719.tar.gz
emacs-e5087278b9bcab5847ce63d80c0d74c27f50e719.tar.bz2
emacs-e5087278b9bcab5847ce63d80c0d74c27f50e719.zip
merge master
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-generic.el18
-rw-r--r--lisp/emacs-lisp/find-func.el2
2 files changed, 14 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index f214faff237..095f1e5d582 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -462,9 +462,12 @@ for all those different tags in the method-cache.")
(gethash (cons generic-name mets-by-qual)
cl--generic-combined-method-memoization)
(cond
- ((null mets-by-qual) (lambda (&rest args)
- (apply #'cl-no-applicable-method
- generic-name args)))
+ ((null mets-by-qual)
+ (lambda (&rest args)
+ (apply #'cl-no-applicable-method generic-name args)))
+ ((null (alist-get :primary mets-by-qual))
+ (lambda (&rest args)
+ (apply #'cl-no-primary-method generic-name args)))
(t
(let* ((fun (lambda (&rest args)
;; FIXME: CLOS passes as second arg the "calling method".
@@ -475,8 +478,6 @@ for all those different tags in the method-cache.")
;; . QUALIFIER) USE-CNM . FUNCTION) entry from the method
;; table, but the caller wouldn't be able to do much with
;; it anyway. So we pass nil for now.
- ;; FIXME: signal `no-primary-method' if there's
- ;; no primary.
(apply #'cl-no-next-method generic-name nil args)))
;; We use `cdr' to drop the `uses-cnm' annotations.
(before
@@ -546,6 +547,7 @@ for all those different tags in the method-cache.")
(define-error 'cl-no-method "No method for %S")
(define-error 'cl-no-next-method "No next method for %S" 'cl-no-method)
+(define-error 'cl-no-primary-method "No primary method for %S" 'cl-no-method)
(define-error 'cl-no-applicable-method "No applicable method for %S"
'cl-no-method)
@@ -559,6 +561,11 @@ for all those different tags in the method-cache.")
(cl-defmethod cl-no-applicable-method (generic &rest args)
(signal 'cl-no-applicable-method `(,generic ,@args)))
+(cl-defgeneric cl-no-primary-method (generic &rest args)
+ "Function called when a method call finds no primary method.")
+(cl-defmethod cl-no-primary-method (generic &rest args)
+ (signal 'cl-no-primary-method `(,generic ,@args)))
+
(defun cl-call-next-method (&rest _args)
"Function to call the next applicable method.
Can only be used from within the lexical body of a primary or around method."
@@ -727,6 +734,7 @@ Can only be used from within the lexical body of a primary or around method."
;; (foo 'major-mode toto titi)
;;
;; FIXME: Better would be to do that via dispatch on an "implicit argument".
+;; E.g. (cl-defmethod foo (y z &context (major-mode text-mode)) ...)
;; (defvar cl--generic-major-modes (make-hash-table :test #'eq))
;;
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 6c9c798bc16..7ea13d4637b 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -59,7 +59,7 @@
(concat
"^\\s-*(\\(def\\(ine-skeleton\\|ine-generic-mode\\|ine-derived-mode\\|\
ine\\(?:-global\\)?-minor-mode\\|ine-compilation-mode\\|un-cvs-mode\\|\
-foo\\|\\(?:[^icfv]\\|g[^r]\\)\\(\\w\\|\\s_\\)+\\*?\\)\\|easy-mmode-define-[a-z-]+\\|easy-menu-define\\|\
+foo\\|\\(?:[^icfgv]\\|g[^r]\\)\\(\\w\\|\\s_\\)+\\*?\\)\\|easy-mmode-define-[a-z-]+\\|easy-menu-define\\|\
menu-bar-make-toggle\\)"
find-function-space-re
"\\('\\|\(quote \\)?%s\\(\\s-\\|$\\|\(\\|\)\\)")