From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via CC-Mode-help Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: Last use of defadvice in Emacs Date: Thu, 07 Apr 2022 22:34:45 -0400 Message-ID: References: <834k35ctd4.fsf@gnu.org> <25167.38053.15113.49802@retriever.mtv.corp.google.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27266"; 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, acm@muc.de, eliz@gnu.org, emacs-devel@gnu.org To: "T.V Raman" Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Fri Apr 08 04:35:17 2022 Return-path: Envelope-to: sf-cc-mode-help@m.gmane-mx.org Original-Received: from lists.sourceforge.net ([216.105.38.7]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nceSy-0006so-JP for sf-cc-mode-help@m.gmane-mx.org; Fri, 08 Apr 2022 04:35:16 +0200 Original-Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nceSo-0007yX-5J; Fri, 08 Apr 2022 02:35:07 +0000 Original-Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nceSm-0007yP-Cf for cc-mode-help@lists.sourceforge.net; Fri, 08 Apr 2022 02:35:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:In-Reply-To:Date: References:Message-ID:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iOsVsm3Gyj9YPBKpaQOQIlXeoShCTOw8EcE1dN6RjWU=; b=PBQy28842RBf5Sa7oq7qzpO2V6 zgt3GHBO1rdaDpw//CJ6UyDljYG+Bhew53bGU/ULUzq8tjkJOZ+1nKCbgOrvjYLexdURr4l3l3OVR lFptWo7Zf9hbBNMcPTBlv4BmV0ngzV4bzNzu/t1/Zpbh0zss7NPNQFMq2T92l7gjIaY4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:In-Reply-To:Date:References:Message-ID:Subject: Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=iOsVsm3Gyj9YPBKpaQOQIlXeoShCTOw8EcE1dN6RjWU=; b=h6BPq4XhkBGWB/xM9x/OiK5wp1 Pl2Gfv3k8m54YZ5Z601AVgVh6O+RuhDdvpqBCFTyjf8oiX4J+ZC6gO3PbRZpdakO4z0ji8XxmXLD4 mTWGYEpdyszg9fAFDJXXkkuTECfA2pen9dQiidb3a77JyyHuH+ajphLrFtNsUN2wvdVQ=; Original-Received: from eggs.gnu.org ([209.51.188.92]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nceSj-009EoH-Jv for cc-mode-help@lists.sourceforge.net; Fri, 08 Apr 2022 02:35:05 +0000 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nceSZ-0006Gb-Q6; Thu, 07 Apr 2022 22:34:53 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 115294415DE; Thu, 7 Apr 2022 22:34:49 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 50A164415CB; Thu, 7 Apr 2022 22:34:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1649385287; bh=SJlMW9ztkxiPSjhOGrizQuDc5EVRCNi0g556laRB3VM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Che7Tj+NlkLZy+Nxhky3ce13YjUGZXm1t50/UG37YI37tTqGGw7l5J0E48YiekBxt nUBvU20lyVV/gTa0PxZ9ehk2MZkq/wGgcLZPNMqxTrD++ac8+jqazOA9w0UlcxnzlX Wo1JXyZwKo1JUYNIS++OFJScpJNPI2F7S+2yyHLW9WqbM9/uYKpRJxe9QXnJKonFtL uR0ZGAMOfJLyXK8fL6zCEeE4kBzHWGA7qz8VRi/7gdsXlGwvqJ1GS/tTprPwK1mHLt 7bDh5H9ACDxI8cb7gtoPkkeBR8gZKW+gNCGwKo5quLbHk40UPXgVXr8JFqd8eFZUeF a9YQPhCbCka4A== Original-Received: from pastel (unknown [45.72.221.51]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 143C0120680; Thu, 7 Apr 2022 22:34:47 -0400 (EDT) In-Reply-To: <25167.38053.15113.49802@retriever.mtv.corp.google.com> (T. V. Raman's message of "Thu, 7 Apr 2022 18:49:25 -0700") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Headers-End: 1nceSj-009EoH-Jv X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.io gmane.emacs.cc-mode.general:8301 gmane.emacs.devel:287914 Archived-At: > 1. ad-get-arg vs ad-get-argument: I've always used ad-get-arg -- > however for the last few years I've notied that ad-get-arg is > getting harder and harder to discover; for the last few years, > emacs always completes ad-get-arg to ad-get-argument. I personally > find ad-get-arg to be more idiomatic and easier to use. `ad-get-argument` is basically an internal function of `advice.el` so you never want to use it. But `ad-get-arg` (the thing you *do* need to use to access arguments) is not "defined" anywhere, neither as a function nor as a macro, so TAB completion will never know (and has never known) to use it. For kicks, try an advice like (defadvice next-line (before some-fun activate) (message "surprise: %S" '(ad-get-args 0))) > 2. Re ad-return-value -- I've almost never had to explicitly set > ad-return-value -- in around and after advice, I have always > returned ad-return-value and have never hit issues --- perhaps > because I've always wrappered my advice body in a let form -- > not sure. What kind of breakages happen when returning > ad-return-value vs explicitly setting ad-return-value at the end > of the advice body? You typically need to set it when you want to do: (defadvice some-function (around my-advice activate) (if (bla bla) (cons 1 ad-do-it) (do something else) (and return some value))) which needs to be something like: (defadvice some-function (around my-advice activate) (if (bla bla) (progn ad-do-it (push 1 ad-return-value)) (do something else) (setq ad-return-value (and return some value)))) > 3. I've avoided the complexity around preactivation vs > activation etc by always saying (... pre act comp) in all my > advice forms Not sure in which sense this "avoided the complexity". And most people reading your code won't know what it means, I'm afraid. Stefan