branch: elpa/buttercup
commit 07b1ee68801e1744b09604bde9ee5e69ef626719
Author: Jorgen Schaefer <[email protected]>
Commit: Jorgen Schaefer <[email protected]>
Add compatibility definition for define-error
---
buttercup.el | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/buttercup.el b/buttercup.el
index c226b6a..55f57dd 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -29,6 +29,31 @@
(require 'cl)
+;;;;;;;;;;;;;;;;;
+;;; Compatibility
+
+;; Introduced in 24.4
+(when (not (fboundp 'define-error))
+ (defun define-error (name message &optional parent)
+ "Define NAME as a new error signal.
+MESSAGE is a string that will be output to the echo area if such an error
+is signaled without being caught by a `condition-case'.
+PARENT is either a signal or a list of signals from which it inherits.
+Defaults to `error'."
+ (unless parent (setq parent 'error))
+ (let ((conditions
+ (if (consp parent)
+ (apply #'append
+ (mapcar (lambda (parent)
+ (cons parent
+ (or (get parent 'error-conditions)
+ (error "Unknown signal `%s'"
parent))))
+ parent))
+ (cons parent (get parent 'error-conditions)))))
+ (put name 'error-conditions
+ (delete-dups (copy-sequence (cons name conditions))))
+ (when message (put name 'error-message message)))))
+
;;;;;;;;;;
;;; expect