emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup 07b1ee6 008/340: Add compatibility definition fo


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 07b1ee6 008/340: Add compatibility definition for define-error
Date: Thu, 16 Dec 2021 14:58:54 -0500 (EST)

branch: elpa/buttercup
commit 07b1ee68801e1744b09604bde9ee5e69ef626719
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>

    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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]