|
From: | Gabriele Nicolardi |
Subject: | bug#69573: Eager macro-expansion failure: (wrong-type-argument integer-or-marker-p nil) |
Date: | Wed, 6 Mar 2024 00:53:20 +0100 |
User-agent: | Mozilla Thunderbird |
Hi,
I have this code:
(defun make-search-sensitive-to-ifpmod-advice (orig-fun &rest args)
"Temporary advice the search functions to make them sensitive to
`isearch-filter-predicate'"
(let ((POINT (point)))
(catch 'filtered
(while (apply orig-fun args)
(let ((B (match-beginning 0))
(E (match-end 0)))
;; 1 - If all points in the region that matches the search
;; from the previous "search-command" meet the criteria
;; accepted by the filter, then the loop stops (`throw') and
;; returns the position `(point)`:
(when (funcall isearch-filter-predicate B E)
(throw 'filtered (point)))))
;; 2 - If the search is unsuccessful, or does not meet
;; the criteria accepted by the filter, then return to the
;; starting position and return the value `nil'.
(goto-char POINT)
nil)))
(defalias 'search-forward-ifpmod
(symbol-function 'search-forward)
"Copy of `search-forward' function (to be) adviced to obey to
`isearch-filter-predicate'")
(advice-add 'search-forward-ifpmod
:around
#'make-search-sensitive-to-ifpmod-advice)
(defalias 're-search-forward-ifpmod
(symbol-function 're-search-forward)
"Copy of `re-search-forward' function (to be) adviced to obey to
`isearch-filter-predicate'")
(defalias 'search-forward-regexp-ifpmod 're-search-forward-ifpmod)
;; The following breaks my minor-modes definitions
(advice-add 're-search-forward-ifpmod
:around
#'make-search-sensitive-to-ifpmod-advice)
I found that this particular code snippet:
(advice-add 're-search-forward-ifpmod
:around
#'make-search-sensitive-to-ifpmod-advice)
breaks my minor-modes definitions. E.g. if I evaluate the code above and later on the following code (MWE):
(defun mwe-function-1 ()
"MWE function 1"
(interactive)
(message "function 1 executed"))
(define-minor-mode mwe-mode
"MWE mode"
:init-value nil
:lighter (:eval (propertize " MWE "
'face '(:foreground
"RoyalBlue"
:background
"DarkGoldenrod1")))
:keymap
`(
(,(kbd "<C-kp-1>") . mwe-function)
)
(if mwe-mode
(easy-menu-define mwe-menu mwe-mode-map
"MWE"
'("MWE mode"
;; I want the menu on mode-line only:
:visible (not (eq (framep (selected-frame)) 'x))
["mwe-function-1" mwe-function-1
:help "mwe-function 1"]
))
t))
I get this error:
internal-macroexpand-for-load: Eager macro-expansion failure: (wrong-type-argument integer-or-marker-p nil)
emacs -Q
add-advice
codeDid I make a mistake
in the add-advice
usage or is it a bug?
Best regards,
Gabriele Nicolardi
[Prev in Thread] | Current Thread | [Next in Thread] |