home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3998 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.5 KB  |  55 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!pipex!demon!edscom!kevin
  3. From: kevin@edscom.demon.co.uk (Kevin Broadey)
  4. Subject: How do I subvert a function?
  5. Message-ID: <KEVIN.92Sep4100146@runningbear.edscom.demon.co.uk>
  6. Sender: kevin@edscom.demon.co.uk (Kevin Broadey)
  7. Organization: EDS-Scicon, Milton Keynes, UK
  8. Distribution: gnu
  9. Date: Fri, 4 Sep 1992 10:01:46 GMT
  10. Lines: 43
  11.  
  12. I'd like to be able to replace an elisp function with one I've written
  13. myself while keeping hold of the original.
  14.  
  15. The reason for this is that I want to modify the function's behaviour
  16. slightly without upsetting the other Emacs users on my site and without
  17. the bother of having a private copy of the entire .el file.
  18.  
  19. I tried doing this:-
  20.  
  21. ;; original.el
  22.  
  23. ...
  24.  
  25. (defun original ()
  26.   ...)
  27.  
  28.  
  29.  
  30. ;; subvert.el
  31.  
  32. (fset 'old-original 'original)
  33.  
  34. (defun original ()
  35.   (old-original)
  36.   ;; modify behaviour here
  37.   ...)
  38.  
  39.  
  40. The trouble is that (defun original ()...) also affects the function
  41. definition of `old-original', presumably because both symbols are
  42. pointing to the same definition cell, and it is the cell rather than the
  43. pointer that gets hacked by defun.
  44.  
  45. Needless to say, this makes my function crawl up the stack at an
  46. alarming rate!
  47.  
  48. So, how do I save a function definition.  Is there a `purecopy' for
  49. functions?
  50. --
  51. Kevin Broadey <kbroadey@edscom.demon.co.uk>
  52. EDS-Scicon, Wavendon Tower, Wavendon, Milton Keynes, MK17 8LX, England.
  53. Phone: +44 908 284198 (direct) or +44 908 585858 ext 4198
  54. These opinions are mine: others available on request.
  55.