From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: with-wrapper-hook is obsolete; how to replace it? Date: Mon, 16 May 2016 11:18:41 -0700 Organization: UCLA Computer Science Department Message-ID: References: <5738AB51.8030401@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7AD0EA3622DA43D3CA17FF3C" X-Trace: ger.gmane.org 1463422748 781 80.91.229.3 (16 May 2016 18:19:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 May 2016 18:19:08 +0000 (UTC) To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 16 20:18:58 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b2N6U-0002no-L6 for ged-emacs-devel@m.gmane.org; Mon, 16 May 2016 20:18:55 +0200 Original-Received: from localhost ([::1]:46186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2N6U-0001LW-2T for ged-emacs-devel@m.gmane.org; Mon, 16 May 2016 14:18:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2N6P-0001EQ-He for emacs-devel@gnu.org; Mon, 16 May 2016 14:18:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2N6K-0006nh-5G for emacs-devel@gnu.org; Mon, 16 May 2016 14:18:48 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2N6J-0006mC-O2 for emacs-devel@gnu.org; Mon, 16 May 2016 14:18:43 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8626C1612EB; Mon, 16 May 2016 11:18:42 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iSbZl2BArrF4; Mon, 16 May 2016 11:18:41 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B32B71612F1; Mon, 16 May 2016 11:18:41 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id njfzewZ5YEXD; Mon, 16 May 2016 11:18:41 -0700 (PDT) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 959F71612EB; Mon, 16 May 2016 11:18:41 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:203867 Archived-At: This is a multi-part message in MIME format. --------------7AD0EA3622DA43D3CA17FF3C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------7AD0EA3622DA43D3CA17FF3C Content-Type: text/x-patch; name="with-wrapper-hook.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="with-wrapper-hook.diff" 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 -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")) --------------7AD0EA3622DA43D3CA17FF3C--