home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / edit-doc.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  1.3 KB  |  40 lines

  1. ;From utkcs2!emory!samsung!sdd.hp.com!decwrl!ads.com!saturn!ccm Thu Jul 12 13:36:20 EDT 1990
  2. ;Article 3181 of gnu.emacs:
  3. ;Path: utkcs2!emory!samsung!sdd.hp.com!decwrl!ads.com!saturn!ccm
  4. ;>From: ccm@warhol.ads.com (Chris McConnell)
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: How to set function documentation
  7. ;Message-ID: <CCM.90Jul11150057@warhol.ads.com>
  8. ;Date: 11 Jul 90 19:00:57 GMT
  9. ;Sender: usenet@ads.com (USENET News)
  10. ;Distribution: gnu
  11. ;Organization: Advanced Decision Systems, Mountain View, CA 94043, +1 (415)
  12. ;    960-7300
  13. ;Lines: 23
  14. ;
  15. ;These functions will allow changes to the documentation string of a function.
  16.  
  17. ;;;
  18. (defun get-doc (function)
  19.   "Return the raw documentation string of the symbol FUNCTION.  If
  20. there is documentation, this will be either a string or a number, if
  21. not it will probably be a list."
  22.   (car (cdr (cdr (symbol-function function)))))
  23.  
  24. ;;;
  25. (defun set-doc (function string)
  26.   "Set the documentation of the symbol FUNCTION to STRING."
  27.   (let* ((old-function (symbol-function function))
  28.      (old-doc (cdr (cdr old-function)))
  29.      (doc (car old-doc)))
  30.     ;; I did not use rplacd so that I can replace read-only objects
  31.     (fset function
  32.       (nconc (list (car old-function)
  33.                (car (cdr old-function))
  34.                string)
  35.          (if(or (stringp doc) (numberp doc))
  36.             (cdr old-doc)
  37.             old-doc)))))
  38.  
  39.  
  40.