home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / dump-my-emacs.el < prev    next >
Encoding:
Text File  |  1993-02-01  |  3.9 KB  |  108 lines

  1. ; From: nickel@cs.tu-berlin.de (Juergen Nickelsen)
  2. ; Subject: Dumping a private copy of Emacs (was Re: model for .emacs file)
  3. ; Date: 16 Jan 93 00:44:26 GMT
  4. ; Organization: STONE Project, Technical University of Berlin, Germany
  5. ; In article <GISLI.93Jan13225133@liapunov.eecs.umich.edu>
  6. ; gisli@liapunov.eecs.umich.edu (Gisli Ottarsson) writes:
  7. ; > How about dumping your private copy of emacs once all your
  8. ; > customization has stablized?  Works fine for me.
  9. ; This posting made me try this again; I had done that previously and
  10. ; fallen into some holes; one of these was bug no 2 (see below).
  11. ; However, the function dump-emacs lacks some features that may be
  12. ; useful for the user; so I have written an interactive dump function.
  13. ; My .emacs file now looks like this:
  14. ;     (defvar privately-dumped-emacs nil
  15. ;       "If non-nil, the running Emacs is a privately dumped copy.
  16. ;     This variable is set by dump-my-emacs to a string containing the
  17. ;     date of the dump and the userid and hostname of the person who did
  18. ;     the dump.")
  19. ;     (if (not privately-dumped-emacs)
  20. ;     (progn
  21. ;     
  22. ;       ;; load stuff
  23. ;           (load "ange-ftp")
  24. ;           ;; etc.
  25. ;       
  26. ;         ))
  27. ;     ;; actions, even to be done in a privately dumped Emacs.
  28. ;     (if display-time-process
  29. ;     (delete-process display-time-process))
  30. ;     (display-time)
  31. ;     ;; etc.
  32. ; Since I load some expensive packages on startup (tree-dired, ange-ftp,
  33. ; completion), this affected my Emacs' startup speed by a factor of
  34. ; five.
  35. ; Two bugs still remain: 
  36. ;   - It seems to be impossible to set the variable
  37. ;     privately-dumped-emacs from the function dump-my-emacs for the
  38. ;     dumped Emacs without affecting the Emacs it has been dumped from.
  39. ;   - If the dumping Emacs used an X display, the dumped Emacs will not
  40. ;     run on an alpha terminal. On the other hand, if the dumping Emacs
  41. ;     ran on an alpha terminal, the dumped *will* be able to use an X
  42. ;     display.
  43. ;       
  44. ; ----------------------------------------------------------------------
  45.  
  46. ;; interactive Emacs dump function
  47. ;; nickel@cs.tu-berlin.de  Jan 16 1993
  48.  
  49. ;; LCD Archive Entry:
  50. ;; dump-my-emacs|Juergen Nickelsen|nickel@cs.tu-berlin.de|
  51. ;; Interactive Emacs dump function.|
  52. ;; 1993-01-16||~/misc/dump-my-emacs.el.Z|
  53.  
  54. (defun dump-my-emacs (filename)
  55.   "Dump current Emacs to file FILENAME.
  56. command-line-processed is set to nil, the variable
  57. privately-dumped-emacs is set to a descriptive string. This variable
  58. can be used in the .emacs startup file to determine if some libraries
  59. have yet to be loaded.
  60.  
  61. If the variable emacs-symbol-file exists and contains a string,
  62. its contents is used as the name of the symbol-file for dumping Emacs.
  63. Otherwise <exec-directory>/../src/emacs-<emacs-version>
  64. and <exec-directory>/../src/xemacs are tried.
  65.  
  66. The dumped Emacs has the same buffer configuration and contents as
  67. the one it has been dumped from. To have a clean Emacs for
  68. general-purpose use, dump a newly started Emacs that contains only
  69. an empty *scratch* buffer."
  70.   (interactive "FDump Emacs to file: ")
  71.   (setq filename (expand-file-name filename))
  72.   (setq command-line-processed nil)
  73.   (setq privately-dumped-emacs
  74.     (format "Emacs dumped at %s by %s@%s"
  75.         (current-time-string)
  76.         (user-login-name)
  77.         (system-name)))
  78.   (let ((symbol-file (or (if (and (boundp 'emacs-symbol-file)
  79.                   (stringp emacs-symbol-file))
  80.                  emacs-symbol-file)
  81.              (let ((version-emacs (concat exec-directory
  82.                               "../src/emacs-"
  83.                               emacs-version)))
  84.                (if (file-exists-p version-emacs)
  85.                    version-emacs))
  86.              (let ((xemacs (concat exec-directory
  87.                            "../src/xemacs")))
  88.                (if (file-exists-p xemacs)
  89.                    xemacs)))))
  90.     (if (not symbol-file)
  91.     (error "No symbol file found for dumping Emacs")
  92.       (garbage-collect)
  93.       (message "Dumping Emacs...")
  94.       (message (if (dump-emacs filename symbol-file)
  95.            ""
  96.          "Dumping Emacs...done")))))
  97.