From: Teemu Likonen <tlikonen@iki.fi>
To: Shyam Nath <shyam@shyam.id.au>, help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Metaprogramming
Date: Sun, 15 Sep 2019 10:32:59 +0300 [thread overview]
Message-ID: <87blvmm2tw.fsf@iki.fi> (raw)
In-Reply-To: <16d32e8f08d.1191d211432772.321131096239642746@shyam.id.au>
[-- Attachment #1: Type: text/plain, Size: 930 bytes --]
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 (...) ...))
(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 ...)
;; ...
)
--
/// OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450
// https://keys.openpgp.org/search?q=tlikonen@iki.fi
/ https://keybase.io/tlikonen https://github.com/tlikonen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 694 bytes --]
next prev parent reply other threads:[~2019-09-15 7:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-15 3:13 Metaprogramming Shyam Nath
2019-09-15 7:32 ` Teemu Likonen [this message]
2019-09-15 9:39 ` Metaprogramming Shyam Nath
2019-09-15 13:22 ` Metaprogramming Stefan Monnier
2019-09-15 14:36 ` Metaprogramming Stefan Monnier
2019-09-15 19:03 ` Metaprogramming Emanuel Berg via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87blvmm2tw.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=help-gnu-emacs@gnu.org \
--cc=shyam@shyam.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.