startup.el 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595
  1. ;;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
  2. ;; Copyright (C) 1985-1986, 1992, 1994-2017 Free Software Foundation,
  3. ;; Inc.
  4. ;; Maintainer: emacs-devel@gnu.org
  5. ;; Keywords: internal
  6. ;; Package: emacs
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This file parses the command line and gets Emacs running. Options
  20. ;; on the command line are handled in precedence order. For priorities
  21. ;; see the structure standard_args in the emacs.c file.
  22. ;;; Code:
  23. (setq top-level '(normal-top-level))
  24. (defvar command-line-processed nil
  25. "Non-nil once command line has been processed.")
  26. (defgroup initialization nil
  27. "Emacs start-up procedure."
  28. :group 'environment)
  29. (defcustom initial-buffer-choice nil
  30. "Buffer to show after starting Emacs.
  31. If the value is nil and `inhibit-startup-screen' is nil, show the
  32. startup screen. If the value is a string, switch to a buffer
  33. visiting the file or directory that the string specifies. If the
  34. value is a function, call it with no arguments and switch to the buffer
  35. that it returns. If t, open the `*scratch*' buffer.
  36. When `initial-buffer-choice' is non-nil, the startup screen is
  37. inhibited.
  38. If you use `emacsclient' with no target file, then it obeys any
  39. string or function value that this variable has."
  40. :type '(choice
  41. (const :tag "Startup screen" nil)
  42. (directory :tag "Directory" :value "~/")
  43. (file :tag "File" :value "~/.emacs")
  44. ;; Note sure about hard-coding this as an option...
  45. (const :tag "Remember Mode notes buffer" remember-notes)
  46. (function :tag "Function")
  47. (const :tag "Lisp scratch buffer" t))
  48. :version "23.1"
  49. :group 'initialization)
  50. (defcustom inhibit-startup-screen nil
  51. "Non-nil inhibits the startup screen.
  52. This is for use in your personal init file (but NOT site-start.el),
  53. once you are familiar with the contents of the startup screen."
  54. :type 'boolean
  55. :group 'initialization)
  56. (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen)
  57. (defvaralias 'inhibit-startup-message 'inhibit-startup-screen)
  58. (defvar startup-screen-inhibit-startup-screen nil)
  59. ;; The mechanism used to ensure that only end users can disable this
  60. ;; message is not complex. Clearly, it is possible for a determined
  61. ;; system administrator to inhibit this message anyway, but at least
  62. ;; they will do so with knowledge of why the Emacs developers think
  63. ;; this is a bad idea.
  64. (defcustom inhibit-startup-echo-area-message nil
  65. "Non-nil inhibits the initial startup echo area message.
  66. The startup message is in the echo area as it provides information
  67. about GNU Emacs and the GNU system in general, which we want all
  68. users to see. As this is the least intrusive startup message,
  69. this variable gets specialized treatment to prevent the message
  70. from being disabled site-wide by systems administrators, while
  71. still allowing individual users to do so.
  72. Setting this variable takes effect only if you do it with the
  73. customization buffer or if your init file contains a line of this
  74. form:
  75. (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
  76. If your init file is byte-compiled, use the following form
  77. instead:
  78. (eval \\='(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
  79. Thus, someone else using a copy of your init file will see the
  80. startup message unless he personally acts to inhibit it."
  81. :type '(choice (const :tag "Don't inhibit")
  82. (string :tag "Enter your user name, to inhibit"))
  83. :group 'initialization)
  84. (defcustom inhibit-default-init nil
  85. "Non-nil inhibits loading the `default' library."
  86. :type 'boolean
  87. :group 'initialization)
  88. (defcustom inhibit-startup-buffer-menu nil
  89. "Non-nil inhibits display of buffer list when more than 2 files are loaded."
  90. :type 'boolean
  91. :group 'initialization)
  92. (defvar command-switch-alist nil
  93. "Alist of command-line switches.
  94. Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
  95. HANDLER-FUNCTION receives the switch string as its sole argument;
  96. the remaining command-line args are in the variable `command-line-args-left'.")
  97. (defvar command-line-args-left nil
  98. "List of command-line args not yet processed.")
  99. (defvaralias 'argv 'command-line-args-left
  100. "List of command-line args not yet processed.
  101. This is a convenience alias, so that one can write \(pop argv)
  102. inside of --eval command line arguments in order to access
  103. following arguments.")
  104. (internal-make-var-non-special 'argv)
  105. (defvar argi nil
  106. "Current command-line argument.")
  107. (internal-make-var-non-special 'argi)
  108. (defvar command-line-functions nil ;; lrs 7/31/89
  109. "List of functions to process unrecognized command-line arguments.
  110. Each function should access the dynamically bound variables
  111. `argi' (the current argument) and `command-line-args-left' (the remaining
  112. arguments). The function should return non-nil only if it recognizes and
  113. processes `argi'. If it does so, it may consume successive arguments by
  114. altering `command-line-args-left' to remove them.")
  115. (defvar command-line-default-directory nil
  116. "Default directory to use for command line arguments.
  117. This is normally copied from `default-directory' when Emacs starts.")
  118. ;; This is here, rather than in x-win.el, so that we can ignore these
  119. ;; options when we are not using X.
  120. (defconst command-line-x-option-alist
  121. '(("-bw" 1 x-handle-numeric-switch border-width)
  122. ("-d" 1 x-handle-display)
  123. ("-display" 1 x-handle-display)
  124. ("-name" 1 x-handle-name-switch)
  125. ("-title" 1 x-handle-switch title)
  126. ("-T" 1 x-handle-switch title)
  127. ("-r" 0 x-handle-switch reverse t)
  128. ("-rv" 0 x-handle-switch reverse t)
  129. ("-reverse" 0 x-handle-switch reverse t)
  130. ("-reverse-video" 0 x-handle-switch reverse t)
  131. ("-fn" 1 x-handle-switch font)
  132. ("-font" 1 x-handle-switch font)
  133. ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
  134. ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
  135. ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
  136. ("-mm" 0 x-handle-initial-switch fullscreen maximized)
  137. ("-ib" 1 x-handle-numeric-switch internal-border-width)
  138. ("-g" 1 x-handle-geometry)
  139. ("-lsp" 1 x-handle-numeric-switch line-spacing)
  140. ("-geometry" 1 x-handle-geometry)
  141. ("-fg" 1 x-handle-switch foreground-color)
  142. ("-foreground" 1 x-handle-switch foreground-color)
  143. ("-bg" 1 x-handle-switch background-color)
  144. ("-background" 1 x-handle-switch background-color)
  145. ("-ms" 1 x-handle-switch mouse-color)
  146. ("-nbi" 0 x-handle-switch icon-type nil)
  147. ("-iconic" 0 x-handle-iconic)
  148. ("-xrm" 1 x-handle-xrm-switch)
  149. ("-cr" 1 x-handle-switch cursor-color)
  150. ("-vb" 0 x-handle-switch vertical-scroll-bars t)
  151. ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
  152. ("-bd" 1 x-handle-switch)
  153. ("--border-width" 1 x-handle-numeric-switch border-width)
  154. ("--display" 1 x-handle-display)
  155. ("--name" 1 x-handle-name-switch)
  156. ("--title" 1 x-handle-switch title)
  157. ("--reverse-video" 0 x-handle-switch reverse t)
  158. ("--font" 1 x-handle-switch font)
  159. ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
  160. ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
  161. ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
  162. ("--maximized" 0 x-handle-initial-switch fullscreen maximized)
  163. ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
  164. ("--geometry" 1 x-handle-geometry)
  165. ("--foreground-color" 1 x-handle-switch foreground-color)
  166. ("--background-color" 1 x-handle-switch background-color)
  167. ("--mouse-color" 1 x-handle-switch mouse-color)
  168. ("--no-bitmap-icon" 0 x-handle-no-bitmap-icon)
  169. ("--iconic" 0 x-handle-iconic)
  170. ("--xrm" 1 x-handle-xrm-switch)
  171. ("--cursor-color" 1 x-handle-switch cursor-color)
  172. ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
  173. ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
  174. ("--border-color" 1 x-handle-switch border-color)
  175. ("--smid" 1 x-handle-smid)
  176. ("--parent-id" 1 x-handle-parent-id))
  177. "Alist of X Windows options.
  178. Each element has the form
  179. (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
  180. where NAME is the option name string, NUMARGS is the number of arguments
  181. that the option accepts, HANDLER is a function to call to handle the option.
  182. FRAME-PARAM (optional) is the frame parameter this option specifies,
  183. and VALUE is the value which is given to that frame parameter
  184. \(most options use the argument for this, so VALUE is not present).")
  185. (defconst command-line-ns-option-alist
  186. '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
  187. ("-NXAutoLaunch" 1 ns-ignore-1-arg)
  188. ("-macosx" 0 ignore)
  189. ("-NSHost" 1 ns-ignore-1-arg)
  190. ("-_NSMachLaunch" 1 ns-ignore-1-arg)
  191. ("-MachLaunch" 1 ns-ignore-1-arg)
  192. ("-NXOpen" 1 ns-ignore-1-arg)
  193. ("-NSOpen" 1 ns-handle-nxopen)
  194. ("-NXOpenTemp" 1 ns-ignore-1-arg)
  195. ("-NSOpenTemp" 1 ns-handle-nxopentemp)
  196. ("-GSFilePath" 1 ns-handle-nxopen)
  197. ;;("-bw" . x-handle-numeric-switch)
  198. ;;("-d" . x-handle-display)
  199. ;;("-display" . x-handle-display)
  200. ("-name" 1 x-handle-name-switch)
  201. ("-title" 1 x-handle-switch title)
  202. ("-T" 1 x-handle-switch title)
  203. ("-r" 0 x-handle-switch reverse t)
  204. ("-rv" 0 x-handle-switch reverse t)
  205. ("-reverse" 0 x-handle-switch reverse t)
  206. ("-fn" 1 x-handle-switch font)
  207. ("-font" 1 x-handle-switch font)
  208. ("-ib" 1 x-handle-numeric-switch internal-border-width)
  209. ("-g" 1 x-handle-geometry)
  210. ("-geometry" 1 x-handle-geometry)
  211. ("-fg" 1 x-handle-switch foreground-color)
  212. ("-foreground" 1 x-handle-switch foreground-color)
  213. ("-bg" 1 x-handle-switch background-color)
  214. ("-background" 1 x-handle-switch background-color)
  215. ; ("-ms" 1 x-handle-switch mouse-color)
  216. ("-itype" 0 x-handle-switch icon-type t)
  217. ("-i" 0 x-handle-switch icon-type t)
  218. ("-iconic" 0 x-handle-iconic icon-type t)
  219. ;;("-xrm" . x-handle-xrm-switch)
  220. ("-cr" 1 x-handle-switch cursor-color)
  221. ("-vb" 0 x-handle-switch vertical-scroll-bars t)
  222. ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
  223. ("-bd" 1 x-handle-switch)
  224. ;; ("--border-width" 1 x-handle-numeric-switch border-width)
  225. ;; ("--display" 1 ns-handle-display)
  226. ("--name" 1 x-handle-name-switch)
  227. ("--title" 1 x-handle-switch title)
  228. ("--reverse-video" 0 x-handle-switch reverse t)
  229. ("--font" 1 x-handle-switch font)
  230. ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
  231. ;; ("--geometry" 1 ns-handle-geometry)
  232. ("--foreground-color" 1 x-handle-switch foreground-color)
  233. ("--background-color" 1 x-handle-switch background-color)
  234. ("--mouse-color" 1 x-handle-switch mouse-color)
  235. ("--icon-type" 0 x-handle-switch icon-type t)
  236. ("--iconic" 0 x-handle-iconic)
  237. ;; ("--xrm" 1 ns-handle-xrm-switch)
  238. ("--cursor-color" 1 x-handle-switch cursor-color)
  239. ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
  240. ("--border-color" 1 x-handle-switch border-width))
  241. "Alist of NS options.
  242. Each element has the form
  243. (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
  244. where NAME is the option name string, NUMARGS is the number of arguments
  245. that the option accepts, HANDLER is a function to call to handle the option.
  246. FRAME-PARAM (optional) is the frame parameter this option specifies,
  247. and VALUE is the value which is given to that frame parameter
  248. \(most options use the argument for this, so VALUE is not present).")
  249. (defvar before-init-hook nil
  250. "Normal hook run after handling urgent options but before loading init files.")
  251. (defvar after-init-hook nil
  252. "Normal hook run after initializing the Emacs session.
  253. It is run after Emacs loads the init file, `default' library, the
  254. abbrevs file, and additional Lisp packages (if any), and setting
  255. the value of `after-init-time'.
  256. There is no `condition-case' around the running of this hook;
  257. therefore, if `debug-on-error' is non-nil, an error in one of
  258. these functions will invoke the debugger.")
  259. (defvar emacs-startup-hook nil
  260. "Normal hook run after loading init files and handling the command line.")
  261. (defvar term-setup-hook nil
  262. "Normal hook run immediately after `emacs-startup-hook'.
  263. In new code, there is no reason to use this instead of `emacs-startup-hook'.
  264. If you want to execute terminal-specific Lisp code, for example
  265. to override the definitions made by the terminal-specific file,
  266. see `tty-setup-hook'.")
  267. (make-obsolete-variable 'term-setup-hook
  268. "use either `emacs-startup-hook' or \
  269. `tty-setup-hook' instead." "24.4")
  270. (defvar inhibit-startup-hooks nil
  271. "Non-nil means don't run some startup hooks, because we already did.
  272. Currently this applies to: `emacs-startup-hook', `term-setup-hook',
  273. and `window-setup-hook'.")
  274. (defvar keyboard-type nil
  275. "The brand of keyboard you are using.
  276. This variable is used to define the proper function and keypad
  277. keys for use under X. It is used in a fashion analogous to the
  278. environment variable TERM.")
  279. (defvar window-setup-hook nil
  280. "Normal hook run after loading init files and handling the command line.
  281. This is very similar to `emacs-startup-hook'. The only difference
  282. is that this hook runs after frame parameters have been set up in
  283. response to any settings from your init file. Unless this matters
  284. to you, use `emacs-startup-hook' instead. (The name of this hook
  285. is due to historical reasons, and does not reflect its purpose very well.)")
  286. (defcustom initial-major-mode 'lisp-interaction-mode
  287. "Major mode command symbol to use for the initial `*scratch*' buffer."
  288. :type 'function
  289. :group 'initialization)
  290. (defvar init-file-user nil
  291. "Identity of user whose init file is or was read.
  292. The value is nil if `-q' or `--no-init-file' was specified,
  293. meaning do not load any init file.
  294. Otherwise, the value may be an empty string, meaning
  295. use the init file for the user who originally logged in,
  296. or it may be a string containing a user's name meaning
  297. use that person's init file.
  298. In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
  299. evaluates to the name of the directory where the init file was
  300. looked for.
  301. Setting `init-file-user' does not prevent Emacs from loading
  302. `site-start.el'. The only way to do that is to use `--no-site-file'.")
  303. (defcustom site-run-file (purecopy "site-start")
  304. "File containing site-wide run-time initializations.
  305. This file is loaded at run-time before `~/.emacs'. It contains inits
  306. that need to be in place for the entire site, but which, due to their
  307. higher incidence of change, don't make sense to load into Emacs's
  308. dumped image. Thus, the run-time load order is: 1. file described in
  309. this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
  310. Don't use the `site-start.el' file for things some users may not like.
  311. Put them in `default.el' instead, so that users can more easily
  312. override them. Users can prevent loading `default.el' with the `-q'
  313. option or by setting `inhibit-default-init' in their own init files,
  314. but inhibiting `site-start.el' requires `--no-site-file', which
  315. is less convenient.
  316. This variable is defined for customization so as to make
  317. it visible in the relevant context. However, actually customizing it
  318. is not allowed, since it would not work anyway. The only way to set
  319. this variable usefully is to set it while building and dumping Emacs."
  320. :type '(choice (const :tag "none" nil) string)
  321. :group 'initialization
  322. :initialize #'custom-initialize-default
  323. :set (lambda (_variable _value)
  324. (error "Customizing `site-run-file' does not work")))
  325. (make-obsolete-variable 'system-name "use (system-name) instead" "25.1")
  326. (defcustom mail-host-address nil
  327. "The name of this machine, for use in constructing email addresses.
  328. If this is nil, Emacs uses `system-name'."
  329. :type '(choice (const nil) string)
  330. :group 'mail)
  331. (defcustom user-mail-address
  332. (or (getenv "EMAIL")
  333. (concat (user-login-name) "@" (or mail-host-address (system-name))))
  334. "The email address of the current user.
  335. This defaults to either: the value of EMAIL environment variable; or
  336. user@host, using `user-login-name' and `mail-host-address' (or `system-name')."
  337. :initialize 'custom-initialize-delay
  338. :set-after '(mail-host-address)
  339. :type 'string
  340. :group 'mail)
  341. (defcustom auto-save-list-file-prefix
  342. (cond ((eq system-type 'ms-dos)
  343. ;; MS-DOS cannot have initial dot, and allows only 8.3 names
  344. (concat user-emacs-directory "auto-save.list/_s"))
  345. (t
  346. (concat user-emacs-directory "auto-save-list/.saves-")))
  347. "Prefix for generating `auto-save-list-file-name'.
  348. This is used after reading your init file to initialize
  349. `auto-save-list-file-name', by appending Emacs's pid and the system name,
  350. if you have not already set `auto-save-list-file-name' yourself.
  351. Directories in the prefix will be created if necessary.
  352. Set this to nil if you want to prevent `auto-save-list-file-name'
  353. from being initialized."
  354. :type '(choice (const :tag "Don't record a session's auto save list" nil)
  355. string)
  356. :group 'auto-save)
  357. (defvar emacs-basic-display nil)
  358. (defvar init-file-debug nil)
  359. (defvar init-file-had-error nil
  360. "Non-nil if there was an error loading the user's init file.")
  361. (defvar normal-top-level-add-subdirs-inode-list nil)
  362. (defvar no-blinking-cursor nil)
  363. (defvar pure-space-overflow nil
  364. "Non-nil if building Emacs overflowed pure space.")
  365. (defvar pure-space-overflow-message (purecopy "\
  366. Warning Warning!!! Pure space overflow !!!Warning Warning
  367. \(See the node Pure Storage in the Lisp manual for details.)\n"))
  368. (defcustom tutorial-directory
  369. (file-name-as-directory (expand-file-name "tutorials" data-directory))
  370. "Directory containing the Emacs TUTORIAL files."
  371. :group 'installation
  372. :type 'directory
  373. :initialize #'custom-initialize-delay)
  374. (defun normal-top-level-add-subdirs-to-load-path ()
  375. "Recursively add all subdirectories of `default-directory' to `load-path'.
  376. More precisely, this uses only the subdirectories whose names
  377. start with letters or digits; it excludes any subdirectory named `RCS'
  378. or `CVS', and any subdirectory that contains a file named `.nosearch'."
  379. (let (dirs
  380. attrs
  381. (pending (list default-directory)))
  382. ;; This loop does a breadth-first tree walk on DIR's subtree,
  383. ;; putting each subdir into DIRS as its contents are examined.
  384. (while pending
  385. (push (pop pending) dirs)
  386. (let* ((this-dir (car dirs))
  387. (contents (directory-files this-dir))
  388. (default-directory this-dir)
  389. (canonicalized (if (fboundp 'w32-untranslated-canonical-name)
  390. (w32-untranslated-canonical-name this-dir))))
  391. ;; The Windows version doesn't report meaningful inode numbers, so
  392. ;; use the canonicalized absolute file name of the directory instead.
  393. (setq attrs (or canonicalized
  394. (nthcdr 10 (file-attributes this-dir))))
  395. (unless (member attrs normal-top-level-add-subdirs-inode-list)
  396. (push attrs normal-top-level-add-subdirs-inode-list)
  397. (dolist (file contents)
  398. (and (string-match "\\`[[:alnum:]]" file)
  399. ;; The lower-case variants of RCS and CVS are for DOS/Windows.
  400. (not (member file '("RCS" "CVS" "rcs" "cvs")))
  401. ;; Avoid doing a `stat' when it isn't necessary because
  402. ;; that can cause trouble when an NFS server is down.
  403. (not (string-match "\\.elc?\\'" file))
  404. (file-directory-p file)
  405. (let ((expanded (expand-file-name file)))
  406. (or (file-exists-p (expand-file-name ".nosearch" expanded))
  407. (setq pending (nconc pending (list expanded))))))))))
  408. (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
  409. (defun normal-top-level-add-to-load-path (dirs)
  410. "This function is called from a subdirs.el file.
  411. It assumes that `default-directory' is the directory in which the
  412. subdirs.el file exists, and it adds to `load-path' the subdirs of
  413. that directory as specified in DIRS. Normally the elements of
  414. DIRS are relative."
  415. (let ((tail load-path)
  416. (thisdir (directory-file-name default-directory)))
  417. (while (and tail
  418. ;;Don't go all the way to the nil terminator.
  419. (cdr tail)
  420. (not (equal thisdir (car tail)))
  421. (not (and (memq system-type '(ms-dos windows-nt))
  422. (equal (downcase thisdir) (downcase (car tail))))))
  423. (setq tail (cdr tail)))
  424. ;;Splice the new section in.
  425. (when tail
  426. (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
  427. (defun normal-top-level ()
  428. "Emacs calls this function when it first starts up.
  429. It sets `command-line-processed', processes the command-line,
  430. reads the initialization files, etc.
  431. It is the default value of the variable `top-level'."
  432. (if command-line-processed
  433. (message internal--top-level-message)
  434. (setq command-line-processed t)
  435. ;; Look in each dir in load-path for a subdirs.el file. If we
  436. ;; find one, load it, which will add the appropriate subdirs of
  437. ;; that dir into load-path. This needs to be done before setting
  438. ;; the locale environment, because the latter might need to load
  439. ;; some support files.
  440. ;; Look for a leim-list.el file too. Loading it will register
  441. ;; available input methods.
  442. (let ((tail load-path)
  443. (lispdir (expand-file-name "../lisp" data-directory))
  444. dir)
  445. (while tail
  446. (setq dir (car tail))
  447. (let ((default-directory dir))
  448. (load (expand-file-name "subdirs.el") t t t))
  449. ;; Do not scan standard directories that won't contain a leim-list.el.
  450. ;; http://lists.gnu.org/archive/html/emacs-devel/2009-10/msg00502.html
  451. ;; (Except the preloaded one in lisp/leim.)
  452. (or (string-prefix-p lispdir dir)
  453. (let ((default-directory dir))
  454. (load (expand-file-name "leim-list.el") t t t)))
  455. ;; We don't use a dolist loop and we put this "setq-cdr" command at
  456. ;; the end, because the subdirs.el files may add elements to the end
  457. ;; of load-path and we want to take it into account.
  458. (setq tail (cdr tail))))
  459. ;; Set the default strings to display in mode line for end-of-line
  460. ;; formats that aren't native to this platform. This should be
  461. ;; done before calling set-locale-environment, as the latter might
  462. ;; use these mnemonics.
  463. (cond
  464. ((memq system-type '(ms-dos windows-nt))
  465. (setq eol-mnemonic-unix "(Unix)"
  466. eol-mnemonic-mac "(Mac)"))
  467. (t ; this is for Unix/GNU/Linux systems
  468. (setq eol-mnemonic-dos "(DOS)"
  469. eol-mnemonic-mac "(Mac)")))
  470. (set-locale-environment nil)
  471. ;; Decode all default-directory's (probably, only *scratch* exists
  472. ;; at this point). default-directory of *scratch* is the basis
  473. ;; for many other file-name variables and directory lists, so it
  474. ;; is important to decode it ASAP.
  475. (when locale-coding-system
  476. (let ((coding (if (eq system-type 'windows-nt)
  477. ;; MS-Windows build converts all file names to
  478. ;; UTF-8 during startup.
  479. 'utf-8
  480. locale-coding-system)))
  481. (save-excursion
  482. (dolist (elt (buffer-list))
  483. (set-buffer elt)
  484. (if default-directory
  485. (setq default-directory
  486. (if (eq system-type 'windows-nt)
  487. ;; Convert backslashes to forward slashes.
  488. (expand-file-name
  489. (decode-coding-string default-directory coding t))
  490. (decode-coding-string default-directory coding t))))))
  491. ;; Decode all the important variables and directory lists, now
  492. ;; that we know the locale's encoding. This is because the
  493. ;; values of these variables are until here unibyte undecoded
  494. ;; strings created by build_unibyte_string. data-directory in
  495. ;; particular is used to construct many other standard
  496. ;; directory names, so it must be decoded ASAP. Note that
  497. ;; charset-map-path cannot be decoded here, since we could
  498. ;; then be trapped in infinite recursion below, when we load
  499. ;; subdirs.el, because encoding a directory name might need to
  500. ;; load a charset map, which will want to encode
  501. ;; charset-map-path, which will want to load the same charset
  502. ;; map... So decoding of charset-map-path is delayed until
  503. ;; further down below.
  504. (dolist (pathsym '(load-path exec-path))
  505. (let ((path (symbol-value pathsym)))
  506. (if (listp path)
  507. (set pathsym (mapcar (lambda (dir)
  508. (decode-coding-string dir coding t))
  509. path)))))
  510. (dolist (filesym '(data-directory doc-directory exec-directory
  511. installation-directory
  512. invocation-directory invocation-name
  513. source-directory
  514. shared-game-score-directory))
  515. (let ((file (symbol-value filesym)))
  516. (if (stringp file)
  517. (set filesym (decode-coding-string file coding t)))))))
  518. (let ((dir default-directory))
  519. (with-current-buffer "*Messages*"
  520. (messages-buffer-mode)
  521. ;; Make it easy to do like "tail -f".
  522. (set (make-local-variable 'window-point-insertion-type) t)
  523. ;; Give *Messages* the same default-directory as *scratch*,
  524. ;; just to keep things predictable.
  525. (setq default-directory (or dir (expand-file-name "~/")))))
  526. ;; `user-full-name' is now known; reset its standard-value here.
  527. (put 'user-full-name 'standard-value
  528. (list (default-value 'user-full-name)))
  529. ;; If the PWD environment variable isn't accurate, delete it.
  530. (let ((pwd (getenv "PWD")))
  531. (and (stringp pwd)
  532. ;; Use FOO/., so that if FOO is a symlink, file-attributes
  533. ;; describes the directory linked to, not FOO itself.
  534. (or (and default-directory
  535. (equal (file-attributes
  536. (concat (file-name-as-directory pwd) "."))
  537. (file-attributes
  538. (concat (file-name-as-directory default-directory)
  539. "."))))
  540. (setq process-environment
  541. (delete (concat "PWD=" pwd)
  542. process-environment)))))
  543. ;; Now, that other directories were searched, and any charsets we
  544. ;; need for encoding them are already loaded, we are ready to
  545. ;; decode charset-map-path.
  546. (if (listp charset-map-path)
  547. (let ((coding (if (eq system-type 'windows-nt)
  548. 'utf-8
  549. locale-coding-system)))
  550. (setq charset-map-path
  551. (mapcar (lambda (dir)
  552. (decode-coding-string dir coding t))
  553. charset-map-path))))
  554. (if default-directory
  555. (setq default-directory (abbreviate-file-name default-directory))
  556. (display-warning 'initialization "Error setting default-directory"))
  557. (let ((old-face-font-rescale-alist face-font-rescale-alist))
  558. (unwind-protect
  559. (command-line)
  560. ;; Do this again, in case .emacs defined more abbreviations.
  561. (if default-directory
  562. (setq default-directory (abbreviate-file-name default-directory)))
  563. ;; Specify the file for recording all the auto save files of this session.
  564. ;; This is used by recover-session.
  565. (or auto-save-list-file-name
  566. (and auto-save-list-file-prefix
  567. (setq auto-save-list-file-name
  568. ;; Under MS-DOS our PID is almost always reused between
  569. ;; Emacs invocations. We need something more unique.
  570. (cond ((eq system-type 'ms-dos)
  571. ;; We are going to access the auto-save
  572. ;; directory, so make sure it exists.
  573. (make-directory
  574. (file-name-directory auto-save-list-file-prefix)
  575. t)
  576. (concat
  577. (make-temp-name
  578. (expand-file-name
  579. auto-save-list-file-prefix))
  580. "~"))
  581. (t
  582. (expand-file-name
  583. (format "%s%d-%s~"
  584. auto-save-list-file-prefix
  585. (emacs-pid)
  586. (system-name))))))))
  587. (unless inhibit-startup-hooks
  588. (run-hooks 'emacs-startup-hook 'term-setup-hook))
  589. ;; Don't do this if we failed to create the initial frame,
  590. ;; for instance due to a dense colormap.
  591. (when (or frame-initial-frame
  592. ;; If frame-initial-frame has no meaning, do this anyway.
  593. (not (and initial-window-system
  594. (not noninteractive)
  595. (not (eq initial-window-system 'pc)))))
  596. ;; FIXME: The user's init file may change
  597. ;; face-font-rescale-alist. However, the default face
  598. ;; already has an assigned font object, which does not take
  599. ;; face-font-rescale-alist into account. For such
  600. ;; situations, we ought to have a way to find all font
  601. ;; objects and regenerate them; currently we do not. As a
  602. ;; workaround, we specifically reset te default face's :font
  603. ;; attribute here. See bug#1785.
  604. (unless (eq face-font-rescale-alist
  605. old-face-font-rescale-alist)
  606. (set-face-attribute 'default nil :font (font-spec)))
  607. ;; Modify the initial frame based on what .emacs puts into
  608. ;; ...-frame-alist.
  609. (if (fboundp 'frame-notice-user-settings)
  610. (frame-notice-user-settings))
  611. ;; Set the faces for the initial background mode even if
  612. ;; frame-notice-user-settings didn't (such as on a tty).
  613. ;; frame-set-background-mode is idempotent, so it won't
  614. ;; cause any harm if it's already been done.
  615. (if (fboundp 'frame-set-background-mode)
  616. (frame-set-background-mode (selected-frame))))
  617. ;; Now we know the user's default font, so add it to the menu.
  618. (if (fboundp 'font-menu-add-default)
  619. (font-menu-add-default))
  620. (unless inhibit-startup-hooks
  621. (run-hooks 'window-setup-hook))))
  622. ;; Subprocesses of Emacs do not have direct access to the terminal, so
  623. ;; unless told otherwise they should only assume a dumb terminal.
  624. ;; We are careful to do it late (after term-setup-hook), although the
  625. ;; new multi-tty code does not use $TERM any more there anyway.
  626. (setenv "TERM" "dumb")
  627. ;; Remove DISPLAY from the process-environment as well. This allows
  628. ;; `callproc.c' to give it a useful adaptive default which is either
  629. ;; the value of the `display' frame-parameter or the DISPLAY value
  630. ;; from initial-environment.
  631. (let ((display (frame-parameter nil 'display)))
  632. ;; Be careful which DISPLAY to remove from process-environment: follow
  633. ;; the logic of `callproc.c'.
  634. (if (stringp display) (setq display (concat "DISPLAY=" display))
  635. (dolist (varval initial-environment)
  636. (if (string-match "\\`DISPLAY=" varval)
  637. (setq display varval))))
  638. (when display
  639. (delete display process-environment)))))
  640. ;; Precompute the keyboard equivalents in the menu bar items.
  641. ;; Command-line options supported by tty's:
  642. (defconst tty-long-option-alist
  643. '(("--name" . "-name")
  644. ("--title" . "-T")
  645. ("--reverse-video" . "-reverse")
  646. ("--foreground-color" . "-fg")
  647. ("--background-color" . "-bg")
  648. ("--color" . "-color")))
  649. (defconst tool-bar-images-pixel-height 24
  650. "Height in pixels of images in the tool-bar.")
  651. (cl-defgeneric handle-args-function (args)
  652. "Method for processing window-system dependent command-line arguments.
  653. Window system startup files should add their own function to this
  654. method, which should parse the command line arguments. Those
  655. pertaining to the window system should be processed and removed
  656. from the returned command line.")
  657. (cl-defmethod handle-args-function (args &context (window-system nil))
  658. (tty-handle-args args))
  659. (cl-defgeneric window-system-initialization (&optional _display)
  660. "Method for window-system initialization.
  661. Window-system startup files should add their own implementation
  662. to this method. The function should initialize the window system environment
  663. to prepare for opening the first frame (e.g. open a connection to an X server)."
  664. nil)
  665. (defun tty-handle-args (args)
  666. "Handle the X-like command-line arguments \"-fg\", \"-bg\", \"-name\", etc."
  667. (let (rest)
  668. (while (and args
  669. (not (equal (car args) "--")))
  670. (let* ((argi (pop args))
  671. (orig-argi argi)
  672. argval completion)
  673. ;; Check for long options with attached arguments
  674. ;; and separate out the attached option argument into argval.
  675. (when (string-match "^\\(--[^=]*\\)=" argi)
  676. (setq argval (substring argi (match-end 0))
  677. argi (match-string 1 argi)))
  678. (when (string-match "^--" argi)
  679. (setq completion (try-completion argi tty-long-option-alist))
  680. (if (eq completion t)
  681. ;; Exact match for long option.
  682. (setq argi (cdr (assoc argi tty-long-option-alist)))
  683. (if (stringp completion)
  684. (let ((elt (assoc completion tty-long-option-alist)))
  685. ;; Check for abbreviated long option.
  686. (or elt
  687. (error "Option `%s' is ambiguous" argi))
  688. (setq argi (cdr elt)))
  689. ;; Check for a short option.
  690. (setq argval nil
  691. argi orig-argi))))
  692. (cond ((member argi '("-fg" "-foreground"))
  693. (push (cons 'foreground-color (or argval (pop args)))
  694. default-frame-alist))
  695. ((member argi '("-bg" "-background"))
  696. (push (cons 'background-color (or argval (pop args)))
  697. default-frame-alist))
  698. ((member argi '("-T" "-name"))
  699. (unless argval (setq argval (pop args)))
  700. (push (cons 'title
  701. (if (stringp argval)
  702. argval
  703. (let ((case-fold-search t)
  704. i)
  705. (setq argval (invocation-name))
  706. ;; Change any . or * characters in name to
  707. ;; hyphens, so as to emulate behavior on X.
  708. (while
  709. (setq i (string-match "[.*]" argval))
  710. (aset argval i ?-))
  711. argval)))
  712. default-frame-alist))
  713. ((member argi '("-r" "-rv" "-reverse"))
  714. (push '(reverse . t)
  715. default-frame-alist))
  716. ((equal argi "-color")
  717. (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
  718. (push (cons 'tty-color-mode
  719. (cond
  720. ((numberp argval) argval)
  721. ((string-match "-?[0-9]+" argval)
  722. (string-to-number argval))
  723. (t (intern argval))))
  724. default-frame-alist))
  725. (t
  726. (push argi rest)))))
  727. (nconc (nreverse rest) args)))
  728. (declare-function x-get-resource "frame.c"
  729. (attribute class &optional component subclass))
  730. (declare-function tool-bar-mode "tool-bar" (&optional arg))
  731. (declare-function tool-bar-setup "tool-bar")
  732. (defvar server-name)
  733. (defvar server-process)
  734. (defun startup--setup-quote-display (&optional style)
  735. "If needed, display ASCII approximations to curved quotes.
  736. Do this by modifying `standard-display-table'. Optional STYLE
  737. specifies the desired quoting style, as in `text-quoting-style'.
  738. If STYLE is nil, display appropriately for the terminal."
  739. (let ((repls (let ((style-repls (assq style '((grave . "`'\"\"")
  740. (straight . "''\"\"")))))
  741. (if style-repls (cdr style-repls) (make-vector 4 nil))))
  742. glyph-count)
  743. ;; REPLS is a sequence of the four replacements for "‘’“”", respectively.
  744. ;; If STYLE is nil, infer REPLS from terminal characteristics.
  745. (unless style
  746. ;; On a terminal that supports glyph codes,
  747. ;; GLYPH-COUNT[i] is the number of times that glyph code I
  748. ;; represents either an ASCII character or one of the 4
  749. ;; quote characters. This assumes glyph codes are valid
  750. ;; Elisp characters, which is a safe assumption in practice.
  751. (when (integerp (internal-char-font nil (max-char)))
  752. (setq glyph-count (make-char-table nil 0))
  753. (dotimes (i 132)
  754. (let ((glyph (internal-char-font
  755. nil (if (< i 128) i (aref "‘’“”" (- i 128))))))
  756. (when (<= 0 glyph)
  757. (aset glyph-count glyph (1+ (aref glyph-count glyph)))))))
  758. (dotimes (i 2)
  759. (let ((lq (aref "‘“" i)) (rq (aref "’”" i))
  760. (lr (aref "`\"" i)) (rr (aref "'\"" i))
  761. (i2 (* i 2)))
  762. (unless (if glyph-count
  763. ;; On a terminal that supports glyph codes, use
  764. ;; ASCII replacements unless both quotes are displayable.
  765. ;; If not using ASCII replacements, highlight
  766. ;; quotes unless they are both unique among the
  767. ;; 128 + 4 characters of concern.
  768. (let ((lglyph (internal-char-font nil lq))
  769. (rglyph (internal-char-font nil rq)))
  770. (when (and (<= 0 lglyph) (<= 0 rglyph))
  771. (setq lr lq rr rq)
  772. (and (= 1 (aref glyph-count lglyph))
  773. (= 1 (aref glyph-count rglyph)))))
  774. ;; On a terminal that does not support glyph codes, use
  775. ;; ASCII replacements unless both quotes are displayable.
  776. (and (char-displayable-p lq)
  777. (char-displayable-p rq)))
  778. (aset repls i2 lr)
  779. (aset repls (1+ i2) rr)))))
  780. (dotimes (i 4)
  781. (let ((char (aref "‘’“”" i))
  782. (repl (aref repls i)))
  783. (if repl
  784. (aset (or standard-display-table
  785. (setq standard-display-table (make-display-table)))
  786. char (vector (make-glyph-code repl 'homoglyph)))
  787. (when standard-display-table
  788. (aset standard-display-table char nil)))))))
  789. (defun command-line ()
  790. "A subroutine of `normal-top-level'.
  791. Amongst another things, it parses the command-line arguments."
  792. (setq before-init-time (current-time)
  793. after-init-time nil
  794. command-line-default-directory default-directory)
  795. ;; Force recomputation, in case it was computed during the dump.
  796. (setq abbreviated-home-dir nil)
  797. ;; See if we should import version-control from the environment variable.
  798. (let ((vc (getenv "VERSION_CONTROL")))
  799. (cond ((eq vc nil)) ;don't do anything if not set
  800. ((member vc '("t" "numbered"))
  801. (setq version-control t))
  802. ((member vc '("nil" "existing"))
  803. (setq version-control nil))
  804. ((member vc '("never" "simple"))
  805. (setq version-control 'never))))
  806. ;;! This has been commented out; I currently find the behavior when
  807. ;;! split-window-keep-point is nil disturbing, but if I can get used
  808. ;;! to it, then it would be better to eliminate the option.
  809. ;;! ;; Choose a good default value for split-window-keep-point.
  810. ;;! (setq split-window-keep-point (> baud-rate 2400))
  811. ;; Convert preloaded file names in load-history to absolute.
  812. (let ((simple-file-name
  813. ;; Look for simple.el or simple.elc and use their directory
  814. ;; as the place where all Lisp files live.
  815. (locate-file "simple" load-path (get-load-suffixes)))
  816. lisp-dir)
  817. ;; Don't abort if simple.el cannot be found, but print a warning.
  818. ;; Although in most usage we are going to cryptically abort a moment
  819. ;; later anyway, due to missing required bidi data files (eg bug#13430).
  820. (if (null simple-file-name)
  821. (let ((standard-output 'external-debugging-output)
  822. (lispdir (expand-file-name "../lisp" data-directory)))
  823. (princ "Warning: Could not find simple.el or simple.elc")
  824. (terpri)
  825. (when (getenv "EMACSLOADPATH")
  826. (princ "The EMACSLOADPATH environment variable is set, \
  827. please check its value")
  828. (terpri))
  829. (unless (file-readable-p lispdir)
  830. (princ (format "Lisp directory %s not readable?" lispdir))
  831. (terpri)))
  832. (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
  833. (setq load-history
  834. (mapcar (lambda (elt)
  835. (if (and (stringp (car elt))
  836. (not (file-name-absolute-p (car elt))))
  837. (cons (concat lisp-dir
  838. (car elt))
  839. (cdr elt))
  840. elt))
  841. load-history))))
  842. ;; Convert the arguments to Emacs internal representation.
  843. (let ((args command-line-args))
  844. (while args
  845. (setcar args
  846. (decode-coding-string (car args) locale-coding-system t))
  847. (pop args)))
  848. (let ((done nil)
  849. (args (cdr command-line-args))
  850. display-arg)
  851. ;; Figure out which user's init file to load,
  852. ;; either from the environment or from the options.
  853. (setq init-file-user (if noninteractive nil (user-login-name)))
  854. ;; If user has not done su, use current $HOME to find .emacs.
  855. (and init-file-user
  856. (equal init-file-user (user-real-login-name))
  857. (setq init-file-user ""))
  858. ;; Process the command-line args, and delete the arguments
  859. ;; processed. This is consistent with the way main in emacs.c
  860. ;; does things.
  861. (while (and (not done) args)
  862. (let* ((longopts '(("--no-init-file") ("--no-site-file")
  863. ("--no-x-resources") ("--debug-init")
  864. ("--user") ("--iconic") ("--icon-type") ("--quick")
  865. ("--no-blinking-cursor") ("--basic-display")))
  866. (argi (pop args))
  867. (orig-argi argi)
  868. argval)
  869. ;; Handle --OPTION=VALUE format.
  870. (when (string-match "\\`\\(--[^=]*\\)=" argi)
  871. (setq argval (substring argi (match-end 0))
  872. argi (match-string 1 argi)))
  873. (when (string-match "\\`--." orig-argi)
  874. (let ((completion (try-completion argi longopts)))
  875. (cond ((eq completion t)
  876. (setq argi (substring argi 1)))
  877. ((stringp completion)
  878. (let ((elt (assoc completion longopts)))
  879. (unless elt
  880. (error "Option `%s' is ambiguous" argi))
  881. (setq argi (substring (car elt) 1))))
  882. (t
  883. (setq argval nil
  884. argi orig-argi)))))
  885. (cond
  886. ;; The --display arg is handled partly in C, partly in Lisp.
  887. ;; When it shows up here, we just put it back to be handled
  888. ;; by `command-line-1'.
  889. ((member argi '("-d" "-display"))
  890. (setq display-arg (list argi (pop args))))
  891. ((member argi '("-Q" "-quick"))
  892. (setq init-file-user nil
  893. site-run-file nil
  894. inhibit-x-resources t)
  895. ;; Stop it showing up in emacs -Q's customize-rogue.
  896. (put 'site-run-file 'standard-value '(nil)))
  897. ((member argi '("-no-x-resources"))
  898. (setq inhibit-x-resources t))
  899. ((member argi '("-D" "-basic-display"))
  900. (setq no-blinking-cursor t
  901. emacs-basic-display t)
  902. (push '(vertical-scroll-bars . nil) initial-frame-alist))
  903. ((member argi '("-q" "-no-init-file"))
  904. (setq init-file-user nil))
  905. ((member argi '("-u" "-user"))
  906. (setq init-file-user (or argval (pop args))
  907. argval nil))
  908. ((equal argi "-no-site-file")
  909. (setq site-run-file nil)
  910. (put 'site-run-file 'standard-value '(nil)))
  911. ((equal argi "-debug-init")
  912. (setq init-file-debug t))
  913. ((equal argi "-iconic")
  914. (push '(visibility . icon) initial-frame-alist))
  915. ((member argi '("-nbc" "-no-blinking-cursor"))
  916. (setq no-blinking-cursor t))
  917. ;; Push the popped arg back on the list of arguments.
  918. (t
  919. (push argi args)
  920. (setq done t)))
  921. ;; Was argval set but not used?
  922. (and argval
  923. (error "Option `%s' doesn't allow an argument" argi))))
  924. ;; Re-attach the --display arg.
  925. (and display-arg (setq args (append display-arg args)))
  926. ;; Re-attach the program name to the front of the arg list.
  927. (and command-line-args
  928. (setcdr command-line-args args)))
  929. ;; Make sure window system's init file was loaded in loadup.el if
  930. ;; using a window system.
  931. ;; Initialize the window-system only after processing the command-line
  932. ;; args so that -Q can influence this initialization.
  933. (condition-case error
  934. (unless noninteractive
  935. (if (and initial-window-system
  936. (not (featurep
  937. (intern
  938. (concat (symbol-name initial-window-system) "-win")))))
  939. (error "Unsupported window system `%s'" initial-window-system))
  940. ;; Process window-system specific command line parameters.
  941. (setq command-line-args
  942. (let ((window-system initial-window-system)) ;Hack attack!
  943. (handle-args-function command-line-args)))
  944. ;; Initialize the window system. (Open connection, etc.)
  945. (let ((window-system initial-window-system)) ;Hack attack!
  946. (window-system-initialization))
  947. (put initial-window-system 'window-system-initialized t))
  948. ;; If there was an error, print the error message and exit.
  949. (error
  950. (princ
  951. (if (eq (car error) 'error)
  952. (apply 'concat (cdr error))
  953. (if (memq 'file-error (get (car error) 'error-conditions))
  954. (format "%s: %s"
  955. (nth 1 error)
  956. (mapconcat (lambda (obj) (prin1-to-string obj t))
  957. (cdr (cdr error)) ", "))
  958. (format "%s: %s"
  959. (get (car error) 'error-message)
  960. (mapconcat (lambda (obj) (prin1-to-string obj t))
  961. (cdr error) ", "))))
  962. 'external-debugging-output)
  963. (terpri 'external-debugging-output)
  964. (setq initial-window-system nil)
  965. (kill-emacs)))
  966. (run-hooks 'before-init-hook)
  967. ;; Under X, create the X frame and delete the terminal frame.
  968. (unless (daemonp)
  969. (if (or noninteractive emacs-basic-display)
  970. (setq menu-bar-mode nil
  971. tool-bar-mode nil
  972. no-blinking-cursor t))
  973. (frame-initialize))
  974. (when (fboundp 'x-create-frame)
  975. ;; Set up the tool-bar (even in tty frames, since Emacs might open a
  976. ;; graphical frame later).
  977. (unless noninteractive
  978. (tool-bar-setup)))
  979. ;; Turn off blinking cursor if so specified in X resources. This is here
  980. ;; only because all other settings of no-blinking-cursor are here.
  981. (unless (or noninteractive
  982. emacs-basic-display
  983. (and (memq window-system '(x w32 ns))
  984. (not (member (x-get-resource "cursorBlink" "CursorBlink")
  985. '("no" "off" "false" "0")))))
  986. (setq no-blinking-cursor t))
  987. (unless noninteractive
  988. (startup--setup-quote-display)
  989. (setq internal--text-quoting-flag t))
  990. ;; Re-evaluate predefined variables whose initial value depends on
  991. ;; the runtime context.
  992. (mapc 'custom-reevaluate-setting
  993. ;; Initialize them in the same order they were loaded, in case there
  994. ;; are dependencies between them.
  995. (prog1 (nreverse custom-delayed-init-variables)
  996. (setq custom-delayed-init-variables nil)))
  997. (normal-erase-is-backspace-setup-frame)
  998. ;; Register default TTY colors for the case the terminal hasn't a
  999. ;; terminal init file. We do this regardless of whether the terminal
  1000. ;; supports colors or not and regardless the current display type,
  1001. ;; since users can connect to color-capable terminals and also
  1002. ;; switch color support on or off in mid-session by setting the
  1003. ;; tty-color-mode frame parameter.
  1004. ;; Exception: the `pc' ``window system'' has only 16 fixed colors,
  1005. ;; and they are already set at this point by a suitable method of
  1006. ;; window-system-initialization.
  1007. (or (eq initial-window-system 'pc)
  1008. (tty-register-default-colors))
  1009. (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
  1010. (old-face-ignored-fonts face-ignored-fonts))
  1011. ;; Run the site-start library if it exists. The point of this file is
  1012. ;; that it is run before .emacs. There is no point in doing this after
  1013. ;; .emacs; that is useless.
  1014. ;; Note that user-init-file is nil at this point. Code that might
  1015. ;; be loaded from site-run-file and wants to test if -q was given
  1016. ;; should check init-file-user instead, since that is already set.
  1017. ;; See cus-edit.el for an example.
  1018. (if site-run-file
  1019. (load site-run-file t t))
  1020. ;; Sites should not disable this. Only individuals should disable
  1021. ;; the startup screen.
  1022. (setq inhibit-startup-screen nil)
  1023. ;; Warn for invalid user name.
  1024. (when init-file-user
  1025. (if (string-match "[~/:\n]" init-file-user)
  1026. (display-warning 'initialization
  1027. (format "Invalid user name %s"
  1028. init-file-user)
  1029. :error)
  1030. (if (file-directory-p (expand-file-name
  1031. ;; We don't support ~USER on MS-Windows
  1032. ;; and MS-DOS except for the current
  1033. ;; user, and always load .emacs from
  1034. ;; the current user's home directory
  1035. ;; (see below). So always check "~",
  1036. ;; even if invoked with "-u USER", or
  1037. ;; if $USER or $LOGNAME are set to
  1038. ;; something different.
  1039. (if (memq system-type '(windows-nt ms-dos))
  1040. "~"
  1041. (concat "~" init-file-user))))
  1042. nil
  1043. (display-warning 'initialization
  1044. (format "User %s has no home directory"
  1045. (if (equal init-file-user "")
  1046. (user-real-login-name)
  1047. init-file-user))
  1048. :error))))
  1049. ;; Load that user's init file, or the default one, or none.
  1050. (let (debug-on-error-from-init-file
  1051. debug-on-error-should-be-set
  1052. (debug-on-error-initial
  1053. (if (eq init-file-debug t) 'startup init-file-debug))
  1054. (orig-enable-multibyte (default-value 'enable-multibyte-characters)))
  1055. (let ((debug-on-error debug-on-error-initial)
  1056. ;; This function actually reads the init files.
  1057. (inner
  1058. (function
  1059. (lambda ()
  1060. (if init-file-user
  1061. (let ((user-init-file-1
  1062. (cond
  1063. ((eq system-type 'ms-dos)
  1064. (concat "~" init-file-user "/_emacs"))
  1065. ((not (eq system-type 'windows-nt))
  1066. (concat "~" init-file-user "/.emacs"))
  1067. ;; Else deal with the Windows situation
  1068. ((directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
  1069. ;; Prefer .emacs on Windows.
  1070. "~/.emacs")
  1071. ((directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
  1072. ;; Also support _emacs for compatibility, but warn about it.
  1073. (push `(initialization
  1074. ,(format-message
  1075. "`_emacs' init file is deprecated, please use `.emacs'"))
  1076. delayed-warnings-list)
  1077. "~/_emacs")
  1078. (t ;; But default to .emacs if _emacs does not exist.
  1079. "~/.emacs"))))
  1080. ;; This tells `load' to store the file name found
  1081. ;; into user-init-file.
  1082. (setq user-init-file t)
  1083. (load user-init-file-1 t t)
  1084. (when (eq user-init-file t)
  1085. ;; If we did not find ~/.emacs, try
  1086. ;; ~/.emacs.d/init.el.
  1087. (let ((otherfile
  1088. (expand-file-name
  1089. "init"
  1090. (file-name-as-directory
  1091. (concat "~" init-file-user "/.emacs.d")))))
  1092. (load otherfile t t)
  1093. ;; If we did not find the user's init file,
  1094. ;; set user-init-file conclusively.
  1095. ;; Don't let it be set from default.el.
  1096. (when (eq user-init-file t)
  1097. (setq user-init-file user-init-file-1))))
  1098. ;; If we loaded a compiled file, set
  1099. ;; `user-init-file' to the source version if that
  1100. ;; exists.
  1101. (when (and user-init-file
  1102. (equal (file-name-extension user-init-file)
  1103. "elc"))
  1104. (let* ((source (file-name-sans-extension user-init-file))
  1105. (alt (concat source ".el")))
  1106. (setq source (cond ((file-exists-p alt) alt)
  1107. ((file-exists-p source) source)
  1108. (t nil)))
  1109. (when source
  1110. (when (file-newer-than-file-p source user-init-file)
  1111. (message "Warning: %s is newer than %s"
  1112. source user-init-file)
  1113. (sit-for 1))
  1114. (setq user-init-file source))))
  1115. (unless inhibit-default-init
  1116. (let ((inhibit-startup-screen nil))
  1117. ;; Users are supposed to be told their rights.
  1118. ;; (Plus how to get help and how to undo.)
  1119. ;; Don't you dare turn this off for anyone
  1120. ;; except yourself.
  1121. (load "default" t t)))))))))
  1122. (if init-file-debug
  1123. ;; Do this without a condition-case if the user wants to debug.
  1124. (funcall inner)
  1125. (condition-case error
  1126. (progn
  1127. (funcall inner)
  1128. (setq init-file-had-error nil))
  1129. (error
  1130. (display-warning
  1131. 'initialization
  1132. (format-message "\
  1133. An error occurred while loading `%s':\n\n%s%s%s\n\n\
  1134. To ensure normal operation, you should investigate and remove the
  1135. cause of the error in your initialization file. Start Emacs with
  1136. the `--debug-init' option to view a complete error backtrace."
  1137. user-init-file
  1138. (get (car error) 'error-message)
  1139. (if (cdr error) ": " "")
  1140. (mapconcat (lambda (s) (prin1-to-string s t))
  1141. (cdr error) ", "))
  1142. :warning)
  1143. (setq init-file-had-error t))))
  1144. (if (and deactivate-mark transient-mark-mode)
  1145. (with-current-buffer (window-buffer)
  1146. (deactivate-mark)))
  1147. ;; If the user has a file of abbrevs, read it (unless -batch).
  1148. (when (and (not noninteractive)
  1149. (file-exists-p abbrev-file-name)
  1150. (file-readable-p abbrev-file-name))
  1151. (quietly-read-abbrev-file abbrev-file-name))
  1152. ;; If the abbrevs came entirely from the init file or the
  1153. ;; abbrevs file, they do not need saving.
  1154. (setq abbrevs-changed nil)
  1155. ;; If we can tell that the init file altered debug-on-error,
  1156. ;; arrange to preserve the value that it set up.
  1157. (or (eq debug-on-error debug-on-error-initial)
  1158. (setq debug-on-error-should-be-set t
  1159. debug-on-error-from-init-file debug-on-error)))
  1160. (if debug-on-error-should-be-set
  1161. (setq debug-on-error debug-on-error-from-init-file))
  1162. (unless (or (default-value 'enable-multibyte-characters)
  1163. (eq orig-enable-multibyte (default-value
  1164. 'enable-multibyte-characters)))
  1165. ;; Init file changed to unibyte. Reset existing multibyte
  1166. ;; buffers (probably *scratch*, *Messages*, *Minibuf-0*).
  1167. ;; Arguably this should only be done if they're free of
  1168. ;; multibyte characters.
  1169. (mapc (lambda (buffer)
  1170. (with-current-buffer buffer
  1171. (if enable-multibyte-characters
  1172. (set-buffer-multibyte nil))))
  1173. (buffer-list))
  1174. ;; Also re-set the language environment in case it was
  1175. ;; originally done before unibyte was set and is sensitive to
  1176. ;; unibyte (display table, terminal coding system &c).
  1177. (set-language-environment current-language-environment)))
  1178. ;; Do this here in case the init file sets mail-host-address.
  1179. (and mail-host-address
  1180. ;; Check that user-mail-address has not been set by hand.
  1181. ;; Yes, this is ugly, but slightly less so than leaving
  1182. ;; user-mail-address uninitialized during init file processing.
  1183. ;; Perhaps we should make :set-after do something like this?
  1184. ;; Ie, extend it to also mean (re)initialize-after. See etc/TODO.
  1185. (equal user-mail-address
  1186. (let (mail-host-address)
  1187. (ignore-errors
  1188. (eval (car (get 'user-mail-address 'standard-value))))))
  1189. (custom-reevaluate-setting 'user-mail-address))
  1190. ;; If parameter have been changed in the init file which influence
  1191. ;; face realization, clear the face cache so that new faces will
  1192. ;; be realized.
  1193. (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
  1194. (eq face-ignored-fonts old-face-ignored-fonts))
  1195. (clear-face-cache)))
  1196. ;; If any package directory exists, initialize the package system.
  1197. (and user-init-file
  1198. package-enable-at-startup
  1199. (catch 'package-dir-found
  1200. (let (dirs)
  1201. (if (boundp 'package-directory-list)
  1202. (setq dirs package-directory-list)
  1203. (dolist (f load-path)
  1204. (and (stringp f)
  1205. (equal (file-name-nondirectory f) "site-lisp")
  1206. (push (expand-file-name "elpa" f) dirs))))
  1207. (push (if (boundp 'package-user-dir)
  1208. package-user-dir
  1209. (locate-user-emacs-file "elpa"))
  1210. dirs)
  1211. (dolist (dir dirs)
  1212. (when (file-directory-p dir)
  1213. (dolist (subdir (directory-files dir))
  1214. (when (let ((subdir (expand-file-name subdir dir)))
  1215. (and (file-directory-p subdir)
  1216. (file-exists-p
  1217. (expand-file-name
  1218. (package--description-file subdir)
  1219. subdir))))
  1220. (throw 'package-dir-found t)))))))
  1221. (package-initialize))
  1222. (setq after-init-time (current-time))
  1223. ;; Display any accumulated warnings after all functions in
  1224. ;; `after-init-hook' like `desktop-read' have finalized possible
  1225. ;; changes in the window configuration.
  1226. (run-hooks 'after-init-hook 'delayed-warnings-hook)
  1227. ;; If *scratch* exists and init file didn't change its mode, initialize it.
  1228. (if (get-buffer "*scratch*")
  1229. (with-current-buffer "*scratch*"
  1230. (if (eq major-mode 'fundamental-mode)
  1231. (funcall initial-major-mode))))
  1232. ;; Load library for our terminal type.
  1233. ;; User init file can set term-file-prefix to nil to prevent this.
  1234. (unless (or noninteractive
  1235. initial-window-system
  1236. (daemonp))
  1237. (tty-run-terminal-initialization (selected-frame) nil t))
  1238. ;; Update the out-of-memory error message based on user's key bindings
  1239. ;; for save-some-buffers.
  1240. (setq memory-signal-data
  1241. (list 'error
  1242. (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
  1243. ;; Process the remaining args.
  1244. (command-line-1 (cdr command-line-args))
  1245. ;; This is a problem because, e.g. if emacs.d/gnus.el exists,
  1246. ;; trying to load gnus could load the wrong file.
  1247. ;; OK, it would not matter if .emacs.d were at the end of load-path.
  1248. ;; but for the sake of simplicity, we discourage it full-stop.
  1249. ;; Ref eg http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00056.html
  1250. ;;
  1251. ;; A bad element could come from user-emacs-file, the command line,
  1252. ;; or EMACSLOADPATH, so we basically always have to check.
  1253. (let (warned)
  1254. (dolist (dir load-path)
  1255. (and (not warned)
  1256. (stringp dir)
  1257. (string-equal (file-name-as-directory (expand-file-name dir))
  1258. (expand-file-name user-emacs-directory))
  1259. (setq warned t)
  1260. (display-warning 'initialization
  1261. (format-message "\
  1262. Your `load-path' seems to contain\n\
  1263. your `.emacs.d' directory: %s\n\
  1264. This is likely to cause problems...\n\
  1265. Consider using a subdirectory instead, e.g.: %s"
  1266. dir (expand-file-name
  1267. "lisp" user-emacs-directory))
  1268. :warning))))
  1269. ;; If -batch, terminate after processing the command options.
  1270. (if noninteractive (kill-emacs t))
  1271. ;; In daemon mode, start the server to allow clients to connect.
  1272. ;; This is done after loading the user's init file and after
  1273. ;; processing all command line arguments to allow e.g. `server-name'
  1274. ;; to be changed before the server starts.
  1275. (let ((dn (daemonp)))
  1276. (when dn
  1277. (when (stringp dn) (setq server-name dn))
  1278. (server-start)
  1279. (if server-process
  1280. (daemon-initialized)
  1281. (if (stringp dn)
  1282. (message
  1283. "Unable to start daemon: Emacs server named %S already running"
  1284. server-name)
  1285. (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process."))
  1286. (kill-emacs 1))))
  1287. ;; Run emacs-session-restore (session management) if started by
  1288. ;; the session manager and we have a session manager connection.
  1289. (if (and (boundp 'x-session-previous-id)
  1290. (stringp x-session-previous-id))
  1291. (with-no-warnings
  1292. (emacs-session-restore x-session-previous-id))))
  1293. (defun x-apply-session-resources ()
  1294. "Apply X resources which specify initial values for Emacs variables.
  1295. This is called from a window-system initialization function, such
  1296. as `x-initialize-window-system' for X, either at startup (prior
  1297. to reading the init file), or afterwards when the user first
  1298. opens a graphical frame.
  1299. This can set the values of `menu-bar-mode', `tool-bar-mode', and
  1300. `no-blinking-cursor', as well as the `cursor' face. Changed
  1301. settings will be marked as \"CHANGED outside of Customize\"."
  1302. (let ((no-vals '("no" "off" "false" "0"))
  1303. (settings '(("menuBar" "MenuBar" menu-bar-mode nil)
  1304. ("toolBar" "ToolBar" tool-bar-mode nil)
  1305. ("scrollBar" "ScrollBar" scroll-bar-mode nil)
  1306. ("cursorBlink" "CursorBlink" no-blinking-cursor t))))
  1307. (dolist (x settings)
  1308. (if (member (x-get-resource (nth 0 x) (nth 1 x)) no-vals)
  1309. (set (nth 2 x) (nth 3 x)))))
  1310. (let ((color (x-get-resource "cursorColor" "Foreground")))
  1311. (when color
  1312. (put 'cursor 'theme-face
  1313. `((changed ((t :background ,color)))))
  1314. (put 'cursor 'face-modified t))))
  1315. (defcustom initial-scratch-message (purecopy "\
  1316. ;; This buffer is for text that is not saved, and for Lisp evaluation.
  1317. ;; To create a file, visit it with \\[find-file] and enter text in its buffer.
  1318. ")
  1319. "Initial documentation displayed in *scratch* buffer at startup.
  1320. If this is nil, no message will be displayed."
  1321. :type '(choice (text :tag "Message")
  1322. (const :tag "none" nil))
  1323. :group 'initialization)
  1324. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1325. ;;; Fancy splash screen
  1326. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1327. (defconst fancy-startup-text
  1328. `((:face (variable-pitch font-lock-comment-face)
  1329. "Welcome to "
  1330. :link ("GNU Emacs"
  1331. ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
  1332. "Browse http://www.gnu.org/software/emacs/")
  1333. ", one component of the "
  1334. :link
  1335. ,(lambda ()
  1336. (if (eq system-type 'gnu/linux)
  1337. `("GNU/Linux"
  1338. ,(lambda (_button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
  1339. "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
  1340. `("GNU" ,(lambda (_button)
  1341. (browse-url "http://www.gnu.org/gnu/thegnuproject.html"))
  1342. "Browse http://www.gnu.org/gnu/thegnuproject.html")))
  1343. " operating system.\n\n"
  1344. :face variable-pitch
  1345. :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
  1346. "\tLearn basic keystroke commands"
  1347. ,(lambda ()
  1348. (let* ((en "TUTORIAL")
  1349. (tut (or (get-language-info current-language-environment
  1350. 'tutorial)
  1351. en))
  1352. (title (with-temp-buffer
  1353. (insert-file-contents
  1354. (expand-file-name tut tutorial-directory)
  1355. ;; We used to read only the first 256 bytes of
  1356. ;; the tutorial, but that prevents the coding:
  1357. ;; setting, if any, in file-local variables
  1358. ;; section to be seen by insert-file-contents,
  1359. ;; and results in gibberish when the language
  1360. ;; environment's preferred encoding is
  1361. ;; different from what the file-local variable
  1362. ;; says. One case in point is Hebrew.
  1363. nil)
  1364. (search-forward ".")
  1365. (buffer-substring (point-min) (1- (point))))))
  1366. ;; If there is a specific tutorial for the current language
  1367. ;; environment and it is not English, append its title.
  1368. (if (string= en tut)
  1369. ""
  1370. (concat " (" title ")"))))
  1371. "\n"
  1372. :link ("Emacs Guided Tour"
  1373. ,(lambda (_button)
  1374. (browse-url "http://www.gnu.org/software/emacs/tour/"))
  1375. "Browse http://www.gnu.org/software/emacs/tour/")
  1376. "\tOverview of Emacs features at gnu.org\n"
  1377. :link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual)))
  1378. "\tView the Emacs manual using Info\n"
  1379. :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
  1380. "\tGNU Emacs comes with "
  1381. :face (variable-pitch (:slant oblique))
  1382. "ABSOLUTELY NO WARRANTY\n"
  1383. :face variable-pitch
  1384. :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
  1385. "\tConditions for redistributing and changing Emacs\n"
  1386. :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
  1387. "\tPurchasing printed copies of manuals\n"
  1388. "\n"))
  1389. "A list of texts to show in the middle part of splash screens.
  1390. Each element in the list should be a list of strings or pairs
  1391. `:face FACE', like `fancy-splash-insert' accepts them.")
  1392. (defconst fancy-about-text
  1393. `((:face (variable-pitch font-lock-comment-face)
  1394. "This is "
  1395. :link ("GNU Emacs"
  1396. ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
  1397. "Browse http://www.gnu.org/software/emacs/")
  1398. ", one component of the "
  1399. :link
  1400. ,(lambda ()
  1401. (if (eq system-type 'gnu/linux)
  1402. `("GNU/Linux"
  1403. ,(lambda (_button)
  1404. (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
  1405. "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
  1406. `("GNU" ,(lambda (_button) (describe-gnu-project))
  1407. "Display info on the GNU project.")))
  1408. " operating system.\n"
  1409. :face (variable-pitch font-lock-builtin-face)
  1410. "\n"
  1411. ,(lambda () (emacs-version))
  1412. "\n"
  1413. :face (variable-pitch (:height 0.8))
  1414. ,(lambda () emacs-copyright)
  1415. "\n\n"
  1416. :face variable-pitch
  1417. :link ("Authors"
  1418. ,(lambda (_button)
  1419. (view-file (expand-file-name "AUTHORS" data-directory))
  1420. (goto-char (point-min))))
  1421. "\tMany people have contributed code included in GNU Emacs\n"
  1422. :link ("Contributing"
  1423. ,(lambda (_button) (info "(emacs)Contributing")))
  1424. "\tHow to contribute improvements to Emacs\n"
  1425. "\n"
  1426. :link ("GNU and Freedom" ,(lambda (_button) (describe-gnu-project)))
  1427. "\tWhy we developed GNU Emacs, and the GNU operating system\n"
  1428. :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
  1429. "\tGNU Emacs comes with "
  1430. :face (variable-pitch (:slant oblique))
  1431. "ABSOLUTELY NO WARRANTY\n"
  1432. :face variable-pitch
  1433. :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
  1434. "\tConditions for redistributing and changing Emacs\n"
  1435. :link ("Getting New Versions" ,(lambda (_button) (describe-distribution)))
  1436. "\tHow to obtain the latest version of Emacs\n"
  1437. :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
  1438. "\tBuying printed manuals from the FSF\n"
  1439. "\n"
  1440. :link ("Emacs Tutorial" ,(lambda (_button) (help-with-tutorial)))
  1441. "\tLearn basic Emacs keystroke commands"
  1442. ,(lambda ()
  1443. (let* ((en "TUTORIAL")
  1444. (tut (or (get-language-info current-language-environment
  1445. 'tutorial)
  1446. en))
  1447. (title (with-temp-buffer
  1448. (insert-file-contents
  1449. (expand-file-name tut tutorial-directory)
  1450. ;; Read the entire file, to make sure any
  1451. ;; coding cookies and other local variables
  1452. ;; get acted upon.
  1453. nil)
  1454. (search-forward ".")
  1455. (buffer-substring (point-min) (1- (point))))))
  1456. ;; If there is a specific tutorial for the current language
  1457. ;; environment and it is not English, append its title.
  1458. (if (string= en tut)
  1459. ""
  1460. (concat " (" title ")"))))
  1461. "\n"
  1462. :link ("Emacs Guided Tour"
  1463. ,(lambda (_button)
  1464. (browse-url "http://www.gnu.org/software/emacs/tour/"))
  1465. "Browse http://www.gnu.org/software/emacs/tour/")
  1466. "\tSee an overview of Emacs features at gnu.org"))
  1467. "A list of texts to show in the middle part of the About screen.
  1468. Each element in the list should be a list of strings or pairs
  1469. `:face FACE', like `fancy-splash-insert' accepts them.")
  1470. (defgroup fancy-splash-screen ()
  1471. "Fancy splash screen when Emacs starts."
  1472. :version "21.1"
  1473. :group 'initialization)
  1474. (defcustom fancy-splash-image nil
  1475. "The image to show in the splash screens, or nil for defaults."
  1476. :group 'fancy-splash-screen
  1477. :type '(choice (const :tag "Default" nil)
  1478. (file :tag "File")))
  1479. (defvar splash-screen-keymap
  1480. (let ((map (make-sparse-keymap)))
  1481. (suppress-keymap map)
  1482. (set-keymap-parent map button-buffer-map)
  1483. (define-key map "\C-?" 'scroll-down-command)
  1484. (define-key map [?\S-\ ] 'scroll-down-command)
  1485. (define-key map " " 'scroll-up-command)
  1486. (define-key map "q" 'exit-splash-screen)
  1487. map)
  1488. "Keymap for splash screen buffer.")
  1489. ;; These are temporary storage areas for the splash screen display.
  1490. (defun fancy-splash-insert (&rest args)
  1491. "Insert text into the current buffer, with faces.
  1492. Arguments from ARGS should be either strings; functions called
  1493. with no args that return a string; pairs `:face FACE', where FACE
  1494. is a face specification usable with `put-text-property'; or pairs
  1495. `:link LINK' where LINK is a list of arguments to pass to
  1496. `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which
  1497. specifies the button's label, `action' property and help-echo string.
  1498. FACE and LINK can also be functions, which are evaluated to obtain
  1499. a face or button specification."
  1500. (let ((current-face nil))
  1501. (while args
  1502. (cond ((eq (car args) :face)
  1503. (setq args (cdr args) current-face (car args))
  1504. (if (functionp current-face)
  1505. (setq current-face (funcall current-face))))
  1506. ((eq (car args) :link)
  1507. (setq args (cdr args))
  1508. (let ((spec (car args)))
  1509. (if (functionp spec)
  1510. (setq spec (funcall spec)))
  1511. (insert-button (car spec)
  1512. 'face (list 'link current-face)
  1513. 'action (cadr spec)
  1514. 'help-echo (concat "mouse-2, RET: "
  1515. (or (nth 2 spec)
  1516. "Follow this link"))
  1517. 'follow-link t)))
  1518. (t (insert (propertize (let ((it (car args)))
  1519. (if (functionp it)
  1520. (funcall it)
  1521. it))
  1522. 'face current-face
  1523. 'help-echo (startup-echo-area-message)))))
  1524. (setq args (cdr args)))))
  1525. (declare-function image-size "image.c" (spec &optional pixels frame))
  1526. (defun fancy-splash-image-file ()
  1527. (cond ((stringp fancy-splash-image) fancy-splash-image)
  1528. ((display-color-p)
  1529. (cond ((<= (display-planes) 8)
  1530. (if (image-type-available-p 'xpm)
  1531. "splash.xpm"
  1532. "splash.pbm"))
  1533. ((or (image-type-available-p 'svg)
  1534. (image-type-available-p 'imagemagick))
  1535. "splash.svg")
  1536. ((image-type-available-p 'png)
  1537. "splash.png")
  1538. ((image-type-available-p 'xpm)
  1539. "splash.xpm")
  1540. (t "splash.pbm")))
  1541. (t "splash.pbm")))
  1542. (defun fancy-splash-head ()
  1543. "Insert the head part of the splash screen into the current buffer."
  1544. (let* ((image-file (fancy-splash-image-file))
  1545. (img (create-image image-file))
  1546. (image-width (and img (car (image-size img))))
  1547. (window-width (window-width)))
  1548. (when img
  1549. (when (> window-width image-width)
  1550. ;; Center the image in the window.
  1551. (insert (propertize " " 'display
  1552. `(space :align-to (+ center (-0.5 . ,img)))))
  1553. ;; Change the color of the XPM version of the splash image
  1554. ;; so that it is visible with a dark frame background.
  1555. (when (and (memq 'xpm img)
  1556. (eq (frame-parameter nil 'background-mode) 'dark))
  1557. (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
  1558. ;; Insert the image with a help-echo and a link.
  1559. (make-button (prog1 (point) (insert-image img)) (point)
  1560. 'face 'default
  1561. 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
  1562. 'action (lambda (_button) (browse-url "http://www.gnu.org/"))
  1563. 'follow-link t)
  1564. (insert "\n\n")))))
  1565. (defun fancy-startup-tail (&optional concise)
  1566. "Insert the tail part of the splash screen into the current buffer."
  1567. (unless concise
  1568. (fancy-splash-insert
  1569. :face 'variable-pitch
  1570. "\nTo start... "
  1571. :link `("Open a File"
  1572. ,(lambda (_button) (call-interactively 'find-file))
  1573. "Specify a new file's name, to edit the file")
  1574. " "
  1575. :link `("Open Home Directory"
  1576. ,(lambda (_button) (dired "~"))
  1577. "Open your home directory, to operate on its files")
  1578. " "
  1579. :link `("Customize Startup"
  1580. ,(lambda (_button) (customize-group 'initialization))
  1581. "Change initialization settings including this screen")
  1582. "\n"))
  1583. (fancy-splash-insert
  1584. :face 'variable-pitch "To quit a partially entered command, type "
  1585. :face 'default "Control-g"
  1586. :face 'variable-pitch ".\n")
  1587. (fancy-splash-insert :face `(variable-pitch font-lock-builtin-face)
  1588. "\nThis is "
  1589. (emacs-version)
  1590. "\n"
  1591. :face '(variable-pitch (:height 0.8))
  1592. emacs-copyright
  1593. "\n")
  1594. (when auto-save-list-file-prefix
  1595. (let ((dir (file-name-directory auto-save-list-file-prefix))
  1596. (name (file-name-nondirectory auto-save-list-file-prefix))
  1597. files)
  1598. ;; Don't warn if the directory for auto-save-list files does not
  1599. ;; yet exist.
  1600. (and (file-directory-p dir)
  1601. (setq files (directory-files dir nil (concat "\\`" name) t))
  1602. (fancy-splash-insert :face '(variable-pitch font-lock-comment-face)
  1603. (if (= (length files) 1)
  1604. "\nAn auto-save file list was found. "
  1605. "\nAuto-save file lists were found. ")
  1606. "If an Emacs session crashed recently,\ntype "
  1607. :link `("M-x recover-session RET"
  1608. ,(lambda (_button)
  1609. (call-interactively
  1610. 'recover-session)))
  1611. " to recover the files you were editing."))))
  1612. (when concise
  1613. (fancy-splash-insert
  1614. :face 'variable-pitch "\n"
  1615. :link `("Dismiss this startup screen"
  1616. ,(lambda (_button)
  1617. (when startup-screen-inhibit-startup-screen
  1618. (customize-set-variable 'inhibit-startup-screen t)
  1619. (customize-mark-to-save 'inhibit-startup-screen)
  1620. (custom-save-all))
  1621. (let ((w (get-buffer-window "*GNU Emacs*")))
  1622. (and w (not (one-window-p)) (delete-window w)))
  1623. (kill-buffer "*GNU Emacs*")))
  1624. " ")
  1625. (when (or user-init-file custom-file)
  1626. (let ((checked (create-image "checked.xpm"
  1627. nil nil :ascent 'center))
  1628. (unchecked (create-image "unchecked.xpm"
  1629. nil nil :ascent 'center)))
  1630. (insert-button
  1631. " "
  1632. :on-glyph checked
  1633. :off-glyph unchecked
  1634. 'checked nil 'display unchecked 'follow-link t
  1635. 'action (lambda (button)
  1636. (if (overlay-get button 'checked)
  1637. (progn (overlay-put button 'checked nil)
  1638. (overlay-put button 'display
  1639. (overlay-get button :off-glyph))
  1640. (setq startup-screen-inhibit-startup-screen
  1641. nil))
  1642. (overlay-put button 'checked t)
  1643. (overlay-put button 'display
  1644. (overlay-get button :on-glyph))
  1645. (setq startup-screen-inhibit-startup-screen t)))))
  1646. (fancy-splash-insert :face '(variable-pitch (:height 0.9))
  1647. " Never show it again."))))
  1648. (defun exit-splash-screen ()
  1649. "Stop displaying the splash screen buffer."
  1650. (interactive)
  1651. (quit-window t))
  1652. (defun fancy-startup-screen (&optional concise)
  1653. "Display fancy startup screen.
  1654. If CONCISE is non-nil, display a concise version of the
  1655. splash screen in another window."
  1656. (let ((splash-buffer (get-buffer-create "*GNU Emacs*")))
  1657. (with-current-buffer splash-buffer
  1658. (let ((inhibit-read-only t))
  1659. (erase-buffer)
  1660. (setq default-directory command-line-default-directory)
  1661. (make-local-variable 'startup-screen-inhibit-startup-screen)
  1662. (if pure-space-overflow
  1663. (insert pure-space-overflow-message))
  1664. (unless concise
  1665. (fancy-splash-head))
  1666. (dolist (text fancy-startup-text)
  1667. (apply #'fancy-splash-insert text)
  1668. (insert "\n"))
  1669. (skip-chars-backward "\n")
  1670. (delete-region (point) (point-max))
  1671. (insert "\n")
  1672. (fancy-startup-tail concise))
  1673. (use-local-map splash-screen-keymap)
  1674. (setq-local browse-url-browser-function 'eww-browse-url)
  1675. (setq tab-width 22
  1676. buffer-read-only t)
  1677. (set-buffer-modified-p nil)
  1678. (if (and view-read-only (not view-mode))
  1679. (view-mode-enter nil 'kill-buffer))
  1680. (goto-char (point-min))
  1681. (forward-line (if concise 2 4)))
  1682. (if concise
  1683. (progn
  1684. (display-buffer splash-buffer)
  1685. ;; If the splash screen is in a split window, fit it.
  1686. (let ((window (get-buffer-window splash-buffer t)))
  1687. (or (null window)
  1688. (eq window (selected-window))
  1689. (eq window (next-window window))
  1690. (fit-window-to-buffer window))))
  1691. (switch-to-buffer splash-buffer))))
  1692. (defun fancy-about-screen ()
  1693. "Display fancy About screen."
  1694. (let ((frame (fancy-splash-frame)))
  1695. (save-selected-window
  1696. (select-frame frame)
  1697. (switch-to-buffer "*About GNU Emacs*")
  1698. (setq buffer-undo-list t)
  1699. (let ((inhibit-read-only t))
  1700. (erase-buffer)
  1701. (if pure-space-overflow
  1702. (insert pure-space-overflow-message))
  1703. (fancy-splash-head)
  1704. (dolist (text fancy-about-text)
  1705. (apply #'fancy-splash-insert text)
  1706. (insert "\n"))
  1707. (set-buffer-modified-p nil)
  1708. (goto-char (point-min))
  1709. (force-mode-line-update))
  1710. (use-local-map splash-screen-keymap)
  1711. (setq-local browse-url-browser-function 'eww-browse-url)
  1712. (setq tab-width 22)
  1713. (setq buffer-read-only t)
  1714. (goto-char (point-min))
  1715. (forward-line 3))))
  1716. (defun fancy-splash-frame ()
  1717. "Return the frame to use for the fancy splash screen.
  1718. Returning non-nil does not mean we should necessarily
  1719. use the fancy splash screen, but if we do use it,
  1720. we put it on this frame."
  1721. (let (chosen-frame)
  1722. ;; MS-Windows needs this to have a chance to make the initial
  1723. ;; frame visible.
  1724. (if (eq (window-system) 'w32)
  1725. (sit-for 0 t))
  1726. (dolist (frame (append (frame-list) (list (selected-frame))))
  1727. (if (and (frame-visible-p frame)
  1728. (not (window-minibuffer-p (frame-selected-window frame))))
  1729. (setq chosen-frame frame)))
  1730. chosen-frame))
  1731. (defun use-fancy-splash-screens-p ()
  1732. "Return t if fancy splash screens should be used."
  1733. (when (and (display-graphic-p)
  1734. (or (and (display-color-p)
  1735. (image-type-available-p 'xpm))
  1736. (image-type-available-p 'pbm)))
  1737. (let ((frame (fancy-splash-frame)))
  1738. (when frame
  1739. (let* ((img (create-image (fancy-splash-image-file)))
  1740. (image-height (and img (cdr (image-size img nil frame))))
  1741. ;; We test frame-height and not window-height so that,
  1742. ;; if the frame is split by displaying a warning, that
  1743. ;; doesn't cause the normal splash screen to be used.
  1744. ;; We subtract 2 from frame-height to account for the
  1745. ;; echo area and the mode line.
  1746. (frame-height (- (frame-height frame) 2)))
  1747. (> frame-height (+ image-height 19)))))))
  1748. (defun normal-splash-screen (&optional startup concise)
  1749. "Display non-graphic splash screen.
  1750. If optional argument STARTUP is non-nil, display the startup screen
  1751. after Emacs starts. If STARTUP is nil, display the About screen.
  1752. If CONCISE is non-nil, display a concise version of the
  1753. splash screen in another window."
  1754. (let ((splash-buffer (get-buffer-create "*About GNU Emacs*")))
  1755. (with-current-buffer splash-buffer
  1756. (setq buffer-read-only nil)
  1757. (erase-buffer)
  1758. (setq default-directory command-line-default-directory)
  1759. (set (make-local-variable 'tab-width) 8)
  1760. (if pure-space-overflow
  1761. (insert pure-space-overflow-message))
  1762. ;; The convention for this piece of code is that
  1763. ;; each piece of output starts with one or two newlines
  1764. ;; and does not end with any newlines.
  1765. (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs"))
  1766. (insert
  1767. (if (eq system-type 'gnu/linux)
  1768. ", one component of the GNU/Linux operating system.\n"
  1769. ", a part of the GNU operating system.\n"))
  1770. (if startup
  1771. (if (display-mouse-p)
  1772. ;; The user can use the mouse to activate menus
  1773. ;; so give help in terms of menu items.
  1774. (normal-mouse-startup-screen)
  1775. ;; No mouse menus, so give help using kbd commands.
  1776. (normal-no-mouse-startup-screen))
  1777. (normal-about-screen))
  1778. ;; The rest of the startup screen is the same on all
  1779. ;; kinds of terminals.
  1780. ;; Give information on recovering, if there was a crash.
  1781. (and startup
  1782. auto-save-list-file-prefix
  1783. ;; Don't signal an error if the
  1784. ;; directory for auto-save-list files
  1785. ;; does not yet exist.
  1786. (file-directory-p (file-name-directory
  1787. auto-save-list-file-prefix))
  1788. (directory-files
  1789. (file-name-directory auto-save-list-file-prefix)
  1790. nil
  1791. (concat "\\`"
  1792. (regexp-quote (file-name-nondirectory
  1793. auto-save-list-file-prefix)))
  1794. t)
  1795. (insert "\n\nIf an Emacs session crashed recently, "
  1796. "type M-x recover-session RET\nto recover"
  1797. " the files you were editing.\n"))
  1798. (use-local-map splash-screen-keymap)
  1799. ;; Display the input that we set up in the buffer.
  1800. (set-buffer-modified-p nil)
  1801. (setq buffer-read-only t)
  1802. (if (and view-read-only (not view-mode))
  1803. (view-mode-enter nil 'kill-buffer))
  1804. (if startup (rename-buffer "*GNU Emacs*" t))
  1805. (goto-char (point-min)))
  1806. (if concise
  1807. (display-buffer splash-buffer)
  1808. (switch-to-buffer splash-buffer))))
  1809. (defun normal-mouse-startup-screen ()
  1810. ;; The user can use the mouse to activate menus
  1811. ;; so give help in terms of menu items.
  1812. (insert "\
  1813. To follow a link, click Mouse-1 on it, or move to it and type RET.
  1814. To quit a partially entered command, type Control-g.\n")
  1815. (insert "\nImportant Help menu items:\n")
  1816. (insert-button "Emacs Tutorial"
  1817. 'action (lambda (_button) (help-with-tutorial))
  1818. 'follow-link t)
  1819. (insert "\t\tLearn basic Emacs keystroke commands\n")
  1820. (insert-button "Read the Emacs Manual"
  1821. 'action (lambda (_button) (info-emacs-manual))
  1822. 'follow-link t)
  1823. (insert "\tView the Emacs manual using Info\n")
  1824. (insert-button "(Non)Warranty"
  1825. 'action (lambda (_button) (describe-no-warranty))
  1826. 'follow-link t)
  1827. (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
  1828. (insert-button "Copying Conditions"
  1829. 'action (lambda (_button) (describe-copying))
  1830. 'follow-link t)
  1831. (insert "\tConditions for redistributing and changing Emacs\n")
  1832. (insert-button "More Manuals / Ordering Manuals"
  1833. 'action (lambda (_button) (view-order-manuals))
  1834. 'follow-link t)
  1835. (insert " How to order printed manuals from the FSF\n")
  1836. (insert "\nUseful tasks:\n")
  1837. (insert-button "Visit New File"
  1838. 'action (lambda (_button) (call-interactively 'find-file))
  1839. 'follow-link t)
  1840. (insert (substitute-command-keys
  1841. "\t\tSpecify a new file's name, to edit the file\n"))
  1842. (insert-button "Open Home Directory"
  1843. 'action (lambda (_button) (dired "~"))
  1844. 'follow-link t)
  1845. (insert "\tOpen your home directory, to operate on its files\n")
  1846. (insert-button "Customize Startup"
  1847. 'action (lambda (_button) (customize-group 'initialization))
  1848. 'follow-link t)
  1849. (insert "\tChange initialization settings including this screen\n")
  1850. (insert "\n" (emacs-version)
  1851. "\n" emacs-copyright))
  1852. (defun normal-no-mouse-startup-screen ()
  1853. "Show a splash screen suitable for displays without mouse support."
  1854. (let* ((c-h-accessible
  1855. ;; If normal-erase-is-backspace is used on a tty, there's
  1856. ;; no way to invoke C-h and you have to use F1 instead.
  1857. (or (not (char-table-p keyboard-translate-table))
  1858. (eq (aref keyboard-translate-table ?\C-h) ?\C-h)))
  1859. (minor-mode-overriding-map-alist
  1860. (cons (cons (not c-h-accessible)
  1861. ;; If C-h can't be invoked, temporarily disable its
  1862. ;; binding, so where-is uses alternative bindings.
  1863. (let ((map (make-sparse-keymap)))
  1864. (define-key map [?\C-h] 'undefined)
  1865. map))
  1866. minor-mode-overriding-map-alist)))
  1867. (insert (format "\nGet help\t %s\n"
  1868. (let ((where (where-is-internal 'help-command nil t)))
  1869. (cond
  1870. ((equal where [?\C-h])
  1871. "C-h (Hold down CTRL and press h)")
  1872. (where (key-description where))
  1873. (t "M-x help")))))
  1874. (insert-button "Emacs manual"
  1875. 'action (lambda (_button) (info-emacs-manual))
  1876. 'follow-link t)
  1877. (insert (substitute-command-keys"\t \\[info-emacs-manual]\t"))
  1878. (insert-button "Browse manuals"
  1879. 'action (lambda (_button) (Info-directory))
  1880. 'follow-link t)
  1881. (insert (substitute-command-keys "\t \\[info]\n"))
  1882. (insert-button "Emacs tutorial"
  1883. 'action (lambda (_button) (help-with-tutorial))
  1884. 'follow-link t)
  1885. (insert (substitute-command-keys
  1886. "\t \\[help-with-tutorial]\tUndo changes\t \\[undo]\n"))
  1887. (insert-button "Buy manuals"
  1888. 'action (lambda (_button) (view-order-manuals))
  1889. 'follow-link t)
  1890. (insert (substitute-command-keys
  1891. "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
  1892. ;; Say how to use the menu bar with the keyboard.
  1893. (insert "\n")
  1894. (insert-button "Activate menubar"
  1895. 'action (lambda (_button) (tmm-menubar))
  1896. 'follow-link t)
  1897. (if (and (eq (key-binding "\M-`") 'tmm-menubar)
  1898. (eq (key-binding [f10]) 'tmm-menubar))
  1899. (insert " F10 or ESC ` or M-`")
  1900. (insert (substitute-command-keys " \\[tmm-menubar]")))
  1901. ;; Many users seem to have problems with these.
  1902. (insert (substitute-command-keys "
  1903. \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
  1904. If you have no Meta key, you may instead type ESC followed by the character.)"))
  1905. ;; Insert links to useful tasks
  1906. (insert "\nUseful tasks:\n")
  1907. (insert-button "Visit New File"
  1908. 'action (lambda (_button) (call-interactively 'find-file))
  1909. 'follow-link t)
  1910. (insert "\t\t\t")
  1911. (insert-button "Open Home Directory"
  1912. 'action (lambda (_button) (dired "~"))
  1913. 'follow-link t)
  1914. (insert "\n")
  1915. (insert-button "Customize Startup"
  1916. 'action (lambda (_button) (customize-group 'initialization))
  1917. 'follow-link t)
  1918. (insert "\t\t")
  1919. (insert-button "Open *scratch* buffer"
  1920. 'action (lambda (_button) (switch-to-buffer
  1921. (get-buffer-create "*scratch*")))
  1922. 'follow-link t)
  1923. (insert "\n")
  1924. (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
  1925. (insert (substitute-command-keys
  1926. "
  1927. GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
  1928. (insert-button "full details"
  1929. 'action (lambda (_button) (describe-no-warranty))
  1930. 'follow-link t)
  1931. (insert (substitute-command-keys ".
  1932. Emacs is Free Software--Free as in Freedom--so you can redistribute copies
  1933. of Emacs and modify it; type \\[describe-copying] to see "))
  1934. (insert-button "the conditions"
  1935. 'action (lambda (_button) (describe-copying))
  1936. 'follow-link t)
  1937. (insert (substitute-command-keys".
  1938. Type \\[describe-distribution] for information on "))
  1939. (insert-button "getting the latest version"
  1940. 'action (lambda (_button) (describe-distribution))
  1941. 'follow-link t)
  1942. (insert "."))
  1943. (defun normal-about-screen ()
  1944. (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n")
  1945. (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n")
  1946. (insert-button "Authors"
  1947. 'action
  1948. (lambda (_button)
  1949. (view-file (expand-file-name "AUTHORS" data-directory))
  1950. (goto-char (point-min)))
  1951. 'follow-link t)
  1952. (insert "\t\tMany people have contributed code included in GNU Emacs\n")
  1953. (insert-button "Contributing"
  1954. 'action
  1955. (lambda (_button) (info "(emacs)Contributing"))
  1956. 'follow-link t)
  1957. (insert "\tHow to contribute improvements to Emacs\n\n")
  1958. (insert-button "GNU and Freedom"
  1959. 'action (lambda (_button) (describe-gnu-project))
  1960. 'follow-link t)
  1961. (insert "\t\tWhy we developed GNU Emacs and the GNU system\n")
  1962. (insert-button "Absence of Warranty"
  1963. 'action (lambda (_button) (describe-no-warranty))
  1964. 'follow-link t)
  1965. (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
  1966. (insert-button "Copying Conditions"
  1967. 'action (lambda (_button) (describe-copying))
  1968. 'follow-link t)
  1969. (insert "\tConditions for redistributing and changing Emacs\n")
  1970. (insert-button "Getting New Versions"
  1971. 'action (lambda (_button) (describe-distribution))
  1972. 'follow-link t)
  1973. (insert "\tHow to get the latest version of GNU Emacs\n")
  1974. (insert-button "More Manuals / Ordering Manuals"
  1975. 'action (lambda (_button) (view-order-manuals))
  1976. 'follow-link t)
  1977. (insert "\tBuying printed manuals from the FSF\n"))
  1978. (defun startup-echo-area-message ()
  1979. (if (daemonp)
  1980. "Starting Emacs daemon."
  1981. (substitute-command-keys
  1982. "For information about GNU Emacs and the GNU system, type \
  1983. \\[about-emacs].")))
  1984. (defun display-startup-echo-area-message ()
  1985. (let ((resize-mini-windows t))
  1986. (or noninteractive ;(input-pending-p) init-file-had-error
  1987. ;; t if the init file says to inhibit the echo area startup message.
  1988. (and inhibit-startup-echo-area-message
  1989. user-init-file
  1990. (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
  1991. (equal inhibit-startup-echo-area-message
  1992. (if (equal init-file-user "")
  1993. (user-login-name)
  1994. init-file-user)))
  1995. ;; Wasn't set with custom; see if .emacs has a setq.
  1996. (condition-case nil
  1997. (with-temp-buffer
  1998. (insert-file-contents user-init-file)
  1999. (re-search-forward
  2000. (concat
  2001. "([ \t\n]*setq[ \t\n]+"
  2002. "inhibit-startup-echo-area-message[ \t\n]+"
  2003. (regexp-quote
  2004. (prin1-to-string
  2005. (if (equal init-file-user "")
  2006. (user-login-name)
  2007. init-file-user)))
  2008. "[ \t\n]*)")
  2009. nil t))
  2010. (error nil))))
  2011. (message "%s" (startup-echo-area-message)))))
  2012. (defun display-startup-screen (&optional concise)
  2013. "Display startup screen according to display.
  2014. A fancy display is used on graphic displays, normal otherwise.
  2015. If CONCISE is non-nil, display a concise version of the startup
  2016. screen."
  2017. ;; Prevent recursive calls from server-process-filter.
  2018. (if (not (get-buffer "*GNU Emacs*"))
  2019. (if (use-fancy-splash-screens-p)
  2020. (fancy-startup-screen concise)
  2021. (normal-splash-screen t concise))))
  2022. (defun display-about-screen ()
  2023. "Display the *About GNU Emacs* buffer.
  2024. A fancy display is used on graphic displays, normal otherwise."
  2025. (interactive)
  2026. (if (use-fancy-splash-screens-p)
  2027. (fancy-about-screen)
  2028. (normal-splash-screen nil)))
  2029. (defalias 'about-emacs 'display-about-screen)
  2030. (defalias 'display-splash-screen 'display-startup-screen)
  2031. (defun command-line-1 (args-left)
  2032. "A subroutine of `command-line'."
  2033. (display-startup-echo-area-message)
  2034. (when (and pure-space-overflow
  2035. (not noninteractive))
  2036. (display-warning
  2037. 'initialization
  2038. "Building Emacs overflowed pure space.\
  2039. (See the node Pure Storage in the Lisp manual for details.)"
  2040. :warning))
  2041. ;; `displayable-buffers' is a list of buffers that may be displayed,
  2042. ;; which includes files parsed from the command line arguments and
  2043. ;; `initial-buffer-choice'. All of the display logic happens at the
  2044. ;; end of this `let'. As files as processed from the command line
  2045. ;; arguments, their buffers are prepended to `displayable-buffers'.
  2046. ;; In order for options like "--eval" to work with the "--file" arg,
  2047. ;; the file buffers are set as the current buffer as they are seen
  2048. ;; on the command line (so "emacs --batch --file a --file b
  2049. ;; --eval='(message "%s" (buffer-name))'" will print "b"), but this
  2050. ;; does not affect the final displayed state of the buffers.
  2051. (let ((displayable-buffers nil))
  2052. ;; This `let' processes the command line arguments.
  2053. (let ((command-line-args-left args-left))
  2054. (when command-line-args-left
  2055. ;; We have command args; process them.
  2056. (let* ((dir command-line-default-directory)
  2057. tem
  2058. ;; This approach loses for "-batch -L DIR --eval "(require foo)",
  2059. ;; if foo is intended to be found in DIR.
  2060. ;;
  2061. ;; The directories listed in --directory/-L options will *appear*
  2062. ;; at the front of `load-path' in the order they appear on the
  2063. ;; command-line. We cannot do this by *placing* them at the front
  2064. ;; in the order they appear, so we need this variable to hold them,
  2065. ;; temporarily.
  2066. ;;
  2067. ;; To DTRT we keep track of the splice point and modify `load-path'
  2068. ;; straight away upon any --directory/-L option.
  2069. splice
  2070. just-files ;; t if this follows the magic -- option.
  2071. ;; This includes our standard options' long versions
  2072. ;; and long versions of what's on command-switch-alist.
  2073. (longopts
  2074. (append '("--funcall" "--load" "--insert" "--kill"
  2075. "--directory" "--eval" "--execute" "--no-splash"
  2076. "--find-file" "--visit" "--file" "--no-desktop")
  2077. (mapcar (lambda (elt) (concat "-" (car elt)))
  2078. command-switch-alist)))
  2079. (line 0)
  2080. (column 0)
  2081. ;; `process-file-arg' opens a file buffer for `name',
  2082. ;; sets that buffer as the current buffer without
  2083. ;; displaying it, adds the buffer to
  2084. ;; `displayable-buffers', and puts the point at
  2085. ;; `line':`column'. `line' and `column' are both reset
  2086. ;; to zero when `process-file-arg' returns.
  2087. (process-file-arg
  2088. (lambda (name)
  2089. ;; This can only happen if PWD is deleted.
  2090. (if (not (or dir (file-name-absolute-p name)))
  2091. (message "Ignoring relative file name (%s) due to \
  2092. nil default-directory" name)
  2093. (let* ((file (expand-file-name
  2094. (command-line-normalize-file-name name)
  2095. dir))
  2096. (buf (find-file-noselect file)))
  2097. (setq displayable-buffers (cons buf displayable-buffers))
  2098. ;; Set the file buffer to the current buffer so
  2099. ;; that it will be used with "--eval" and
  2100. ;; similar options.
  2101. (set-buffer buf)
  2102. ;; Put the point at `line':`column' in the file
  2103. ;; buffer, and reset `line' and `column' to 0.
  2104. (unless (zerop line)
  2105. (goto-char (point-min))
  2106. (forward-line (1- line)))
  2107. (setq line 0)
  2108. (unless (< column 1)
  2109. (move-to-column (1- column)))
  2110. (setq column 0))))))
  2111. ;; Add the long X options to longopts.
  2112. (dolist (tem command-line-x-option-alist)
  2113. (if (string-match "^--" (car tem))
  2114. (push (car tem) longopts)))
  2115. ;; Add the long NS options to longopts.
  2116. (dolist (tem command-line-ns-option-alist)
  2117. (if (string-match "^--" (car tem))
  2118. (push (list (car tem)) longopts)))
  2119. ;; Loop, processing options.
  2120. (while command-line-args-left
  2121. (let* ((argi (car command-line-args-left))
  2122. (orig-argi argi)
  2123. argval completion)
  2124. (setq command-line-args-left (cdr command-line-args-left))
  2125. ;; Do preliminary decoding of the option.
  2126. (if just-files
  2127. ;; After --, don't look for options; treat all args as files.
  2128. (setq argi "")
  2129. ;; Convert long options to ordinary options
  2130. ;; and separate out an attached option argument into argval.
  2131. (when (string-match "\\`\\(--[^=]*\\)=" argi)
  2132. (setq argval (substring argi (match-end 0))
  2133. argi (match-string 1 argi)))
  2134. (when (string-match "\\`--?[^-]" orig-argi)
  2135. (setq completion (try-completion argi longopts))
  2136. (if (eq completion t)
  2137. (setq argi (substring argi 1))
  2138. (if (stringp completion)
  2139. (let ((elt (member completion longopts)))
  2140. (or elt
  2141. (error "Option `%s' is ambiguous" argi))
  2142. (setq argi (substring (car elt) 1)))
  2143. (setq argval nil
  2144. argi orig-argi)))))
  2145. ;; Execute the option.
  2146. (cond ((setq tem (assoc argi command-switch-alist))
  2147. (if argval
  2148. (let ((command-line-args-left
  2149. (cons argval command-line-args-left)))
  2150. (funcall (cdr tem) argi))
  2151. (funcall (cdr tem) argi)))
  2152. ((equal argi "-no-splash")
  2153. (setq inhibit-startup-screen t))
  2154. ((member argi '("-f" ; what the manual claims
  2155. "-funcall"
  2156. "-e")) ; what the source used to say
  2157. (setq inhibit-startup-screen t)
  2158. (setq tem (intern (or argval (pop command-line-args-left))))
  2159. (if (commandp tem)
  2160. (command-execute tem)
  2161. (funcall tem)))
  2162. ((member argi '("-eval" "-execute"))
  2163. (setq inhibit-startup-screen t)
  2164. (let* ((str-expr (or argval (pop command-line-args-left)))
  2165. (read-data (read-from-string str-expr))
  2166. (expr (car read-data))
  2167. (end (cdr read-data)))
  2168. (unless (= end (length str-expr))
  2169. (error "Trailing garbage following expression: %s"
  2170. (substring str-expr end)))
  2171. (eval expr)))
  2172. ((member argi '("-L" "-directory"))
  2173. ;; -L :/foo adds /foo to the _end_ of load-path.
  2174. (let (append)
  2175. (if (string-match-p
  2176. (format "\\`%s" path-separator)
  2177. (setq tem (or argval (pop command-line-args-left))))
  2178. (setq tem (substring tem 1)
  2179. append t))
  2180. (setq tem (expand-file-name
  2181. (command-line-normalize-file-name tem)))
  2182. (cond (append (setq load-path
  2183. (append load-path (list tem)))
  2184. (if splice (setq splice load-path)))
  2185. (splice (setcdr splice (cons tem (cdr splice)))
  2186. (setq splice (cdr splice)))
  2187. (t (setq load-path (cons tem load-path)
  2188. splice load-path)))))
  2189. ((member argi '("-l" "-load"))
  2190. (let* ((file (command-line-normalize-file-name
  2191. (or argval (pop command-line-args-left))))
  2192. ;; Take file from default dir if it exists there;
  2193. ;; otherwise let `load' search for it.
  2194. (file-ex (expand-file-name file)))
  2195. (when (file-regular-p file-ex)
  2196. (setq file file-ex))
  2197. (load file nil t)))
  2198. ;; This is used to handle -script. It's not clear
  2199. ;; we need to document it (it is totally internal).
  2200. ((member argi '("-scriptload"))
  2201. (let* ((file (command-line-normalize-file-name
  2202. (or argval (pop command-line-args-left))))
  2203. ;; Take file from default dir.
  2204. (file-ex (expand-file-name file)))
  2205. (load file-ex nil t t)))
  2206. ((equal argi "-insert")
  2207. (setq inhibit-startup-screen t)
  2208. (setq tem (or argval (pop command-line-args-left)))
  2209. (or (stringp tem)
  2210. (error "File name omitted from `-insert' option"))
  2211. (insert-file-contents (command-line-normalize-file-name tem)))
  2212. ((equal argi "-kill")
  2213. (kill-emacs t))
  2214. ;; This is for when they use --no-desktop with -q, or
  2215. ;; don't load Desktop in their .emacs. If desktop.el
  2216. ;; _is_ loaded, it will handle this switch, and we
  2217. ;; won't see it by the time we get here.
  2218. ((equal argi "-no-desktop")
  2219. (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
  2220. ((string-match "^\\+[0-9]+\\'" argi)
  2221. (setq line (string-to-number argi)))
  2222. ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
  2223. (setq line (string-to-number (match-string 1 argi))
  2224. column (string-to-number (match-string 2 argi))))
  2225. ((setq tem (assoc orig-argi command-line-x-option-alist))
  2226. ;; Ignore X-windows options and their args if not using X.
  2227. (setq command-line-args-left
  2228. (nthcdr (nth 1 tem) command-line-args-left)))
  2229. ((setq tem (assoc orig-argi command-line-ns-option-alist))
  2230. ;; Ignore NS-windows options and their args if not using NS.
  2231. (setq command-line-args-left
  2232. (nthcdr (nth 1 tem) command-line-args-left)))
  2233. ((member argi '("-find-file" "-file" "-visit"))
  2234. (setq inhibit-startup-screen t)
  2235. ;; An explicit option to specify visiting a file.
  2236. (setq tem (or argval (pop command-line-args-left)))
  2237. (unless (stringp tem)
  2238. (error "File name omitted from `%s' option" argi))
  2239. (funcall process-file-arg tem))
  2240. ;; These command lines now have no effect.
  2241. ((string-match "\\`--?\\(no-\\)?\\(uni\\|multi\\)byte$" argi)
  2242. (display-warning 'initialization
  2243. (format "Ignoring obsolete arg %s" argi)))
  2244. ((equal argi "--")
  2245. (setq just-files t))
  2246. (t
  2247. ;; We have almost exhausted our options. See if the
  2248. ;; user has made any other command-line options available
  2249. (let ((hooks command-line-functions)
  2250. (did-hook nil))
  2251. (while (and hooks
  2252. (not (setq did-hook (funcall (car hooks)))))
  2253. (setq hooks (cdr hooks)))
  2254. (unless did-hook
  2255. ;; Presume that the argument is a file name.
  2256. (if (string-match "\\`-" argi)
  2257. (error "Unknown option `%s'" argi))
  2258. ;; FIXME: Why do we only inhibit the startup
  2259. ;; screen for -nw?
  2260. (unless initial-window-system
  2261. (setq inhibit-startup-screen t))
  2262. (funcall process-file-arg orig-argi)))))
  2263. ;; In unusual circumstances, the execution of Lisp code due
  2264. ;; to command-line options can cause the last visible frame
  2265. ;; to be deleted. In this case, kill emacs to avoid an
  2266. ;; abort later.
  2267. (unless (frame-live-p (selected-frame)) (kill-emacs nil)))))))
  2268. (when (eq initial-buffer-choice t)
  2269. ;; When `initial-buffer-choice' equals t make sure that *scratch*
  2270. ;; exists.
  2271. (get-buffer-create "*scratch*"))
  2272. ;; If *scratch* exists and is empty, insert initial-scratch-message.
  2273. ;; Do this before switching to *scratch* below to handle bug#9605.
  2274. (and initial-scratch-message
  2275. (get-buffer "*scratch*")
  2276. (with-current-buffer "*scratch*"
  2277. (when (zerop (buffer-size))
  2278. (insert (substitute-command-keys initial-scratch-message))
  2279. (set-buffer-modified-p nil))))
  2280. ;; Prepend `initial-buffer-choice' to `displayable-buffers'.
  2281. (when initial-buffer-choice
  2282. (let ((buf
  2283. (cond ((stringp initial-buffer-choice)
  2284. (find-file-noselect initial-buffer-choice))
  2285. ((functionp initial-buffer-choice)
  2286. (funcall initial-buffer-choice))
  2287. ((eq initial-buffer-choice t)
  2288. (get-buffer-create "*scratch*"))
  2289. (t
  2290. (error "initial-buffer-choice must be a string, a function, or t.")))))
  2291. (unless (buffer-live-p buf)
  2292. (error "initial-buffer-choice is not a live buffer."))
  2293. (setq displayable-buffers (cons buf displayable-buffers))))
  2294. ;; Display the first two buffers in `displayable-buffers'. If
  2295. ;; `initial-buffer-choice' is non-nil, its buffer will be the
  2296. ;; first buffer in `displayable-buffers'. The first buffer will
  2297. ;; be focused.
  2298. (let ((displayable-buffers-len (length displayable-buffers))
  2299. ;; `nondisplayed-buffers-p' is true if there exist buffers
  2300. ;; in `displayable-buffers' that were not displayed to the
  2301. ;; user.
  2302. (nondisplayed-buffers-p nil))
  2303. (when (> displayable-buffers-len 0)
  2304. (switch-to-buffer (car displayable-buffers)))
  2305. (when (> displayable-buffers-len 1)
  2306. (switch-to-buffer-other-window (car (cdr displayable-buffers)))
  2307. ;; Focus on the first buffer.
  2308. (other-window -1))
  2309. (when (> displayable-buffers-len 2)
  2310. (setq nondisplayed-buffers-p t))
  2311. (if (or inhibit-startup-screen
  2312. initial-buffer-choice
  2313. noninteractive
  2314. (daemonp)
  2315. inhibit-x-resources)
  2316. ;; Not displaying a startup screen. Display *Buffer List* if
  2317. ;; there exist buffers that were not displayed.
  2318. (when (and nondisplayed-buffers-p
  2319. (not noninteractive)
  2320. (not inhibit-startup-buffer-menu))
  2321. (list-buffers))
  2322. ;; Display a startup screen, after some preparations.
  2323. ;; If there are no switches to process, we might as well
  2324. ;; run this hook now, and there may be some need to do it
  2325. ;; before doing any output.
  2326. (run-hooks 'emacs-startup-hook 'term-setup-hook)
  2327. ;; It's important to notice the user settings before we
  2328. ;; display the startup message; otherwise, the settings
  2329. ;; won't take effect until the user gives the first
  2330. ;; keystroke, and that's distracting.
  2331. (when (fboundp 'frame-notice-user-settings)
  2332. (frame-notice-user-settings))
  2333. ;; If there are no switches to process, we might as well
  2334. ;; run this hook now, and there may be some need to do it
  2335. ;; before doing any output.
  2336. (run-hooks 'window-setup-hook)
  2337. (setq inhibit-startup-hooks t)
  2338. ;; ;; Do this now to avoid an annoying delay if the user
  2339. ;; ;; clicks the menu bar during the sit-for.
  2340. ;; (when (display-popup-menus-p)
  2341. ;; (precompute-menubar-bindings))
  2342. ;; (with-no-warnings
  2343. ;; (setq menubar-bindings-done t))
  2344. (display-startup-screen (> displayable-buffers-len 0))))))
  2345. (defun command-line-normalize-file-name (file)
  2346. "Collapse multiple slashes to one, to handle non-Emacs file names."
  2347. (save-match-data
  2348. ;; Use arg 1 so that we don't collapse // at the start of the file name.
  2349. ;; That is significant on some systems.
  2350. ;; However, /// at the beginning is supposed to mean just /, not //.
  2351. (if (string-match
  2352. (if (memq system-type '(ms-dos windows-nt))
  2353. "^\\([\\/][\\/][\\/]\\)+"
  2354. "^///+")
  2355. file)
  2356. (setq file (replace-match "/" t t file)))
  2357. (if (memq system-type '(ms-dos windows-nt))
  2358. (while (string-match "\\([\\/][\\/]\\)+" file 1)
  2359. (setq file (replace-match "/" t t file)))
  2360. (while (string-match "//+" file 1)
  2361. (setq file (replace-match "/" t t file))))
  2362. file))
  2363. ;;; startup.el ends here