Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use advice-add instead of obsolete defadvice #240

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions buttercup-compat.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; buttercup-compat.el --- Compatibility definitions for buttercup
;;; buttercup-compat.el --- Compatibility definitions for buttercup -*-lexical-binding:nil-*-

;; Copyright (C) 2015 Jorgen Schaefer
;; Copyright (C) 2015 Free Software Foundation, Inc.
Expand Down Expand Up @@ -29,8 +29,8 @@

;;; Code:

;;;;;;;;;;;;;;;;;;;;;
;; Introduced in 24.4
;;;;;;;;;;;;;;;;;;;;;;
;;; Introduced in 24.4

(when (not (fboundp 'define-error))
(defun define-error (name message &optional parent)
Expand All @@ -53,8 +53,8 @@ Defaults to `error'."
(delete-dups (copy-sequence (cons name conditions))))
(when message (put name 'error-message message)))))

;;;;;;;;;;;;;;;;;;;;;
;; Introduced in 25.1
;;;;;;;;;;;;;;;;;;;;;;
;;; Introduced in 25.1

(when (not (fboundp 'directory-files-recursively))
(defun directory-files-recursively (dir match &optional include-directories)
Expand Down Expand Up @@ -109,8 +109,8 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
(<= (car here) delay)))
(concat (format "%.2f" (/ delay (car (cddr here)))) (cadr here)))))))

;;;;;;;;;;;;;;;;;;;;;
;; Introduced in 26.1
;;;;;;;;;;;;;;;;;;;;;;
;;; Introduced in 26.1

(unless (fboundp 'file-attribute-modification-time)
(defsubst file-attribute-modification-time (attributes)
Expand All @@ -119,18 +119,17 @@ This is the time of the last change to the file's contents, and
is a Lisp timestamp in the style of `current-time'."
(nth 5 attributes)))

;;;;;;;;;;;;;;;;;;;;;
;; Introduced in 29.1
;;;;;;;;;;;;;;;;;;;;;;
;;; Introduced in 29.1

(unless (boundp 'backtrace-on-error-noninteractive)
(defvar backtrace-on-error-noninteractive nil
"Control early backtrace starting in Emacs 29."))

(provide 'buttercup-compat)
;;; buttercup-compat.el ends here

;; Local Variables:
;; indent-tabs-mode: nil
;; tab-width: 8
;; sentence-end-double-space: nil
;; End:
;;; buttercup-compat.el ends here
12 changes: 6 additions & 6 deletions buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,7 @@ Colorize parts of the output if COLOR is non-nil."
FMT and ARGS are passed to `format'."
(send-string-to-terminal (apply #'format fmt args)))


(defadvice display-warning (around buttercup-defer-warnings activate)
(defun buttercup--display-warning (fn type message &optional level buffer-name)
"Log all warnings to a special buffer while running buttercup specs.

Emacs' normal display logic for warnings doesn't mix well with
Expand All @@ -1956,8 +1955,10 @@ finishes."
(cl-letf
((warning-minimum-level :emergency)
((symbol-function 'message) 'ignore))
ad-do-it)
ad-do-it))
(funcall fn type message level buffer-name))
(funcall fn type message level buffer-name)))

(advice-add 'display-warning :around #'buttercup--display-warning)

(defconst buttercup-colors
'((black . 30)
Expand Down Expand Up @@ -2192,10 +2193,9 @@ ARG is ‘toggle’; disable otherwise."
(t (remove-hook 'after-load-functions #'buttercup-check-for-stale-elc))))

(provide 'buttercup)
;;; buttercup.el ends here

;; Local Variables:
;; indent-tabs-mode: nil
;; sentence-end-double-space: nil
;; tab-width: 8
;; End:
;;; buttercup.el ends here
Loading