[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/recomplete 802c85b02d 04/14: Replace cl-letf with advice m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/recomplete 802c85b02d 04/14: Replace cl-letf with advice macro |
Date: |
Thu, 7 Jul 2022 12:02:21 -0400 (EDT) |
branch: elpa/recomplete
commit 802c85b02d99bce4cf540ed4b716eaa39df45c4a
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Replace cl-letf with advice macro
This was causing an error which I didn't want to investigate,
prefer temporary advice over common-lisp.
---
recomplete.el | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/recomplete.el b/recomplete.el
index af547651f0..ad22572693 100644
--- a/recomplete.el
+++ b/recomplete.el
@@ -81,6 +81,17 @@
;; ---------------------------------------------------------------------------
;; Generic Functions/Macros
+(defmacro recomplete--with-advice (fn-orig where fn-advice &rest body)
+ "Execute BODY with advice added WHERE using FN-ADVICE temporarily added to
FN-ORIG."
+ `
+ (let ((fn-advice-var ,fn-advice))
+ (unwind-protect
+ (progn
+ (advice-add ,fn-orig ,where fn-advice-var)
+ ,@body)
+ (advice-remove ,fn-orig fn-advice-var))))
+
+
;; See: https://emacs.stackexchange.com/a/54412/2418
(defmacro recomplete--with-undo-collapse (&rest body)
"Like `progn' but perform BODY with undo collapsed."
@@ -114,13 +125,12 @@
(declare (indent 1))
`
(let ((temp-message-list (list)))
- (cl-letf
- (
- ((symbol-function 'message)
- (lambda (&rest args)
- ;; Only check if non-null because this is a signal not to log at
all.
- (when message-log-max
- (push (apply 'format-message args) temp-message-list)))))
+ (recomplete--with-advice 'message
+ :override
+ (lambda (&rest args)
+ ;; Only check if non-null because this is a signal not to log at all.
+ (when message-log-max
+ (push (apply #'format-message args) temp-message-list)))
(unwind-protect
(progn
,@body)
@@ -205,16 +215,15 @@ Argument FN-CACHE stores the result for reuse."
(pcase-let ((`(,result-choices ,word-beg ,word-end) (or fn-cache '(nil nil
nil))))
(unless result-choices
- (cl-letf
- (
- ((symbol-function 'ispell-command-loop)
- (lambda (miss _guess _word start end)
- (when miss
- (setq result-choices miss)
- (setq word-beg (marker-position start))
- (setq word-end (marker-position end))
- ;; Return the word would make the correction, we do this
ourselves next.
- nil))))
+ (recomplete--with-advice 'ispell-command-loop
+ :override
+ (lambda (miss _guess _word start end)
+ (when miss
+ (setq result-choices miss)
+ (setq word-beg (marker-position start))
+ (setq word-end (marker-position end))
+ ;; Return the word would make the correction, we do this ourselves
next.
+ nil))
(ispell-word))
(when result-choices
- [nongnu] branch elpa/recomplete created (now 021ca9b047), ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 80361184ad 06/14: Cleanup: docstring width, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 8b794d1947 08/14: Cleanup: use defgroup, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 8de8362858 03/14: readme: minor update, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 9bf8222e31 09/14: Fix undo-collapse macro, use back-ported emacs 29.1 macro, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete d0e61f19a2 01/14: Initial working version., ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete f831f61797 02/14: readme: add melpa link, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 802c85b02d 04/14: Replace cl-letf with advice macro,
ELPA Syncer <=
- [nongnu] elpa/recomplete ef800da3ff 05/14: Cleanup: formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 9d64b65855 10/14: Cleanup: use window-body-width, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 28a7dbd533 11/14: readme: uncomment installation section, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 2b38ca25e3 12/14: Add optional argument to step onto the second item when completing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 48432904b2 07/14: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete d0d3809294 13/14: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07
- [nongnu] elpa/recomplete 021ca9b047 14/14: Change URL to codeberg, ELPA Syncer, 2022/07/07