help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there symbol-plist functionality in Emacs Lisp?


From: Jean Louis
Subject: Re: Is there symbol-plist functionality in Emacs Lisp?
Date: Sat, 8 May 2021 19:36:43 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* 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 via email to

[Prev in Thread] Current Thread [Next in Thread]