unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Is there symbol-plist functionality in Emacs Lisp?
Date: Sat, 8 May 2021 19:36:43 +0300	[thread overview]
Message-ID: <YJa+GxByFKdZCZG9@protected.localdomain> (raw)
In-Reply-To: <jwvo8dl44d1.fsf-monnier+emacs@gnu.org>

* Stefan Monnier <monnier@iro.umontreal.ca> [2021-05-08 18:48]:
> >> > While `symbol-plist' in Common Lisp returns the definition as below.
> >> Is that really true of Common Lisp, or just of some implementations?
> >> I can't seem to find that documented in the CLHS.
> > True, it works just in CLISP. Is there equivalent in Emacs that I can
> > get a function definition this way?
> 
> Depends what you mean by "function definition", IOW depends what you
> want to do with it.  There `symbol-function` of course, and there are
> also things like `find-function-noselect`.

Thank you.

When I was working in Common Lisp REPL, I have used CLISP, and it was
handy to save a function that is deleted from file.

(defun save-function ()
  "Saves function at point"
  (interactive)
  (let ((function (function-called-at-point)))
    (when (and (symbolp function)
	       (y-or-n-p (format "Save `%s'" (symbol-name function))))
      (let* ((fun (symbol-function function))
	     (type (car fun))
	     (file (concat "/tmp/function-" (symbol-name function) ".el")))
    (cond ((eq type 'lambda) (setq fun (append (list 'defun function) (cdr fun))))
	  ((eq type 'closure) (setq fun (append (list 'defun function) (nthcdr 2 fun)))))
    (message (string-to-file-force (prin1-to-string fun) file))))))

(defun save-function-delete ()
  (save-function)
  (beginning-of-line)
  (mark-sexp)
  (delete-active-region))

Now if I wish to delete a function, but save it before hand, I would
go to "save-function-delete" and invoke the key to run
`safe-function-delete'

It would save itself from memory, not from file as for future possible
introspection and delete it from the file in the same time.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




      reply	other threads:[~2021-05-08 16:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08  7:28 Is there symbol-plist functionality in Emacs Lisp? Jean Louis
2021-05-08 13:54 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 14:38   ` FW: [External] : " Drew Adams
2021-05-08 16:23     ` Jean Louis
2021-05-08 23:13     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 15:32   ` Jean Louis
2021-05-08 15:47     ` Stefan Monnier
2021-05-08 16:36       ` Jean Louis [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YJa+GxByFKdZCZG9@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).