From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "T.V Raman" Newsgroups: gmane.emacs.devel Subject: Re: Last use of defadvice in Emacs Date: Mon, 04 Apr 2022 13:08:15 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=gb18030 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34805"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 04 22:09:08 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbT0d-0008qR-Nz for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Apr 2022 22:09:07 +0200 Original-Received: from localhost ([::1]:58104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbT0c-0000Nx-BW for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Apr 2022 16:09:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbSzv-00087S-ME for emacs-devel@gnu.org; Mon, 04 Apr 2022 16:08:23 -0400 Original-Received: from [2607:f8b0:4864:20::436] (port=36647 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbSzu-0007ys-8C for emacs-devel@gnu.org; Mon, 04 Apr 2022 16:08:23 -0400 Original-Received: by mail-pf1-x436.google.com with SMTP id z16so10029469pfh.3 for ; Mon, 04 Apr 2022 13:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=UcBEp3j44SltZZq9+4JNcBWnOv2x+gHQbzPCGviyg68=; b=rpRnCcmTmrFUoyVkgkVKrL06FzoVJsraW/7sq741UNNhXA0jWRGDfZ++fj7B/m4qhF pmIdUiPluzm8nn1PfkvCtG+S63T97uA+6fVgFUHP2kC1wXpVU5QxF2rWIPmb96la8Xqi 2AzGLBxUmkXY4GiKPwJ4WIGSP8U6tId9SyqeS13Vtyk982blORBKqRJVLeL3PT/h2Eac iK6Ib+Nz1ZiSUGVCJlqYNnPh2zx8G9rodBWEu8H+spZ9dlH1OWz8wFuu4I2fjruXuNAA CtkyL9WjP/Miu7BNrcLZUW8N5rPaV/ho46iC0Fq5XorEwhIswzosLhfHVj7NVUYXFiDX HiGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=UcBEp3j44SltZZq9+4JNcBWnOv2x+gHQbzPCGviyg68=; b=KU20JQwYKnH7WKKi9AmWaolKlMbmF4vpGw3eGwbxf6qoIquTjQ4Sk/nYwIdePZ0iNJ BdqPvVBPLhwIiK8tPLLLXIwa0idnvao4Z0dIhTBZFZgDmzAdfoMNoJ0Or9v9t43tL4Fj UDc0hr/Iyebx/qQWG9i3LbXB360Bjett+YcbvdKEVO+pw8ulOl0V+yetF9ksPxd57WFv FZmhE7k3QOxvdp4o6mVhGfjDMu+AUnGn2Gukkeq/pgvVUBVk/bUtGWA7sQKqS+K47iIs yoJpVA4aMh/S7HMW2hl4uvPk78b+18LunL4X4q7biKA81UptBHjl0P4gKn9RvNgoV3OD dFWQ== X-Gm-Message-State: AOAM533mrESOi+s9MvjZf6Y1xvL5AVcro3DxBXAs//gAHr8w3725oYvI JDHyNZlwIoOhGWfX0I9RdBcWf7ZK6QH/Bw== X-Google-Smtp-Source: ABdhPJxYw2rvJpgd/XBpTxvh5o5UcVvh6NYDrnVBni4q23rlADkXgg5pu/tMU72zd7q4+pmDUovitg== X-Received: by 2002:a63:9711:0:b0:398:5cf2:20bc with SMTP id n17-20020a639711000000b003985cf220bcmr1287949pge.480.1649102898904; Mon, 04 Apr 2022 13:08:18 -0700 (PDT) Original-Received: from raman-glaptop (c-24-4-174-65.hsd1.ca.comcast.net. [24.4.174.65]) by smtp.gmail.com with ESMTPSA id x6-20020a17090aa38600b001ca2f87d271sm11439pjp.15.2022.04.04.13.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 13:08:18 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 04 Apr 2022 15:49:16 -0400") X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::436 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=raman@google.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -161 X-Spam_score: -16.2 X-Spam_bar: ---------------- X-Spam_report: (-16.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:287775 Archived-At: Stefan Monnier writes: I assume it's still okay and supported for external Emacs packages to use defadvice. > Hi Alan, > > The patch below replaces the last remaining use of `defadvice` in Emacs > (well, except for Org where this has already been fixed upstream but > we're waiting for the change to trickle down to `master`). > > It's guaranteed 100% untested, tho. > > It's kinda weird in that this `defadvice` is not actually used in > current Emacsen, but we still have to macro-expand it, so the new code > macroexpands to the corresponding use of `advice-add` even tho that also > won't be used. > > > Stefan > > > diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el > index 957a0b8a7c5..759a01f1dd8 100644 > --- a/lisp/progmodes/cc-mode.el > +++ b/lisp/progmodes/cc-mode.el > @@ -2563,14 +2563,18 @@ c-extend-after-change-region > (cons c-new-BEG c-new-END)) >=20=20 > ;; Emacs < 22 and XEmacs > +(defun c--fl-extend-region (args) > + ;; Make sure that any string/regexp is completely font-locked. > + (if (not c-buffer-is-cc-mode) > + args > + (list c-new-BEG c-new-END (cddr args)))) > + > (defmacro c-advise-fl-for-region (function) > (declare (debug t)) > - `(defadvice ,function (before get-awk-region activate) > - ;; Make sure that any string/regexp is completely font-locked. > - (when c-buffer-is-cc-mode > - (save-excursion > - (ad-set-arg 1 c-new-END) ; end > - (ad-set-arg 0 c-new-BEG))))) ; beg > + (if (fboundp 'advice-add) > + `(advice-add ',function :filter-args #'c--fl-extend-region) > + `(defadvice ,function (before get-awk-region activate) > + (ad-set-args 0 (c--fl-extend-region (ad-get-args 0)))))) >=20=20 > (unless (boundp 'font-lock-extend-after-change-region-function) > (c-advise-fl-for-region font-lock-after-change-function) > > --=20 Thanks, --Raman(I Search, I Find, I Misplace, I Research) =817=A94 Id: kg:/m/0285kf1 =950=DC8