home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / startup.patch < prev    next >
Encoding:
Internet Message Format  |  1990-07-22  |  6.7 KB

  1. From: warsaw@rtg.cme.nist.gov (Barry A. Warsaw)
  2. Newsgroups: comp.emacs,gnu.emacs
  3. Subject: Mods to startup.el for GNU emacs 18.55
  4. Message-ID: <1586@durer.cme.nbs.gov>
  5. Date: 5 Sep 89 18:59:00 GMT
  6. Lines: 165
  7.  
  8.  
  9. I've made a few changes to emacs/lisp/startup.el which gives you a bit
  10. more flexibility in starting emacs up.  I include a context diff
  11. suitable for patch below.  Here's a summary of what the changes give you:
  12.  
  13. 1) Back in August '89, Lynn Slater posted some code that will let you
  14. define command line switches to emacs.  Here's the description that
  15. came with the code:
  16.  
  17. ======================================================================
  18. From: indetech!lrs@ai.mit.edu (Lynn Slater)
  19. Newsgroups: gnu.emacs
  20. Subject: Settable command line arguments
  21. Date: 2 Aug 89 15:18:00 GMT
  22. Distribution: gnu
  23. Organization: GNUs Not Usenet
  24.  
  25. The following changes to startup.el allow hooks to define new command line
  26. arguments without rebuilding emacs.  Example:
  27.  
  28.  emacs -batch -l dbiogen -data DBIO.eld -verify -status -describe -autogen DBIO
  29.  
  30. The load of dbiogen defines hooks that recognizes all those successive
  31. arguments which would not be otherwise recognized.
  32.  
  33. To define a hook, load code such as the following:
  34.   (setq command-line-hooks (cons 'do-object-data command-line-hooks))
  35.   (defun do-object-data ()
  36.     (if (string= argi "-data")
  37.     (let ((datafile (car command-line-args-left)))
  38.       (setq command-line-args-left (cdr command-line-args-left))
  39.       (object-data datafile)
  40.       )))
  41.  
  42.  
  43. I regret that I cannot construct meaningful diffs of startup.el.
  44. ======================================================================
  45.  
  46. Well, I *have* been able to construct meaningful diffs which
  47. incorporate Lynn's mods.  Thanks Lynn, for some neat stuff.
  48.  
  49. 2) One of the things that always bugged me about emacs was that I had
  50. to rebuild the binary whenever I made a change that affected the site
  51. wide emacs environment.  For example, say I wanted to change the
  52. load-path site wide, or put some new autoloads in that everyone could
  53. use, or change the gnus nntp server name.  I always had to hack
  54. site-init.el, re-byte-compile that file, then rebuild emacs.  Sure, I
  55. know about default.el, but that gets loaded in *after* a user's .emacs
  56. file.  I wanted something that gets loaded in *before* your ~/.emacs,
  57. that I could change whenever I wanted and not have to rebuild emacs to
  58. propogate the changes.  That way, users could utilize site wide stuff
  59. in their .emacs file.
  60.  
  61. So anyway, I put a simple hack into startup.el which will load a
  62. library dynamically on startup, *before* command-line switches (see
  63. above) and *before* ~/.emacs.  The library is called
  64. "emacs-site{.el,.elc}" by default, though if the variable
  65. `site-startup-file' is bound, its value is used as the startup file.
  66. The startup file must be on the compiled load path to be found.  Also,
  67. since `load' is used, you don't need to put the {.el,.elc} suffix on
  68. the value of site-startup-file.
  69.  
  70. Startup load order is now: 1) emacs-site.elc, 2) ~/.emacs, 3) command
  71. line switches.  A switch "-s" as the first command line argument
  72. inhibits loading of emacs-site.elc.
  73.  
  74. I've also looked at what things are better put in site-init and what
  75. things are better put in emacs-site and right now I'm thinking that
  76. all key bindings, load-path changes, and autoloads should go in
  77. emacs-site while all pure storage loads (and binding of
  78. site-startup-file) should go in site-init.  You may find a better
  79. scheme.  I set up load-path in paths.h-dist to be the minimal path
  80. needed to build emacs, then set my "production" load-path in
  81. emacs-site.  This seems to work well.  Anyway, enough babble, the
  82. diffs follow.  Enjoy.
  83.  
  84. -Barry
  85.  
  86. NAME: Barry A. Warsaw                USMAIL: National Institute of Standards
  87. TELE: (301) 975-3460                         and Technology (formerly NBS)
  88. UUCP: {...}!uunet!cme-durer!warsaw           Rm. B-124, Bldg. 220
  89. ARPA: warsaw@cme.nist.gov                    Gaithersburg, MD 20899
  90.  
  91.  
  92.  
  93. --cut here-------------------------------------------------------
  94. *** startup.el.orig    Wed Aug 30 16:37:27 1989
  95. --- startup.el    Fri Sep  1 18:20:18 1989
  96. ***************
  97. *** 48,51 ****
  98. --- 48,65 ----
  99.   ; -kill            kill (exit) emacs
  100.   
  101. + ;; the following changes/additions have been made to allow site
  102. + ;; configurable command line arguments.  These mods were distributed
  103. + ;; by lrs@ai.mit.edu (Lynn Slater) and installed by
  104. + ;; warsaw@cme.nist.gov (Barry Warsaw) on 30-Aug-1989.
  105. + (defvar command-line-hooks nil    ;; lrs 7/31/89
  106. +   "*A list of functions to call to process every unrecognized entry on
  107. + the command line.  Each function should access the dynamically bound
  108. + variables argi (the current argument) and command-line-args-left (the
  109. + remaining arguments) . The function should return non-nil only if it
  110. + recognizes and processes argi. In this case, the function may consume
  111. + successive arguments by trimming command-line-args-left (via setq).")
  112.   (setq top-level '(normal-top-level))
  113.   
  114. ***************
  115. *** 94,97 ****
  116. --- 108,122 ----
  117.       (init (if noninteractive nil (user-login-name)))
  118.       (done nil))
  119. +     ;; load a site-wide "emacs-site" file BEFORE loading user's .emacs file
  120. +     ;; this way we can make site wide changes to environment without having
  121. +     ;; to always rebuild emacs.   1-Sep-1989 baw, warsaw@cme.nist.gov
  122. +     ;; load order: "emacs-site", ~/.emacs, command lines
  123. +     (if (string= (car args) "-s")
  124. +     (setq args (cdr args))
  125. +       (load (if (and (boundp 'site-startup-file)
  126. +              site-startup-file)
  127. +         site-startup-file
  128. +           "emacs-site")
  129. +         t t))
  130.       ;; If user has not done su, use current $HOME to find .emacs.
  131.       (and init (string= init (user-real-login-name))
  132. ***************
  133. *** 222,228 ****
  134.           ((string-match "^\\+[0-9]+\\'" argi)
  135.            (setq line (string-to-int argi)))
  136.           (t
  137. !          (find-file (expand-file-name argi dir))
  138. !          (or (zerop line)
  139. !              (goto-line line))
  140. !          (setq line 0))))))))
  141. --- 247,274 ----
  142.           ((string-match "^\\+[0-9]+\\'" argi)
  143.            (setq line (string-to-int argi)))
  144. + ;; modifications made to distribution startup.el as per mods supplied by
  145. + ;; Lynn Slater (see top of file)
  146. + ;; 30-Aug-1989 baw
  147. + ;;
  148. + ;;        (t
  149. + ;;         (find-file (expand-file-name argi dir))
  150. + ;;         (or (zerop line)
  151. + ;;             (goto-line line))
  152. + ;;         (setq line 0))))))))
  153.           (t
  154. !          ;; We have almost exhausted our options. See if the
  155. !          ;; user has made any other command-line options available
  156. !          (let ((hooks command-line-hooks);; lrs 7/31/89
  157. !                (did-hook nil))
  158. !            (while (and hooks (not (and (funcall (car hooks))
  159. !                            (setq did-hook t))))
  160. !              (setq hooks (cdr hooks)))
  161. !            (if (not did-hook)
  162. !                ;; Ok, give up and presume that the argument
  163. !                ;; is a file name
  164. !                (find-file (expand-file-name argi dir))
  165. !              (or (zerop line)
  166. !              (goto-line line))
  167. !              (setq line 0))))))))))
  168.