* with-wrapper-hook is obsolete; how to replace it? @ 2016-05-15 17:01 Paul Eggert 2016-05-15 18:43 ` Stefan Monnier 2016-05-16 17:40 ` Stefan Monnier 0 siblings, 2 replies; 5+ messages in thread From: Paul Eggert @ 2016-05-15 17:01 UTC (permalink / raw) To: Emacs Development When I run ‘make compile-always’ from the lisp subdirectory I see diagnostics like this: In buffer-substring--filter: simple.el:4058:52:Warning: ‘with-wrapper-hook’ is an obsolete macro (as of 24.4); use a <foo>-function variable modified by ‘add-function’. How do I alter the code to use add-function instead? It's not immediately obvious. That is, if there is source code like this: (with-wrapper-hook filter-buffer-substring-functions (beg end delete) BODY) where filter-buffer-substring-functions is defined like this: (defvar filter-buffer-substring-functions nil "This variable is a wrapper hook around `buffer-substring--filter'.") then what should I replace the source code with? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: with-wrapper-hook is obsolete; how to replace it? 2016-05-15 17:01 with-wrapper-hook is obsolete; how to replace it? Paul Eggert @ 2016-05-15 18:43 ` Stefan Monnier 2016-05-16 18:18 ` Paul Eggert 2016-05-16 17:40 ` Stefan Monnier 1 sibling, 1 reply; 5+ messages in thread From: Stefan Monnier @ 2016-05-15 18:43 UTC (permalink / raw) To: emacs-devel > How do I alter the code to use add-function instead? > It's not immediately obvious. That is, if there is source code like this: I don't think you can do it in a backward-compatible way. Which is why buffer-substring--filter still uses with-wrapper-hook (but only to implement the obsolete filter-buffer-substring-functions variable). > then what should I replace the source code with? The replacement is that instead of using add-hook on filter-buffer-substring-functions, clients should now use add-function on filter-buffer-substring-function. Stefan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: with-wrapper-hook is obsolete; how to replace it? 2016-05-15 18:43 ` Stefan Monnier @ 2016-05-16 18:18 ` Paul Eggert 2016-05-16 18:25 ` Stefan Monnier 0 siblings, 1 reply; 5+ messages in thread From: Paul Eggert @ 2016-05-16 18:18 UTC (permalink / raw) To: Stefan Monnier, emacs-devel [-- Attachment #1: Type: text/plain, Size: 504 bytes --] On 05/15/2016 11:43 AM, Stefan Monnier wrote: > I don't think you can do it in a backward-compatible way. > Which is why buffer-substring--filter still uses with-wrapper-hook (but > only to implement the obsolete filter-buffer-substring-functions variable). OK, thanks, how about the attached patch instead? The idea is to pacify the byte compiler without attempting to use add-function, by creating an internal-use-only version of the obsolete macro, a version that does not generate the warnings. [-- Attachment #2: with-wrapper-hook.diff --] [-- Type: text/x-patch, Size: 2480 bytes --] diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 7814ea2..163dc8e 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -848,7 +848,7 @@ abbrev--default-expand "Default function to use for `abbrev-expand-function'. This respects the wrapper hook `abbrev-expand-functions'. Calls `abbrev-insert' to insert any expansion, and returns what it does." - (with-wrapper-hook abbrev-expand-functions () + (subr--with-wrapper-hook-no-warnings abbrev-expand-functions () (pcase-let ((`(,sym ,name ,wordstart ,wordend) (abbrev--before-point))) (when sym (let ((startpos (copy-marker (point) t)) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 1ee05d3..9190c1f 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1970,7 +1970,7 @@ completion--in-region "Default function to use for `completion-in-region-function'. Its arguments and return value are as specified for `completion-in-region'. This respects the wrapper hook `completion-in-region-functions'." - (with-wrapper-hook + (subr--with-wrapper-hook-no-warnings ;; FIXME: Maybe we should use this hook to provide a "display ;; completions" operation as well. completion-in-region-functions (start end collection predicate) diff --git a/lisp/simple.el b/lisp/simple.el index e257062..65664c9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4061,7 +4061,8 @@ buffer-substring--filter This respects the wrapper hook `filter-buffer-substring-functions', and the abnormal hook `buffer-substring-filters'. No filtering is done unless a hook says to." - (with-wrapper-hook filter-buffer-substring-functions (beg end delete) + (subr--with-wrapper-hook-no-warnings + filter-buffer-substring-functions (beg end delete) (cond ((or delete buffer-substring-filters) (save-excursion diff --git a/lisp/subr.el b/lisp/subr.el index 0fa6404..438f00a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1546,6 +1546,10 @@ with-wrapper-hook (declare (indent 2) (debug (form sexp body)) (obsolete "use a <foo>-function variable modified by `add-function'." "24.4")) + `(subr--with-wrapper-hook-no-warnings ,hook ,args ,@body)) + +(defmacro subr--with-wrapper-hook-no-warnings (hook args &rest body) + "Like (with-wrapper-hook HOOK ARGS BODY), but without warnings." ;; We need those two gensyms because CL's lexical scoping is not available ;; for function arguments :-( (let ((funs (make-symbol "funs")) ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: with-wrapper-hook is obsolete; how to replace it? 2016-05-16 18:18 ` Paul Eggert @ 2016-05-16 18:25 ` Stefan Monnier 0 siblings, 0 replies; 5+ messages in thread From: Stefan Monnier @ 2016-05-16 18:25 UTC (permalink / raw) To: emacs-devel > OK, thanks, how about the attached patch instead? Fine by me, Stefan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: with-wrapper-hook is obsolete; how to replace it? 2016-05-15 17:01 with-wrapper-hook is obsolete; how to replace it? Paul Eggert 2016-05-15 18:43 ` Stefan Monnier @ 2016-05-16 17:40 ` Stefan Monnier 1 sibling, 0 replies; 5+ messages in thread From: Stefan Monnier @ 2016-05-16 17:40 UTC (permalink / raw) To: emacs-devel [ Hmm... I can't seem to see my reply, so I'll send it again. ] > When I run ‘make compile-always’ from the lisp subdirectory I see diagnostics > like this: > In buffer-substring--filter: > simple.el:4058:52:Warning: ‘with-wrapper-hook’ is an obsolete macro (as of > 24.4); use a <foo>-function variable modified by ‘add-function’. > How do I alter the code to use add-function instead? Here's a translation table: +---------------------+-----------------+----------------+ | with-wrapper-hook | foo-functions | add-hook | +---------------------+-----------------+----------------+ | funcall | foo-function | add-function | +---------------------+-----------------+----------------+ This replacement has already been done in buffer-substring, but we still need to use the obsolete with-wrapper-hook in order to support the corresponding obsolete filter-buffer-substring-functions variable. Stefan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-16 18:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-15 17:01 with-wrapper-hook is obsolete; how to replace it? Paul Eggert 2016-05-15 18:43 ` Stefan Monnier 2016-05-16 18:18 ` Paul Eggert 2016-05-16 18:25 ` Stefan Monnier 2016-05-16 17:40 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).