From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: Metaprogramming Date: Sun, 15 Sep 2019 10:32:59 +0300 Message-ID: <87blvmm2tw.fsf@iki.fi> References: <16d32e8f08d.1191d211432772.321131096239642746@shyam.id.au> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="50528"; mail-complaints-to="usenet@blaine.gmane.org" To: Shyam Nath , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 15 09:33:30 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i9P2G-000D3W-OG for geh-help-gnu-emacs@m.gmane.org; Sun, 15 Sep 2019 09:33:28 +0200 Original-Received: from localhost ([::1]:53296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9P2F-000592-Lj for geh-help-gnu-emacs@m.gmane.org; Sun, 15 Sep 2019 03:33:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47604) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9P24-00058v-VK for help-gnu-emacs@gnu.org; Sun, 15 Sep 2019 03:33:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9P23-0001Sv-1L for help-gnu-emacs@gnu.org; Sun, 15 Sep 2019 03:33:16 -0400 Original-Received: from mail.kapsi.fi ([2001:67c:1be8::25]:41357) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i9P22-0001Rk-Gv for help-gnu-emacs@gnu.org; Sun, 15 Sep 2019 03:33:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:To:From:Sender:Reply-To:Cc: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=ZKLvuhXSKTowIdxqXiXXwjHUxNuqX+dkzUoI7LC3PU0=; b=EbX70rhvn1HnK3ylF2mM9GCVYK ePqiwggU5yRRVwqdC4jkkQHbSOIsNLoVtU6j8laqwbcviJQxb6ntly5DBUNxv3Er50DKc2mwzoPDi CO5MPqe2x89D5IndUZAIn9rvn2FWIFDUqW5K5z8zJ95n6BczN38I+ajMmublMzi1lBg+eZYAxFicr UjZv/uz29MSHjtpEnR/QKvQqidF2xmfIDs7zk95gjwkKEte2dIIfQ+3uXLJ0BUTnwZFYTBz+53ZPU grsMBUUJO+iRrR3zjlKOmFKvOUTmjkXwzIgMhVozjiYIX7l/49P13XC5a6n8OZGNXQq8ZCwJEe/CK VAaHO3dw==; Original-Received: from mobile-access-bceed7-245.dhcp.inet.fi ([188.238.215.245] helo=mithlond) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i9P1w-0001zj-3j; Sun, 15 Sep 2019 10:33:08 +0300 In-Reply-To: <16d32e8f08d.1191d211432772.321131096239642746@shyam.id.au> X-SA-Exim-Connect-IP: 188.238.215.245 X-SA-Exim-Mail-From: tlikonen@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:67c:1be8::25 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121514 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Shyam Nath [2019-09-15T13:13:09+10] wrote: > I want to redefine functions by manipulating the pre-existing > function; is there any way to do this? You can keep the original function code in a variable. Use that variable to define the global function first and later all modified versions of it. (defvar function-code (lambda (...) ...)) =20=20=20=20 (setf (symbol-function 'modifiable-function) function-code) I think it is better to keep your defuns static and make them call other functions which are stored in a variable or other predefined place. (defvar modifiable-function (lambda (...) ...)) (defun static-function (...) ;; ... (funcall modifiable-function ...) ;; ... ) =2D-=20 /// OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450 // https://keys.openpgp.org/search?q=3Dtlikonen@iki.fi / https://keybase.io/tlikonen https://github.com/tlikonen --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFEBAEBCgAuFiEEkhZiiC54Bnj5a16Skzo1BB5+rVEFAl196SsQHHRsaWtvbmVu QGlraS5maQAKCRCTOjUEHn6tUZniB/48DY1ypdoY20GHWdLWqk4Aia9EFxnOidZ7 mihE4T51wSObHJ667G7vUThspaOY9+XA5Fx2lA4mKZznWFsbQx3J8zfUZeg2DYOj cgUB+QZtlEpwYqXf7HIswXPlAe5/JI3Lh2iy2iBpEoliYaNVU/UqwLNnzeXEj4Xt zf6opz7lhJX5NP8if0wZUwFcBnd87+FXb3Anw3/g+qVY0spR3ltgwroJ3t1N7RAa qVq/c9z1LiglfNKESEvSipEPaVwhyJ2Sd38/Thc6t/J+I5f/J61lPTehAQsD6n6l KsJodW4ibJ4n9jxACd+m7iDQGN7Vfu65dKu8pLvmzod1xIN5n7GYiIYEARYIAC4W IQTJW2wqtelxC1gHdbitnXWr7pTCcwUCXX3pMxAcdGxpa29uZW5AaWtpLmZpAAoJ EK2ddavulMJzXU4A/2ijHYspbjtEQEcFuiDgoTf6KYpLpxqiZtPIf6fpl6sgAQDB JRVgEsaXo1flr7bAPYiPfvYWUBRCDW0nJNm+DxlEAA== =ytAx -----END PGP SIGNATURE----- --=-=-=--