From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Example use of macro to minimize and generalize the code Date: Tue, 01 Jun 2021 16:02:13 +0200 Message-ID: <87fsy1y97e.fsf@web.de> References: <87mtsbd31w.fsf@zoho.eu> <87a6oad81r.fsf@zoho.eu> <87y2buscef.fsf@web.de> <87k0nes9s0.fsf@web.de> <878s3us8le.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33383"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 01 16:03:06 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lo4z4-0008WS-5e for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 01 Jun 2021 16:03:06 +0200 Original-Received: from localhost ([::1]:46586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo4z3-0007en-49 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 01 Jun 2021 10:03:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo4yJ-0007bO-Ir for help-gnu-emacs@gnu.org; Tue, 01 Jun 2021 10:02:19 -0400 Original-Received: from mout.web.de ([212.227.17.12]:45419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo4yH-0005e8-3Q for help-gnu-emacs@gnu.org; Tue, 01 Jun 2021 10:02:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1622556134; bh=HPLcC1AqGw4ojtH1pO9xlKOoIGHJSbdly6vKhr354Vc=; h=X-UI-Sender-Class:From:To:Subject:References:Date:In-Reply-To; b=VJZ6JKZfsy6GpwlcbZ/otYftFgo/Cnki3v/JNrwQGfEaSCIN+tQdHC2SSOEiiTbP5 LzKHoTNlgeQrOEsv42C/mFn23rPeZnB6OqykM71J+Whpi9iuOKHNgLklrXBkczZMFw aaaKRrZx6GQYAR3yOfSmSOzHygw7TC4eRxnmWYuA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([94.218.219.0]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Mg7Dt-1m0V1P2PX3-00NOcG; Tue, 01 Jun 2021 16:02:14 +0200 In-Reply-To: (Jean Louis's message of "Tue, 1 Jun 2021 04:25:33 +0300") X-Provags-ID: V03:K1:A4L8xy0SX8J8u9pgTsOO5SLkhUAMiBxscH1UP2gO2Hbsn1MqHPw LtIiPEFyRJ0l3BacWiWFsrOEPevrqdVj6GQ9I31wNo8Mka7wGAtBvNOX3pdVrRs9BhLwsX/ 0dgD8n46Nkk9NVsBGE1Nz2cAcHLrCFVTyU0Ny/pLoslwYGxYyGJU+5S57+7HPCnFNPrkQxv lcfGfyD4FXgsS+oEhmIYA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ozzp4XiVuhs=:30stHMq+h3IazyiCBNKT31 SBYM471WeLCYXh3oXtWS6ntQhsW1V+Zt1S6ynF+v4AcydVUIT1HJc6y60WdpCvg+FPW7OfVgH 09wGVC/qLs5EE7MxbJ0GNFK2hNVOrAy1npbHifUrblqFwBuvtuL5inRMLHuYaL3l9Wm4/DLiD R6RWdxOT5qHHkkoYnBPH7jBkmHAlsZdrskk0PrQhjF+imBsd6VpAYX4J+ml/oA/TKj7yAkU97 xuYans/a3rhE2/KJE3tSYXKS1FV80Ub5Amt16iBQFDMIiiwwyZ43SWp3xXF0twm+BUOdsR/69 a5rdtIf/qHhVnnTsagU+opG2z9CHwXOR7fErp5cSoxhC+cfOjOS50IVDzM8pkgfixoMROA4fR HerKk01f6lqct+fNTPwl0geFsWjUtxfDrryoAsVYN1NNJh6Jpuf0FtEwwMXAH1pQAM2hOKPCd SnaN+Cysy8u2TDqZrICX47xVBmX3cH/u1g1KGYdBWwtEumggsUNJJz4vfYSr9a3JAAHJmm1k9 Xngm32rVI7bW81XUsO9FJCO+ZYbrj5/whmNdMUtz5pmtMf2Va2stK9CdayphcZgEiF0eebX6n YFnoWj8N/Mai69r3jj7etc9Bncu1R9UxuS8F/ASJyIUin0UkmZu0eMhq/xWDtB8pvAvs4SPp0 ENunedncAINe5ni5eH0nf+zX5wP6H6YlDhbvj3bQTkJCVyVFgdlpNAXqahBaUCCzRMBsDtWOL ZpHj4l7Twj6yKs6v9rSS+5MSQZjfoA9tpiOASZPkOHRGI35NXIhP93kVj9bxgYrJtSAH/Jph Received-SPF: pass client-ip=212.227.17.12; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130449 Archived-At: Jean Louis writes: > (defmacro when-tabulated-id (table &rest body) > (declare (indent 2) (debug t)) > ;;(ignore id) > `(if id > (progn > ,@body) > (if (or (eq ,table 'any) > (string-equal ,table rcd-current-table)) > (let ((id (tabulated-list-get-id))) > (if id > (progn ,@body) > (message "Did not get ID"))) > (message "This function is for table `%s' only" ,table)))) Yes, better. The downside now is that using the macro hides the fact that the code depends on the id, and the resulting code is (still) hard to understand. Why don't you consider to make the id a real argument? Regards, Michael.