[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 41a7ebcbab 23/86: Cleanup: replace cl-letf with a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 41a7ebcbab 23/86: Cleanup: replace cl-letf with advice macro |
Date: |
Thu, 7 Jul 2022 12:03:40 -0400 (EDT) |
branch: elpa/spell-fu
commit 41a7ebcbabf650f3c68b9db66ca3ddfd1649a45f
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Cleanup: replace cl-letf with advice macro
Removes cl-lib use and avoids dealing with function symbol swapping.
---
spell-fu.el | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/spell-fu.el b/spell-fu.el
index bdfb68d6f4..cb7dc2f3f1 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -56,9 +56,10 @@
;; ---------------------------------------------------------------------------
;; Require Dependencies
-(require 'cl-lib) ;; For `cl-letf', although using `cl' is otherwise avoided.
-(require 'faces) ;; For `face-list-p'.
-(require 'ispell) ;; For variables we read `ispell-personal-dictionary' local
dictionary, etc.
+;; For `face-list-p'.
+(require 'faces)
+;; For variables we read `ispell-personal-dictionary' local dictionary, etc.
+(require 'ispell)
;; ---------------------------------------------------------------------------
@@ -145,36 +146,39 @@ Notes:
;; Helpers, not directly related to checking spelling.
;;
+(defmacro spell-fu--with-advice (fn-orig where fn-advice &rest body)
+ "Execute BODY with advice temporarily enabled."
+ `
+ (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))))
(defmacro spell-fu--with-message-prefix (prefix &rest body)
"Add text before the message output.
Argument PREFIX is the text to add at the start of the message.
Optional argument BODY runs with the message prefix."
(declare (indent 1))
- (let ((message-orig (make-symbol "--spell-fu--with-message-prefix--")))
- `
- (cl-letf*
- (
- (,message-orig (symbol-function 'message))
- ((symbol-function 'message)
- (lambda (arg &rest args)
- (apply ,message-orig (append (list (concat "%s" arg)) (list
,prefix) args)))))
- ,@body)))
+ `
+ (spell-fu--with-advice 'message
+ :around
+ (lambda (fn-orig arg &rest args)
+ (apply fn-orig (append (list (concat "%s" arg)) (list ,prefix) args)))
+ ,@body))
(defmacro spell-fu--with-add-hook-depth-override (depth-override &rest body)
"Support overriding the depth of a hook added by an indirect call.
Argument DEPTH-OVERRIDE the depth value to call `add-hook' with.
Optional argument BODY runs with the depth override."
(declare (indent 1))
- (let ((add-hook-orig (make-symbol
"--spell-fu--with-add-hook-depth-override--")))
- `
- (cl-letf*
- (
- (,add-hook-orig (symbol-function 'add-hook))
- ((symbol-function 'add-hook)
- (lambda (hook function &optional _depth local)
- (funcall ,add-hook-orig hook function ,depth-override local))))
- ,@body)))
+ `
+ (spell-fu--with-advice 'add-hook
+ :around
+ (lambda (fn-orig hook function &optional _depth local)
+ (funcall fn-orig hook function ,depth-override local))
+ ,@body))
(defmacro spell-fu--setq-expand-range-to-line-boundaries (point-start
point-end)
"Set POINT-START the the line beginning, POINT-END to the line end."
- [nongnu] elpa/spell-fu d0700095ea 28/86: Add header to cache loading & error checking for cache content, (continued)
- [nongnu] elpa/spell-fu d0700095ea 28/86: Add header to cache loading & error checking for cache content, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f6c849f860 30/86: Fix disabling spell-fu when used without a timer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 502d523b46 31/86: Fix unintended modification of the standard syntax table, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu e62cfc4f08 34/86: Add support for personal dictionary management, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 86d46cf63e 37/86: fix: encode word to utf8, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 9180a77865 48/86: Fix #15: don't enable (when used globally) for application buffers, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 41a133d119 52/86: Fix #16: Fails to spellcheck when whitespace-mode splits a word, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 7c2542e109 73/86: Merge branch 'multiple-dictionaries' into 'master', ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 50be652a6e 77/86: Fix overlay faces masking other faces (when checking faces-at-point), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu cbe5cd84c3 86/86: Correct URL, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 41a7ebcbab 23/86: Cleanup: replace cl-letf with advice macro,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 251e63eacc 29/86: readme: update, clarify TODO, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ad139f6fac 40/86: Cleanup: quiet checkdoc warning, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2caa9fc6f0 44/86: Update changelog, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f38bebefea 62/86: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 9587fa4b99 17/86: Add missing args (quiet checkdoc warnings), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 484b6bdf04 53/86: Fix disabling spell-fu-mode stopping the idle timer in other buffers, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 3230ff96f1 65/86: Cleanup: modified word ordering, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 96f72c35b1 38/86: Update spell-fu.el, correct package url., ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ac9c1581c8 45/86: readme: move details into top level section, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 646f40ba06 54/86: Cleanup: use 'when' instead of 'if', ELPA Syncer, 2022/07/07