From ff2598d6b7bb62846d8bec71302884b776f46569 Mon Sep 17 00:00:00 2001 From: bg66 Date: Sat, 27 Apr 2002 08:16:09 +0000 Subject: [PATCH 1/1] initial import into CVS --- AUTHORS | 1 + COPYING | 340 ++++++++++++++++++++ ChangeLog | 534 ++++++++++++++++++++++++++++++++ README | 130 ++++++++ TODO | 14 + lisp/INITZ-CFG | 52 ++++ lisp/INITZ-ELS | 15 + lisp/INITZ-MK | 69 +++++ lisp/Makefile | 32 ++ lisp/initz-error.el | 288 +++++++++++++++++ lisp/initz-globals.el | 67 ++++ lisp/initz-list.el | 479 ++++++++++++++++++++++++++++ lisp/initz-util.el | 125 ++++++++ lisp/initz-vars.el | 113 +++++++ lisp/initz.el | 350 +++++++++++++++++++++ sample/dot.emacs | 15 + sample/startup/flavor/init-emacs20.el | 5 + sample/startup/flavor/init-xemacs21.el | 9 + sample/startup/host/init-host1-skk.el | 6 + sample/startup/host/init-host2-skk.el | 6 + sample/startup/init-skk.el | 10 + sample/startup/init-test.el | 5 + 22 files changed, 2665 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100644 lisp/INITZ-CFG create mode 100644 lisp/INITZ-ELS create mode 100644 lisp/INITZ-MK create mode 100644 lisp/Makefile create mode 100644 lisp/initz-error.el create mode 100644 lisp/initz-globals.el create mode 100644 lisp/initz-list.el create mode 100644 lisp/initz-util.el create mode 100644 lisp/initz-vars.el create mode 100644 lisp/initz.el create mode 100644 sample/README create mode 100644 sample/dot.emacs create mode 100644 sample/startup/flavor/init-emacs20.el create mode 100644 sample/startup/flavor/init-xemacs21.el create mode 100644 sample/startup/host/init-host1-skk.el create mode 100644 sample/startup/host/init-host2-skk.el create mode 100644 sample/startup/init-skk.el create mode 100644 sample/startup/init-test.el diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..257c585 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Initz is mainly written by OHASHI Akira . diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..84d08cd --- /dev/null +++ b/ChangeLog @@ -0,0 +1,534 @@ +2002-04-27 OHASHI Akira + + * lisp/initz-util.el (initz-features): Make dummy filename having + extension from `feature'. + + * lisp/initz-config.el: Abolish. + * lisp/initz-make.el: Ditto. + * lisp/initz-modules.el: Ditto. + * lisp/INITZ-CFG: New file. + * lisp/INITZ-ELS: Ditto. + * lisp/INITZ-MK: Ditto. + * lisp/Makefile: Follow change above. + +2002-04-26 OHASHI Akira + + * lisp/initz-util.el (toplevel): Require `cl'. + + * lisp/initz-vars.el (initz-list-unloaded-module-face): New face. + * lisp/initz-list.el (initz-list-node-expand): Use it. + + * lisp/initz-vars.el (initz-list-loaded-mark): New custom variable. + * lisp/initz-list.el (initz-list-node-expand): If module is loaded, + print it at the rear. + + * lisp/initz.el (initz-trim-separator): New function. + (initz-init-alist): Use it. + * lisp/initz-list.el (initz-list-input-module): Ditto. + (initz-list-node-insert): Ditto. + (initz-list-new-file): Ditto. + +2002-04-25 OHASHI Akira + + * Version number is increased to 0.0.10. + + * lisp/initz-vars.el (initz-list-default-node-status): Rename from + `initz-list-node-default-status'. + * lisp/initz-list.el (initz-list): Follow change above. + + * lisp/initz-list.el (initz-list-new-file): Trim + `initz-separator-string'. + (initz-list-new-file): Fix illegal check. + + * lisp/initz.el (initz-get-files): Fix for bugs. + + * lisp/initz.el (initz-features): Abolish; Move to `initz-util.el'. + (initz-get-base-name): Ditto. + (initz-get-module-name): Ditto. + + * lisp/initz.el (initz-compile-file): Try byte-compile first. + + * lisp/initz.el (initz-init-alist): Change value. + (initz-get-init-value): Follow change above. + +2002-04-24 OHASHI Akira + + * lisp/initz-list.el (initz-list-node-insert): When `prefix' equals + `initz-null-string', don't print `prefix'. + (initz-list-get-dir): Follow change above. + (initz-list-insert-file): Ditto. + (initz-list-node-collapse): Ditto. + (initz-list-node-expand): Ditto. + + * lisp/initz.el (initz-init-alist): Add `argument' and improve order. + +2002-04-23 OHASHI Akira + + * lisp/initz.el (initz-add-to-load-path): Abolish; Move to + `initz-util.el'. + + * lisp/initz-util.el: New file. + * lisp/initz-modules.el (initz-modules-to-compile): Add it. + + * lisp/initz-globals.el (initz-load-list-internal): New variable. + (initz-ignore-list-internal): Ditto. + * lisp/initz.el (initz-load): Use them. + (initz-load-file): Ditto. + + * lisp/initz-list.el (initz-list-quit): Add remove hook. + +2002-04-22 OHASHI Akira + + * lisp/initz-globals.el (initz-compile-error-files): Rename from + `initz-error-compile-files'. + (initz-load-error-files): Rename from `initz-error-load-files'. + * lisp/initz.el (initz-compile-file): Follow change above. + (initz-compile): Ditto. + (initz-load-file): Ditto. + (initz-load): Ditto. + * lisp/initz-list.el (initz-list-byte-compile-file): Ditto. + (initz-list-delete-file): Ditto. + (initz-list-load-file): Ditto. + * lisp/initz-error.el (initz-error-node-expand): Ditto. + (initz-error-byte-compile-file): Ditto. + (initz-error-delete-file): Ditto. + (initz-error-load-file): Ditto. + (initz-error): Ditto. + +2002-04-21 OHASHI Akira + + * lisp/initz.el (initz-message-no-log): New macro. + * lisp/initz-list.el (initz-list-print-file): Use it instead of + `message'. + +2002-02-08 OHASHI Akira + + * lisp/initz-list.el (sort-build-lists): New advice. + +2002-02-01 OHASHI Akira + + * Version number is increased to 0.0.9. + + * lisp/initz.el (initz-startup-directory): New function. + (initz-flavor-directory): Ditto. + (initz-compile-files): Use them. + * lisp/initz-list.el (initz-list-new-file): Ditto. + + * lisp/initz.el (initz-get-kind): Rename from `initz-get-kind-symbol'. + (initz-get-dir): Rename from `initz-get-dir-symbol'. + (initz-get-correspondence-file): Follow change above. + +2002-01-29 OHASHI Akira + + * lisp/initz-list.el (initz-list-node-enter): Simplify. + * lisp/initz-error.el (initz-error-node-enter): Ditto. + + * lisp/initz-list.el (initz-list-input-dir-message-format): + Change value. + (initz-list-input-module-message-format): Ditto. + (initz-list-input-dir): Follow chage above. + + * lisp/initz.el (initz-features): Use `delq' instead of `delete'. + (initz-load-file): Use `memq' instead of `member'. + * lisp/initz-list.el (initz-list-new-file): Ditto. + +2002-01-27 OHASHI Akira + + * lisp/initz.el (initz-get-init-value): Use `cond' instead of `if'. + (initz-get-module-name): Ditto. + (initz-message): Use `when' instead of `if'. + * lisp/initz-list.el (initz-list-get-dir): Ditto. + (initz-list-next-line): Ditto. + +2002-01-25 OHASHI Akira + + * lisp/initz-list.el (initz-list-print-file): New function. + (initz-list-mode): Use it. + * lisp/initz-error.el (initz-error-mode): Use it. + +2002-01-24 OHASHI Akira + + * lisp/initz-list.el (initz-list-new-file-provide-message-format): + Change value. + (initz-list-new-file-comment-message-format): Ditto. + (initz-list-new-file): Follow change above. + + * lisp/initz-vars.el (initz-verbose): Fix for XEmacs21; Use `const' + instead of `other'. + (initz-list-input-module-completing): New custom variable. + + * lisp/initz-list.el (initz-list-input-module): Use it. + (initz-list-node-insert): Print `prefix'. + (initz-list-get-dir): Follow change above. + (initz-list-insert-file): Ditto. + (initz-list-node-collapse): Ditto. + (initz-list-node-expand): Ditto. + +2002-01-23 OHASHI Akira + + * Version number is increased to 0.0.8. + + * lisp/initz-var.el (initz-face): New group. + (initz-list-node-face): New face. + (initz-list-module-face): Ditto. + * lisp/initz-list.el (initz-list-insert-file): Use them. + (initz-list-node-insert): Ditto. + (initz-list-node-expand): Ditto. + * lisp/initz-error.el (initz-error-node-insert): Ditto. + (initz-error-node-expand): Ditto. + + * lisp/initz-list.el (initz-list-insert-file): Add text property + `help-echo'. + (initz-list-node-expand): Ditto. + * lisp/initz-error.el (initz-error-node-expand): Ditto. + + * lisp/initz-make.el (install-just-print-p): Salvage. + + * lisp/initz-list.el (initz-list-insert-file): Add text property + `start-open' and `rear-nonsticky'. + (initz-list-node-insert): Ditto. + (initz-list-node-expand): Ditto. + * lisp/initz-error.el (initz-error-node-insert): Ditto. + (initz-error-node-expand): Ditto. + + * lisp/initz-list.el (initz-list-byte-compile-file): Fix for install. + * lisp/initz-error.el (initz-error-byte-compile-file): Ditto. + + * lisp/initz-list.el (initz-list-insert-file): Sort lines. + (initz-list-node-expand): Ditto. + * lisp/initz-error.el (initz-error-node-expand): Ditto. + + * lisp/initz-list.el (initz-list-delete-file): Fix point; + Run previous-line and next-line. + * lisp/initz-error.el (initz-error-delete-file): Ditto. + +2002-01-22 OHASHI Akira + + * lisp/initz-list.el (initz-list-node-map): New keymap. + (initz-list-node-insert): New function. + (initz-list-node-collapse): Ditto. + (initz-list-node-expand): Ditto. + (initz-list-node-enter): Ditto. + (initz-list-node-click): Ditto. + (initz-list): Use it. + (initz-list-get-dir): Follow change above. + (initz-list-insert-file): Ditto. + (initz-list-next-line): New function. + (initz-list-previous-line): Ditto. + (initz-list-mode-map): Use them. + * lisp/initz-error.el (initz-error-mode-map): Ditto. + + * lisp/initz-vars.el(initz-list-node-default-status): + New custom variable. + * lisp/initz-list.el(initz-list): Use it. + (initz-list-get-dir): Run `end-of-line'. + + * lisp/initz-error.el (initz-error-node-map): New keymap. + (initz-error-node-insert): New funciton. + (initz-error-node-collapse): Ditto. + (initz-error-node-expand): Ditto. + (initz-error-node-enter): Ditto. + (initz-error-node-click): Ditto. + (initz-error): Use it. + (initz-error-compile-message-header): Change value. + (initz-error-load-message-header): Ditto. + +2002-01-21 OHASHI Akira + + * lisp/initz.el (initz-compile-file): Fix for error handling. + (initz-get-dir-symbol): Remove the slash only when it exists. + +2002-01-20 OHASHI Akira + + * lisp/initz-list.el (initz-list-input-dir-message-format): + Change value. + (initz-list-input-module-message-format): Ditto. + +2002-01-18 OHASHI Akira + + * lisp/initz.el (toplevel): Autoload `initz-list-new-file'. + + * lisp/initz-list.el (initz-list-find-file-mouse): Remove + `beginning-of-line' and check the end of line. + (initz-list-insert-file): Fix for the end of line and use + `add-text-properties' instead of `set-text-properties'. + (initz-list): Ditto. + * lisp/initz-error.el (initz-error): Ditto. + +2002-01-17 OHASHI Akira + + * lisp/initz.el (initz-features): New function. + (initz-get-files): Simplify. + +2002-01-16 OHASHI Akira + + * Version number is increased to 0.0.7. + + * lisp/initz-error.el (initz-error-delete-file): Use module name + instead of file name for the prompt of confirm. + * lisp/initz-list.el (initz-list-delete-file): Ditto. + + * lisp/initz.el (initz-make-directory): Create parent + directories if they don't exist. + + * lisp/initz-list.el (initz-list-new-file): Fix for module name. + (initz-list-new-file-provided-message): New constant. + (initz-list-new-file): Use it. + + * lisp/initz-error.el (initz-error-click-message-format): + Change value. + (initz-error-enter-message-format): Ditto. + * lisp/initz-list.el (initz-list-click-message-format): + Ditto. + (initz-list-enter-message-format): Ditto. + +2002-01-15 OHASHI Akira + + * Version number is increased to 0.0.6. + + * lisp/initz-globals.el (initz-load-module-ask-message-format): + Change value. + (initz-load-module-message-format): Ditto. + (initz-unload-module-message-format): Ditto. + + * lisp/initz.el: Check docstring. + (initz-init-alist): Change value. + (initz-get-module-name): Rename argument from `file' to `init-file'. + (initz-message): New function. + (initz-load-file): Use it. + (initz-done): Ditto. + + * lisp/initz-list.el (initz-list-input-dir-message-format): + New constant. + (initz-list-input-module-message-format): Ditto. + (initz-list-new-file-exists-message): Ditto. + (initz-list-new-file-illegal-message): Ditto. + (initz-list-new-file-comment-message-format): Ditto. + (initz-list-new-file-provide-message-format): Ditto. + (initz-list-get-dir): New function. + (initz-list-input-dir): Ditto. + (initz-list-input-module): Ditto. + (initz-list-new-file): Use them. + + * lisp/initz.el (initz-get-base-name): New function. + (initz-get-module-name): Use it. + (initz-load-file): Ditto. + * lisp/initz-list.el (initz-list-new-file): Ditto. + + * lisp/initz-error.el (initz-error-mode-map): Change value. + (initz-error-mode): Follow change above. + + * lisp/initz-list.el (initz-list-mode-map): Change value. + (initz-list-mode): Follow change above. + + * lisp/initz-error.el (toplevel): Require `initz-list'. + (initz-error-delete-whole-line): Abolish. + (initz-error-find-file): Ditto. + (initz-error-find-file-mouse): Ditto. + (initz-error-quit): Ditto. + (toplevel): Set aliases from abolished `initz-error-*' to + 'initz-list-*'. + + * lisp/initz-modules.el (initz-modules-to-compile): Change value. + + * lisp/initz.el (toplevel): Fix for autoload. + +2002-01-14 OHASHI Akira + + * Version number is increased to 0.0.5. + + * lisp/initz-list.el: New file. + * lisp/initz-modules.el (initz-modules-to-compile): Add it. + +2002-01-13 OHASHI Akira + + * lisp/init.el (initz-directory): New function. + (initz-startup-directory): Abolish. + (initz-flavor-directory): Ditto. + (initz-delete-file): Follow change above. + (initz-delete-files): Ditto. + (initz-compile-files): Ditto. + (initz-load-files): Ditto. + (initz-load): Ditto. + * lisp/initz-error.el (initz-error): Ditto. + + * lisp/initz.el (initz-init-alist): Change value. + (initz-get-init-value): New function. + (initz-get-files): Ditto. + (initz-get-kind-symbol): Ditto. + (initz-get-dir-symbol): Ditto. + (initz-get-correspoidence-file): Ditto. + (initz-make-directory): Ditto. + (initz-make-directories): Ditto. + (initz-get-module-name): Follow change above. + (initz-delete-file): Ditto. + (initz-delete-files): Ditto. + (initz-delete): Ditto. + (initz-compile-file): Ditto. + (initz-compile-files): Ditto. + (initz-compile): Ditto. + (initz-load-file): Ditto. + (initz-load-files): Ditto. + (initz-load): Ditto. + + * lisp/initz-globals.el (initz-module-regexp): Fix. + (initz-get-module-name): Follow change above. + + * lisp/init.el (initz-done-message-format): Change value. + * lisp/initz-globals.el (initz-load-module-ask-message-format): + Ditto. + (initz-load-module-message-format): Ditto. + (initz-unload-module-message-format): Ditto. + + * lisp/initz-globals.el (initz-error-load-modules): Rename to + `initz-error-load-files'. + * lisp/initz.el (initz-load-file): Follow change above. + (initz-load): Ditto. + * lisp/initz-error.el (initz-error-byte-compile-file): Ditto. + (initz-error-delete-file): Ditto. + (initz-error-load-file): Ditto. + (initz-error): Ditto. + (initz-error-byte-compile-file-ask-message-format): Abolish. + (initz-error-byte-compile-file): Follow change above. + (initz-error-load-file): Run `initz-error-byte-compile-file'. + +2002-01-11 OHASHI Akira + + * Version number is increased to 0.0.4. + + * lisp/initz-error.el (initz-error-mode-name): New constant. + (initz-error-byte-compile-file-ask-message-format): Ditto. + (initz-error-delete-file-ask-message-format): Ditto. + (initz-error-click-message-format): Ditto. + (initz-error-enter-message-format): Ditto. + (initz-error-compile-message-header): Ditto. + (initz-error-load-message-header): Ditto. + (initz-error-byte-compile): Use them. + (initz-error-delete-file): Ditto. + (initz-error-mode): Ditto. + (initz-error): Ditto. + (initz-error-delete-whole-line): New function. + (initz-error-byte-compile-file): Use it. + (initz-error-delete-file): Ditto. + (initz-error-load-file): Ditto. + + * lisp/initz.el (initz-add-to-load-path): Rewrite; Don't use + `paths-find-recursive-load-path' and + `normal-top-level-add-subdirs-to-load-path'. + (initz-compile-files): Simplify; Don't make directory. + +2002-01-10 OHASHI Akira + + * lisp/initz.el (initz-compile-file): Simplify. + + * lisp/initz-globals.el (initz-ask-message-format): Rename to + `initz-load-module-ask-message-format'. + * lisp/initz.el (initz-load-file): Follow change above. + * lisp/initz-error.el (initz-error-load-file): Ditto. + +2002-01-09 OHASHI Akira + + * lisp/initz-error.el (initz-error-show): Rename to `initz-error'. + * lisp/initz.el (toplevel): Follow change above. + (initz-compile): Ditto. + (initz-load): Ditto. + + * lisp/initz-error.el (toplevel): Require `emu'. + (initz-error-mode-map): Fix key map of mouse. + (initz-error): Run `other-window'. + (initz-error-byte-compile-file): Run `save-window-excursion' + with `byte-compile-file'. + (initz-error-load-file): Fix feature and use `base-name'. + +2002-01-08 OHASHI Akira + + * lisp/initz-make.el (install-just-print-p): Abolish. + + * lisp/initz-error.el (initz-error-byte-compile-file): Abolish + the variable which is not referred to. + * lisp/initz.el (initz-compile-file): Ditto. + (initz-load-file): Ditto. + + * lisp/initz.el (initz-load-file): Add argument `name' and + change `initz-error-load-modules'. + (initz-load-files): Follow change above. + * lisp/initz-error.el (initz-error-show): Ditto. + (initz-error-byte-compile-file): Ditto. + (initz-error-delete-file): Ditto. + (initz-error-load-file): New function. + (initz-error-mode-map): Use it. + +2002-01-05 OHASHI Akira + + * Version number is increased to 0.0.3. + + * lisp/initz-globals.el: New file. + * lisp/initz-modules.el (initz-modules-to-compile): Add it. + +2002-01-04 OHASHI Akira + + * lisp/initz.el (initz-compile-file): Use condition-case. + (initz-delete): New function. + (initz-delete-files): Ditto. + (initz-delete-file): Ditto. + (initz-startup): Do nothing when `noninteractive' is non-nil. + +2001-12-28 OHASHI Akira + + * lisp/initz-vars.el (initz-verbose): New custom variable. + * lisp/initz.el (initz-compile): Use it. + (initz-load-file): Ditto. + (initz-load): Ditto. + (initz-done): Ditto. + +2001-12-27 OHASHI Akira + + * lisp/initz-error.el: New file. + * lisp/initz-modules.el (initz-modules-to-compile): Add it. + + * lisp/initz.el (initz-compile-file): When error occurred, + add file name to `initz-error-compile-files'. + (initz-load-file): When error occurred, add module name to + `initz-error-load-modules'. + (initz-compile): Use them. + (initz-load): Ditto. + +2001-12-10 OHASHI Akira + + * lisp/initz.el (initz-init-alist): Use `system-type' instead of + `system-configuration'. + +2001-11-08 OHASHI Akira + + * lisp/initz.el (initz-load-file): Use condition-case. + +2001-11-07 OHASHI Akira + + * Version number is increased to 0.0.2. + + * lisp/Makefile, lisp/initz-config.el, lisp/initz-make.el, + lisp/initz-modules.el, lisp/initz-vars.el: New file. + +2001-11-06 OHASHI Akira + + * lisp/initz.el (initz-load-list): New custom variable. + (initz-interactively): Ditto. + (initz-ask-message-format): New const variable. + (initz-load-file): Use them. + +2001-09-10 OHASHI Akira + + * lisp/initz.el (initz-load-file): Force `unload-feature'. + +2001-08-20 OHASHI Akira + + * AUTHORS, COPYING, NEWS, README, TODO, sample/README, + sample/dot.emacs, sample/startup/init-skk.el, + sample/startup/init-test.el, sample/startup/flavor/init-emacs20.el, + sample/startup/flavor/init-xemacs21.el, + sample/startup/host/init-host1-skk.el, + sample/startup/host/init-host2-skk.el: New file. + +2001-08-06 OHASHI Akira + + * ChangeLog, lisp/initz.el: New file. diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..0e7460e --- /dev/null +++ b/README @@ -0,0 +1,130 @@ +This is Initz version 0.0.11 +============================ + +What's the Initz? +----------------- + + Initz handles the switching of various startup initialization files + of emacsen provided for various environment. According to the + environment (maybe emacs version, OS type or OS versions) Initz + reads appropriate init files provided by the user in several + directories, one for one environment. + +Features +-------- + + * Init files for each emacs environment are separately stored in one + directory for each. You also can provide a common directory whose + init files are read in every environment. + + * When there are init files which are updated, they are automatically + compiled. + + * You can load init files interactively. + + * A major mode `initz-list' is included which supports browsing and + editing init files. + + * When an error occurred during compiling or loading init files, + you can browse and/or edit the files immediately. + + * By using the functions in `init-util.el', you can customize the + handlings of init files dynamically. + +Working Environments +-------------------- + + The latest version of Initz are verified to work properly under + following emacsen. + + XEmacs 21.5 (beta5) + Emacs 20.7.2 + Emacs 21.1.1 + Meadow 1.15pre1 + +Requirements +------------ + + You need following package: + + * APEL (9.0 or later) - ftp://ftp.m17n.org/pub/mule/apel/ + +Directory tree +-------------- + + This package contains following directories: + + lisp/ - elisp files. + + sample/ - sample init files. + +Installation +------------ + + (Install APEL, then) + % cd lisp + % make + % su + # make install + + Add following lines in your .emacs. + + (require 'initz) + (add-hook 'after-init-hook 'initz-startup) + +How to use +---------- + + Provide init files for each environment in appropriate directories + according to next section. Sample init files are provided in the + directory `sample'. + Supposing you need, you may be able to use the functions in + `initz-util.el' conveniently. + +Working directory tree +---------------------- + + ~/.initz -+- startup --+- miscellaneous init files + | +- argument - argument dependant init files + | +- flavor - flavor dependant init files + | +- host - host dependant init files + | +- system - system dependant init files + | + +- (flavor) -+- compiled miscellaneous init files + +- argument - compiled argument dependant init files + +- flavor - compiled flavor dependant init files + +- host - compiled host dependant init files + +- system - compiled system dependant init files + + Compiled init files are created automatically. + +Copying +------- + + Initz is copyrighted free software by OHASHI Akira . + You can redistribute it and/or modify it under either the terms of + the GPL (see the file `COPYING'). + +Information +----------- + + For more information, see the Initz web page at + + http://www.koka-in.org/~bg66/index.cgi?cmd=view;name=Initz + +Bug reports +----------- + + If you have bug reports and/or suggestions for improvement, please send + them to bg66@koka-in.org. + +References +---------- + + * http://deisui.bug.org/cgi-bin/viewcvs.cgi/dot-xemacs/README?rev=HEAD + + * http://triaez.kaisei.org/~kaoru/emacsen/startup/INSTALL.ja + + * http://www.unixuser.org/~ysjj/emacs/ + + * http://www.sodan.org/~knagano/emacs/dotemacs.html diff --git a/TODO b/TODO new file mode 100644 index 0000000..021004c --- /dev/null +++ b/TODO @@ -0,0 +1,14 @@ +TODO +==== + + * Merge `initz-list.el' and `initz-error.el'? + + * Fix the `FIXME'. + + * Reconsider the naming rule of init files and modules. + + * Check documents and docstrings. + + * Refactoring. + + * Provide sample files. diff --git a/lisp/INITZ-CFG b/lisp/INITZ-CFG new file mode 100644 index 0000000..e646eee --- /dev/null +++ b/lisp/INITZ-CFG @@ -0,0 +1,52 @@ +;;; -*-Emacs-Lisp-*- + +;; INITZ-CFG: installation setting about Initz. + +;;; Code: + +(add-to-list 'load-path (expand-file-name ".")) + +(condition-case nil + (require 'install) + (error (error "Please install APEL."))) + + +;;; @ Please specify prefix of install directory. +;;; + +;; Please specify install path prefix. +;; If it is omitted, shared directory (maybe /usr/local is used). +(defvar PREFIX install-prefix) +;;(setq PREFIX "~/") + +;; Please specify Initz prefix [optional] +(setq INITZ_PREFIX "initz") + + + + +;;; @ optional settings +;;; + +;; It is generated by automatically. Please set variable `PREFIX'. +;; If you don't like default directory tree, please set it. +(defvar LISPDIR (install-detect-elisp-directory PREFIX)) +;; (setq install-default-elisp-directory "~/lib/emacs/lisp") + +(setq INITZ_DIR (expand-file-name INITZ_PREFIX LISPDIR)) + +(defvar PACKAGEDIR + (if (boundp 'early-packages) + (let ((dirs (append (if early-package-load-path + early-packages) + (if late-package-load-path + late-packages) + (if last-package-load-path + last-packages))) + dir) + (while (not (file-exists-p + (setq dir (car dirs)))) + (setq dirs (cdr dirs))) + dir))) + +;;; INITZ-CFG ends here diff --git a/lisp/INITZ-ELS b/lisp/INITZ-ELS new file mode 100644 index 0000000..d39336d --- /dev/null +++ b/lisp/INITZ-ELS @@ -0,0 +1,15 @@ +;;; -*-Emacs-Lisp-*- + +;; INITZ-ELS: list of Initz modules to install + +;;; Code: + +(setq initz-modules-to-compile + '(initz-vars initz-globals initz-util initz initz-list initz-error)) + +(setq initz-modules-not-to-compile nil) + +(setq initz-modules (append initz-modules-to-compile + initz-modules-not-to-compile)) + +;;; INITZ-ELS ends here diff --git a/lisp/INITZ-MK b/lisp/INITZ-MK new file mode 100644 index 0000000..387d1d9 --- /dev/null +++ b/lisp/INITZ-MK @@ -0,0 +1,69 @@ +;;; -*-Emacs-Lisp-*- + +;; INITZ-MK: installer for Initz. + +;;; Code: + +(defun config-initz () + (let (prefix lisp-dir) + (and (setq prefix (car command-line-args-left)) + (or (string-equal "NONE" prefix) + (defvar PREFIX prefix))) + (setq command-line-args-left (cdr command-line-args-left)) + (and (setq lisp-dir (car command-line-args-left)) + (or (string-equal "NONE" lisp-dir) + (defvar LISPDIR lisp-dir))) + (setq command-line-args-left (cdr command-line-args-left)) + (load-file "INITZ-CFG") + (load-file "INITZ-ELS") + + (princ (format "PREFIX=%s +LISPDIR=%s\n" PREFIX LISPDIR)))) + +(defun compile-initz () + (config-initz) + (compile-elisp-modules initz-modules ".")) + +(defun install-initz () + (config-initz) + (install-elisp-modules initz-modules "./" INITZ_DIR)) + +(defun config-initz-package () + (let (package-dir) + (and (setq package-dir (car command-line-args-left)) + (or (string= "NONE" package-dir) + (defvar PACKAGEDIR package-dir))) + (setq command-line-args-left (cdr command-line-args-left)) + (load-file "INITZ-CFG") + (load-file "INITZ-ELS") + + (princ (format "PACKAGEDIR=%s\n" PACKAGEDIR)))) + +(defun compile-initz-package () + (config-initz-package) + + (setq autoload-package-name "initz") + (add-to-list 'command-line-args-left ".") + (batch-update-directory) + + (add-to-list 'command-line-args-left ".") + (Custom-make-dependencies) + + (compile-elisp-modules (append initz-modules-to-compile + '(auto-autoloads custom-load)) + ".")) + +(defun install-initz-package () + (config-initz-package) + (install-elisp-modules (append initz-modules + '(auto-autoloads custom-load)) + "./" + (expand-file-name INITZ_PREFIX + (expand-file-name "lisp" + PACKAGEDIR))) + (if (file-exists-p "./auto-autoloads.el") + (delete-file "./auto-autoloads.el")) + (if (file-exists-p "./custom-load.el") + (delete-file "./custom-load.el"))) + +;;; INITZ-MK ends here diff --git a/lisp/Makefile b/lisp/Makefile new file mode 100644 index 0000000..c26c2cb --- /dev/null +++ b/lisp/Makefile @@ -0,0 +1,32 @@ +# +# Makefile for Initz. +# + +PACKAGE = initz + +RM = /bin/rm -f + +EMACS = emacs +XEMACS = xemacs +FLAGS = -batch -q -no-site-file -l INITZ-MK + +PREFIX = NONE +LISPDIR = NONE +PACKAGEDIR = NONE +VERSION_SPECIFIC_LISPDIR = NONE + +GOMI = *.elc *~ + +elc: + $(EMACS) $(FLAGS) -f compile-initz $(PREFIX) $(LISPDIR) + +install: elc + $(EMACS) $(FLAGS) -f install-initz $(PREFIX) $(LISPDIR) + +package: + $(XEMACS) $(FLAGS) -f compile-initz-package $(PACKAGEDIR) + +install-package: package + $(XEMACS) $(FLAGS) -f install-initz-package $(PACKAGEDIR) +clean: + -$(RM) $(GOMI) diff --git a/lisp/initz-error.el b/lisp/initz-error.el new file mode 100644 index 0000000..ca73761 --- /dev/null +++ b/lisp/initz-error.el @@ -0,0 +1,288 @@ +;;; initz-error.el --- Error list mode. + +;; Copyright (C) 2001-2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(require 'emu) +(require 'initz-globals) +(require 'initz) +(require 'initz-list) + +(defvar initz-error-mode-map nil + "Local map for initz error buffers.") +(unless initz-error-mode-map + (let ((map (make-sparse-keymap))) + (define-key map mouse-button-2 'initz-error-find-file-mouse) + (define-key map "n" 'initz-error-next-line) + (define-key map "p" 'initz-error-previous-line) + (define-key map "h" 'backward-char) + (define-key map "j" 'initz-error-next-line) + (define-key map "k" 'initz-error-previous-line) + (define-key map "l" 'forward-char) + (define-key map " " 'initz-error-find-file) + (define-key map "\C-m" 'initz-error-find-file) + (define-key map "B" 'initz-error-byte-compile-file) + (define-key map "D" 'initz-error-delete-file) + (define-key map "L" 'initz-error-load-file) + (define-key map "S" 'initz-startup) + (define-key map "q" 'initz-error-quit) + (setq initz-error-mode-map map))) + +(defvar initz-error-node-map nil) +(unless initz-error-node-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map initz-error-mode-map) + (define-key map mouse-button-2 'initz-error-node-click) + (define-key map " " 'initz-error-node-enter) + (define-key map "\C-m" 'initz-error-node-enter) + (setq initz-error-node-map map))) + +(defvar initz-error-mode-hook nil + "Normal hook run when entering initz-error-mode.") + +(defconst initz-error-mode-name "Initz Error") + +(defconst initz-error-buffer-name "*Initz Error*") + +(defconst initz-error-delete-file-ask-message-format + "Delete %s? ") + +(defconst initz-error-click-message-format + "Click %s on the module name to select it.\n") + +(defconst initz-error-enter-message-format + "In this buffer, type %s to select the module name under point.\n") + +(defconst initz-error-compile-message-header + "Compile error:") + +(defconst initz-error-load-message-header + "Load error:") + +;; Initz error mode is suitable only for specially formatted data. +(put 'initz-error-mode 'mode-class 'special) + +(defalias 'initz-error-delete-whole-line 'initz-list-delete-whole-line) +(defalias 'initz-error-next-line 'initz-list-next-line) +(defalias 'initz-error-previous-line 'initz-list-previous-line) +(defalias 'initz-error-print-file 'initz-list-print-file) +(defalias 'initz-error-find-file 'initz-list-find-file) +(defalias 'initz-error-find-file-mouse 'initz-list-find-file-mouse) +(defalias 'initz-error-quit 'initz-list-quit) + +(defun initz-error-node-insert (node status) + (let ((start (point))) + (insert "[" (if (eq status 'expand) "-" "+") "] " + (eval (intern (concat "initz-error-" + node "-message-header"))) "\n") + (add-text-properties start (+ start 3) + `(face initz-list-node-face + mouse-face highlight + local-map ,initz-error-node-map + keymap ,initz-error-node-map + start-open t rear-nonsticky t + :node ,node + :status ,status)))) + +(defun initz-error-node-collapse (node) + (save-excursion + (setq buffer-read-only nil) + (goto-char (point-min)) + (if (re-search-forward + (concat "^\\[-\\] " + (eval (intern (concat "initz-error-" + node "-message-header"))) + "$") nil t) + (let ((start (progn (beginning-of-line) (point))) + end) + (forward-line 1) + (if (re-search-forward "^\\[[-+]\\] .+:$" nil t) + (progn + (beginning-of-line) + (setq end (point))) + (setq end (point-max))) + (delete-region start end)) + (goto-char (point-max))) + (initz-error-node-insert node 'collapse) + (set-buffer-modified-p nil) + (setq buffer-read-only t))) + +(defun initz-error-node-expand (node) + (save-excursion + (setq buffer-read-only nil) + (goto-char (point-min)) + (if (re-search-forward + (concat "^\\[\\+\\] " + (eval (intern (concat "initz-error-" + node "-message-header"))) + "$") nil t) + (delete-region (progn (beginning-of-line) (point)) + (progn (forward-line 1) (point))) + (goto-char (point-max))) + (initz-error-node-insert node 'expand) + (let ((sort-start (point))) + (mapc + (function (lambda (file) + (let (start) + (insert-char ?\ 4) + (setq start (point)) + (insert (initz-get-module-name file) "\n") + (add-text-properties + start (1- (point)) + `(face initz-list-module-face + mouse-face highlight + start-open t rear-nonsticky t + help-echo ,file)) + (put-text-property start (point) :file file)))) + (eval (intern (concat "initz-" node "-error-files")))) + (sort-lines nil sort-start (point))) + (set-buffer-modified-p nil) + (setq buffer-read-only t))) + +(defun initz-error-node-enter () + (interactive) + (let ((node (get-text-property (point) :node)) + (status (get-text-property (point) :status))) + (when (and node status) + (if (eq status 'expand) + (initz-error-node-collapse node) + (initz-error-node-expand node)) + (forward-char 1)))) + +(defun initz-error-node-click (e) + (interactive "e") + (mouse-set-point e) + (initz-error-node-enter)) + +(defun initz-error-byte-compile-file () + "Byte-compile the file under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (when file + (condition-case nil + (when (save-window-excursion + (byte-compile-file file)) + (let* ((compile-file (initz-get-correspondence-file file)) + (startup-directory (file-name-directory file)) + (flavor-directory (file-name-directory compile-file))) + (install-file (file-name-nondirectory compile-file) + startup-directory flavor-directory t t)) + (when (member file initz-compile-error-files) + (setq initz-compile-error-files + (delete file initz-compile-error-files)) + (initz-error-delete-whole-line))) + (error))))) + +(defun initz-error-delete-file () + "Delete the file under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (when (and file + (y-or-n-p + (format initz-error-delete-file-ask-message-format + (initz-get-module-name file)))) + (delete-file file) + (setq initz-compile-error-files + (delete file initz-compile-error-files)) + (setq initz-load-error-files + (delete file initz-load-error-files)) + (initz-error-delete-whole-line) + (initz-error-previous-line) + (initz-error-next-line)))) + +(defun initz-error-load-file () + "Load the file under point." + (interactive) + (let* ((file (get-text-property (point) :file))) + (initz-error-byte-compile-file) + (when (initz-load-file (initz-get-correspondence-file file)) + (setq initz-load-error-files + (delete file initz-load-error-files)) + (initz-error-delete-whole-line)))) + +(defun initz-error-mode () + "\\ + Major mode for browsing initz error buffer. + +\\[initz-error-next-line] Next line. +\\[initz-error-previous-line] Previous line. +\\[forward-char] Forward char. +\\[backward-char] Backward char. + +\\[initz-error-find-file] View the file under point. +\\[initz-error-byte-compile-file] Byte-compile the file under point. +\\[initz-error-delete-file] Delete the file under point. +\\[initz-error-load-file] Load the file under point. +\\[initz-startup] Initz startup. +\\[initz-error-quit] Quit the initz error mode." + (interactive) + (kill-all-local-variables) + (use-local-map initz-error-mode-map) + (setq mode-name initz-error-mode-name) + (setq major-mode 'initz-error-mode) + (when (or (featurep 'xemacs) (< emacs-major-version 21)) + (make-local-hook 'post-command-hook)) + (add-hook 'post-command-hook 'initz-error-print-file) + (run-hooks 'initz-error-mode-hook)) + +(defun initz-error () + "Show initz error messages." + (interactive) + (when (or initz-compile-error-files + initz-load-error-files) + ;; FIXME: ad-hoc + (let ((buf (get-buffer initz-error-buffer-name))) + (when buf + (unless (one-window-p) + (delete-window)) + (kill-buffer buf))) + (switch-to-buffer-other-window initz-error-buffer-name) + (initz-error-mode) + (goto-char (point-min)) + (insert + (format initz-error-click-message-format + (substitute-command-keys "\\[initz-error-find-file-mouse]"))) + (insert + (format initz-error-enter-message-format + (substitute-command-keys "\\[initz-error-find-file]"))) + (insert "\n") + (mapc + (function (lambda (node) + (initz-error-node-expand node))) + '("compile" "load")) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + (goto-char (point-min)) + (search-forward "\n\n") + (forward-char 1) + ;; FIXME: ad-hoc + (other-window 1))) + +(provide 'initz-error) + +;;; initz-error.el ends here diff --git a/lisp/initz-globals.el b/lisp/initz-globals.el new file mode 100644 index 0000000..3b22c6c --- /dev/null +++ b/lisp/initz-globals.el @@ -0,0 +1,67 @@ +1;;; initz-globals.el --- Global variables and constants. + +;; Copyright (C) 2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(defconst initz-null-string "") + +(defconst initz-separator-string "-") + +(defconst initz-module-regexp "[-.a-zA-Z0-9]+") + +(defconst initz-flavor + (if (featurep 'xemacs) + (concat "xemacs" (number-to-string emacs-major-version)) + (if (featurep 'meadow) + (concat "meadow" + (let ((mver (Meadow-version))) + (if (string-match "Meadow-\\([0-9]+\\.[0-9]+\\)" + mver) + (match-string 1 mver)))) + (concat "emacs" (number-to-string emacs-major-version))))) + +(defconst initz-load-module-ask-message-format + "Load init file for %s? ") + +(defconst initz-load-module-message-format + "Loading init file for %s...") + +(defconst initz-unload-module-message-format + "Unloading init file for %s...") + +(defvar initz-compile-error-files nil) + +(defvar initz-load-error-files nil) + +(defvar initz-load-list-internal nil) + +(defvar initz-ignore-list-internal nil) + +(provide 'initz-globals) + +;;; initz-globals.el ends here diff --git a/lisp/initz-list.el b/lisp/initz-list.el new file mode 100644 index 0000000..aa8a7da --- /dev/null +++ b/lisp/initz-list.el @@ -0,0 +1,479 @@ +;;; initz-list.el --- File list mode. + +;; Copyright (C) 2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(require 'emu) +(require 'initz-globals) +(require 'initz) + +(defvar initz-list-mode-map nil + "Local map for initz list buffers.") +(unless initz-list-mode-map + (let ((map (make-sparse-keymap))) + (define-key map mouse-button-2 'initz-list-find-file-mouse) + (define-key map "n" 'initz-list-next-line) + (define-key map "p" 'initz-list-previous-line) + (define-key map "h" 'backward-char) + (define-key map "j" 'initz-list-next-line) + (define-key map "k" 'initz-list-previous-line) + (define-key map "l" 'forward-char) + (define-key map " " 'initz-list-find-file) + (define-key map "\C-m" 'initz-list-find-file) + (define-key map "B" 'initz-list-byte-compile-file) + (define-key map "D" 'initz-list-delete-file) + (define-key map "L" 'initz-list-load-file) + (define-key map "N" 'initz-list-new-file) + (define-key map "S" 'initz-startup) + (define-key map "q" 'initz-list-quit) + (setq initz-list-mode-map map))) + +(defvar initz-list-node-map nil) +(unless initz-list-node-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map initz-list-mode-map) + (define-key map mouse-button-2 'initz-list-node-click) + (define-key map " " 'initz-list-node-enter) + (define-key map "\C-m" 'initz-list-node-enter) + (setq initz-list-node-map map))) + +(defvar initz-list-mode-hook nil + "Normal hook run when entering initz-list-mode.") + +(defconst initz-list-mode-name "Initz List") + +(defconst initz-list-buffer-name "*Initz List*") + +(defconst initz-list-delete-file-ask-message-format + "Delete %s? ") + +(defconst initz-list-input-dir-message-format + "Dir[%s] (%s): ") + +(defconst initz-list-input-module-message-format + "Module[%s]: ") + +(defconst initz-list-new-file-illegal-message + "Module name is illegal.") + +(defconst initz-list-new-file-exists-message + "File already exists.") + +(defconst initz-list-new-file-provided-message + "Module is already provided.") + +(defconst initz-list-new-file-comment-message-format + ";;; %s --- init file for %s.\n\n\n\n") + +(defconst initz-list-new-file-provide-message-format + "(provide '%s)\n") + +(defconst initz-list-click-message-format + "Click %s on the module name to select it.\n") + +(defconst initz-list-enter-message-format + "In this buffer, type %s to select the module name under point.\n") + +;; Initz list mode is suitable only for specially formatted data. +(put 'initz-list-mode 'mode-class 'special) + +(defadvice sort-build-lists (after sort-including-newline activate) + (when (or (eq major-mode 'initz-list-mode) + (eq major-mode 'initz-error-mode)) + (setq ad-return-value + (mapcar + (function (lambda (list) + (cons (cons (caar list) (1+ (cdar list))) + (cons (cadr list) (1+ (cddr list)))))) + ad-return-value)))) + +(defun initz-list-delete-whole-line () + "Delete whole line at point." + (setq buffer-read-only nil) + (delete-region (progn (beginning-of-line) (point)) + (progn (forward-line 1) (point))) + (set-buffer-modified-p nil) + (setq buffer-read-only t)) + +(defun initz-list-get-dir () + "Return the dir at point." + (save-excursion + (end-of-line) + (when (re-search-backward "^\\[[-+]\\] \\([^ :]+\\)" nil t) + (match-string 1)))) + +(defun initz-list-input-dir (&optional default) + "Input the dir." + (let* ((completing-list (mapcar + (function (lambda (list) + (symbol-name (car list)))) + initz-init-alist)) + (default (if (stringp default) default "misc"))) + (completing-read + (format initz-list-input-dir-message-format + initz-directory default) + (mapcar + (function (lambda (name) + (cons name name))) + completing-list) + nil t nil nil default))) + +(defun initz-list-input-module (dir) + "Input the module." + (let ((init (initz-get-init-value (intern dir) 'prefix))) + (setq init (initz-trim-separator init)) + (unless (string= init initz-null-string) + (setq init (concat init initz-separator-string))) + (if initz-list-input-module-completing + (completing-read + (format initz-list-input-module-message-format dir) + (mapcar + (function (lambda (feature) + (let ((name (symbol-name feature))) + (cons name name)))) + features) + nil nil init) + (read-string + (format initz-list-input-module-message-format dir) + init)))) + +(defun initz-list-insert-file (dir startup-file) + "Insert the STARTUP-FILE at DIR section." + ;; FIXME: Delete `save-excursion' and fix the next `FIXME'. + (save-excursion + (goto-char (point-min)) + (when (re-search-forward (concat "^\\[[-+]\\] " dir "[ :]") nil t) + (beginning-of-line) + (let ((status (get-text-property (point) :status))) + (when (eq status 'expand) + (let (sort-start) + (forward-line 1) + (setq sort-start (point)) + (if (re-search-forward "^\\[[-+]\\] " nil t) + (beginning-of-line) + (re-search-forward "\\'" nil t)) + (setq buffer-read-only nil) + (insert-char ?\ 4) + (let ((start (point))) + (insert (initz-get-module-name startup-file) "\n") + (add-text-properties start (1- (point)) + `(face initz-list-module-face + mouse-face highlight + start-open t rear-nonsticky t + help-echo ,startup-file)) + (put-text-property start (point) :file startup-file)) + (sort-lines nil sort-start (point))) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + ;; FIXME: Move to the line inserted now + ))))) + +(defun initz-list-node-insert (node status) + (let ((prefix (initz-get-init-value node 'prefix)) + (start (point))) + (setq prefix (initz-trim-separator prefix)) + ;; `prefix' will be broken. + (if (string= prefix initz-null-string) + (setq prefix initz-null-string) + (setq prefix (concat " (" prefix ")"))) + (insert "[" (if (eq status 'expand) "-" "+") "] " + (symbol-name node) prefix ":\n") + (add-text-properties start (+ start 3) + `(face initz-list-node-face + mouse-face highlight + local-map ,initz-list-node-map + keymap ,initz-list-node-map + start-open t rear-nonsticky t + :node ,node + :status ,status)))) + +(defun initz-list-node-collapse (node) + (save-excursion + (setq buffer-read-only nil) + (goto-char (point-min)) + (if (re-search-forward (concat "^\\[-\\] " + (symbol-name node) "[ :]") nil t) + (let ((start (progn (beginning-of-line) (point))) + end) + (forward-line 1) + (if (re-search-forward "^\\[[-+]\\] " nil t) + (progn + (beginning-of-line) + (setq end (point))) + (setq end (point-max))) + (delete-region start end)) + (goto-char (point-max))) + (initz-list-node-insert node 'collapse) + (set-buffer-modified-p nil) + (setq buffer-read-only t))) + +(defun initz-list-node-expand (node) + (save-excursion + (setq buffer-read-only nil) + (goto-char (point-min)) + (if (re-search-forward (concat "^\\[\\+\\] " + (symbol-name node) "[ :]") nil t) + (delete-region (progn (beginning-of-line) (point)) + (progn (forward-line 1) (point))) + (goto-char (point-max))) + (initz-list-node-insert node 'expand) + (let ((sort-start (point)) + (initz-features (initz-features))) + (mapc + (function (lambda (file) + (let* ((module (initz-get-module-name file)) + (loaded (memq (intern module) initz-features)) + start) + (insert-char ?\ 4) + (setq start (point)) + (insert module) + (when loaded (insert initz-list-loaded-mark)) + (insert "\n") + (add-text-properties + start (1- (point)) + `(face ,(if loaded + 'initz-list-module-face + 'initz-list-unloaded-module-face) + mouse-face highlight + start-open t rear-nonsticky t + help-echo ,file)) + (put-text-property start (point) :file file)))) + (initz-get-files 'startup node)) + (sort-lines nil sort-start (point))) + (set-buffer-modified-p nil) + (setq buffer-read-only t))) + +(defun initz-list-node-enter () + (interactive) + (let ((node (get-text-property (point) :node)) + (status (get-text-property (point) :status))) + (when (and node status) + (if (eq status 'expand) + (initz-list-node-collapse node) + (initz-list-node-expand node)) + (forward-char 1)))) + +(defun initz-list-node-click (e) + (interactive "e") + (mouse-set-point e) + (initz-list-node-enter)) + +(defun initz-list-next-line (&optional arg) + (interactive) + (if (integerp arg) + (next-line arg) + (next-line 1)) + (beginning-of-line) + (let ((start (re-search-forward "^\\( \\|\\[\\|\\)" nil t))) + (when (integer-or-marker-p start) + (goto-char start)))) + +(defun initz-list-previous-line () + (interactive) + (initz-list-next-line -1)) + +(defun initz-list-print-file () + "Print the file name under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (and file + (initz-message-no-log file)))) + +(defun initz-list-find-file () + "View the file under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (and file + (find-file-other-window file)))) + +(defun initz-list-find-file-mouse (e) + "View the file under clicked point." + (interactive "e") + (mouse-set-point e) + (unless (eolp) + (initz-list-find-file))) + +(defun initz-list-byte-compile-file () + "Byte-compile the file under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (when file + (condition-case nil + (when (save-window-excursion + (byte-compile-file file)) + (let* ((compile-file (initz-get-correspondence-file file)) + (startup-directory (file-name-directory file)) + (flavor-directory (file-name-directory compile-file))) + (install-file (file-name-nondirectory compile-file) + startup-directory flavor-directory t t)) + (setq initz-compile-error-files + (delete file initz-compile-error-files))) + (error))))) + +(defun initz-list-delete-file () + "Delete the file under point." + (interactive) + (let ((file (get-text-property (point) :file))) + (when (and file + (y-or-n-p + (format initz-list-delete-file-ask-message-format + (initz-get-module-name file)))) + (delete-file file) + (setq initz-compile-error-files + (delete file initz-compile-error-files)) + (setq initz-load-error-files + (delete file initz-load-error-files)) + (initz-list-delete-whole-line) + (initz-list-previous-line) + (initz-list-next-line)))) + +(defun initz-list-load-file () + "Load the file under point." + (interactive) + (let* ((file (get-text-property (point) :file))) + (initz-list-byte-compile-file) + (when (initz-load-file (initz-get-correspondence-file file)) + (setq initz-load-error-files + (delete file initz-load-error-files))))) + +;;;###autoload +(defun initz-list-new-file () + "Make new init file." + (interactive) + (let* ((default (initz-list-get-dir)) + (dir (initz-list-input-dir default)) + (module (initz-list-input-module dir))) + (if (not (or (and (string= dir "misc") (string= module initz-null-string)) + (string-match (concat "^" initz-module-regexp "$") module))) + (message initz-list-new-file-illegal-message) + (setq module (initz-trim-separator module)) + (let* ((startup-file (expand-file-name + (concat initz-prefix + (if (string= module initz-null-string) + initz-null-string + initz-separator-string) + module ".el") + (initz-startup-directory (intern dir))))) + (if (file-exists-p startup-file) + (message initz-list-new-file-exists-message) + (let ((base-name (initz-get-base-name startup-file))) + (if (memq (intern base-name) features) + (message initz-list-new-file-provided-message) + (initz-list-insert-file dir startup-file) + (find-file-other-window startup-file) + (insert (format initz-list-new-file-comment-message-format + (file-name-nondirectory startup-file) + (if (string= module initz-null-string) + initz-prefix + module))) + (insert (format initz-list-new-file-provide-message-format + base-name)) + (save-buffer) + (goto-char (point-min)) + (search-forward "\n\n")))))))) + +(defun initz-list-quit () + "Quit the initz list mode." + (interactive) + (when (or (eq major-mode 'initz-list-mode) + (eq major-mode 'initz-error-mode)) + (remove-hook 'post-command-hook + (intern (concat + (substring (symbol-name major-mode) 0 + (string-match "mode" + (symbol-name major-mode))) + "print-file"))) + (let ((buf (current-buffer))) + (unless (one-window-p) + (delete-window)) + (kill-buffer buf)))) + +(defun initz-list-mode () + "\\ + Major mode for browsing initz list buffer. + +\\[initz-list-next-line] Next line. +\\[initz-list-previous-line] Previous line. +\\[forward-char] Forward char. +\\[backward-char] Backward char. + +\\[initz-list-find-file] View the file under point. +\\[initz-list-byte-compile-file] Byte-compile the file under point. +\\[initz-list-delete-file] Delete the file under point. +\\[initz-list-load-file] Load the file under point. +\\[initz-list-new-file] Make new init file. +\\[initz-startup] Initz startup. +\\[initz-list-quit] Quit the initz list mode." + (interactive) + (kill-all-local-variables) + (use-local-map initz-list-mode-map) + (setq mode-name initz-list-mode-name) + (setq major-mode 'initz-list-mode) + (when (or (featurep 'xemacs) (< emacs-major-version 21)) + (make-local-hook 'post-command-hook)) + (add-hook 'post-command-hook 'initz-list-print-file) + (run-hooks 'initz-list-mode-hook)) + +;;;###autoload +(defun initz-list () + "Show initz list buffer." + (interactive) + ;; FIXME: ad-hoc + (let ((buf (get-buffer initz-list-buffer-name))) + (when buf + (unless (one-window-p) + (delete-window)) + (kill-buffer buf))) + (switch-to-buffer-other-window initz-list-buffer-name) + (initz-list-mode) + (goto-char (point-min)) + (insert + (format initz-list-click-message-format + (substitute-command-keys "\\[initz-list-find-file-mouse]"))) + (insert + (format initz-list-enter-message-format + (substitute-command-keys "\\[initz-list-find-file]"))) + (insert "\n") + (mapc + (function (lambda (alist) + (let ((sym (car alist))) + (funcall + (intern (concat "initz-list-node-" + (symbol-name + initz-list-default-node-status))) + sym)))) + initz-init-alist) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + (goto-char (point-min)) + (search-forward "\n\n") + (forward-char 1)) + +(provide 'initz-list) + +;;; initz-list.el ends here diff --git a/lisp/initz-util.el b/lisp/initz-util.el new file mode 100644 index 0000000..5719f89 --- /dev/null +++ b/lisp/initz-util.el @@ -0,0 +1,125 @@ +;;; initz-util.el --- Utilities. + +;; Copyright (C) 2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(require 'initz-vars) +(require 'initz-globals) +(eval-when-compile (require 'cl)) + +(defun initz-add-to-load-list (modules) + "Add MODULES to `initz-load-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (mapc + (function (lambda (module) + (add-to-list 'initz-load-list-internal module))) + modules))) + +(defun initz-add-to-ignore-list (modules) + "Add MODULES to `initz-ignore-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (mapc + (function (lambda (module) + (add-to-list 'initz-ignore-list-internal module))) + modules))) + +(defun initz-remove-from-load-list (modules) + "Remove MODULES from `initz-load-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (mapc + (function (lambda (module) + (setq initz-load-list-internal + (delete module initz-load-list-internal)))) + modules))) + +(defun initz-remove-from-ignore-list (modules) + "Remove MODULES from `initz-ignore-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (mapc + (function (lambda (module) + (setq initz-ignore-list-internal + (delete module initz-ignore-list-internal)))) + modules))) + +(defun initz-set-load-list (modules) + "Set MODULES to `initz-load-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (setq initz-load-list-internal modules))) + +(defun initz-set-ignore-list (modules) + "Set MODULES to `initz-ignore-list-internal'." + (let ((modules (if (listp modules) modules (list modules)))) + (setq initz-ignore-list-internal modules))) + +(defun initz-add-to-load-path (paths) + "Add PATHS to `load-path' recursively." + (let ((paths (if (listp paths) paths (list paths)))) + (mapc + (function (lambda (path) + (when (file-directory-p path) + (add-to-list 'load-path path) + (initz-add-to-load-path + ;; Without `.' and `..'. + (directory-files + path t "^\\([^.].+\\|\\.[^.].+\\|\\.\\..+\\)$"))))) + paths))) + +(defun initz-features () + "Return the Initz features." + (delq nil + (mapcar + (function (lambda (feature) + (let ((initz-feature (initz-get-module-name + (concat (symbol-name feature) + ".el")))) + (unless (string= initz-feature initz-null-string) + (intern initz-feature))))) + features))) + +;;; Internal functions. +(defun initz-get-base-name (init-file) + "Return base name of the INIT-FILE." + (file-name-sans-extension + (file-name-nondirectory init-file))) + +(defun initz-get-module-name (init-file) + "Return module name of the INIT-FILE." + (let ((base-name (initz-get-base-name init-file))) + (cond + ((string= base-name initz-prefix) initz-prefix) + ((string-match (concat + (regexp-quote (concat initz-prefix + initz-separator-string)) + "\\(" initz-module-regexp "\\)") + base-name) + (match-string 1 base-name)) + (t initz-null-string)))) + +(provide 'initz-util) + +;;; initz-util.el ends here diff --git a/lisp/initz-vars.el b/lisp/initz-vars.el new file mode 100644 index 0000000..f9c08c9 --- /dev/null +++ b/lisp/initz-vars.el @@ -0,0 +1,113 @@ +;;; initz-vars.el --- Customization. + +;; Copyright (C) 2001-2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(defgroup initz nil + "Initz specific customize group") + +(defgroup initz-face nil + "Faces for Initz." + :group 'initz + :prefix "initz-") + +;; User modifiable variables. +(defcustom initz-directory "~/.initz" + "*Initz files path." + :type 'directory + :group 'initz) + +(defcustom initz-prefix "init" + "*Initz files prefix." + :type 'string + :group 'initz) + +(defcustom initz-interactively nil + "*If non-nil, initz loads files interactively." + :type 'boolean + :group 'initz) + +(defcustom initz-verbose 'errors + "*If non-nil, initz runs verbose." + :type '(choice + (const :tag "Show messages and errors." errors) + (const :tag "Show only messages." messages) + (const :tag "Quietly." nil)) + :group 'initz) + +(defcustom initz-load-list '() + "*If non-nil, initz loads only the module contained in this list." + :type '(repeat string) + :group 'initz) + +(defcustom initz-ignore-list '() + "*If non-nil, initz ignores the module contained in this list." + :type '(repeat string) + :group 'initz) + +(defcustom initz-list-default-node-status 'expand + "*Default node status of `initz-list'." + :type '(choice + (const :tag "Expand" expand) + (const :tag "Collapse" collapse)) + :group 'initz) + +(defcustom initz-list-input-module-completing t + "*If non-nil, initz completes the module with `features'." + :type 'boolean + :group 'initz) + +(defcustom initz-list-loaded-mark "@" + "*If module was loaded, print this at the rear." + :type 'string + :group 'initz) + +;; Faces. +(defface initz-list-node-face + '((((class color) (background light)) (:foreground "blue")) + (((class color) (background dark)) (:foreground "cyan")) + (t (:bold t))) + "Face used to initz list node." + :group 'initz-face) + +(defface initz-list-module-face + '((((class color) (background light)) (:foreground "ForestGreen")) + (((class color) (background dark)) (:foreground "green")) + (t (:bold t))) + "Face used to initz list module." + :group 'initz-face) + +(defface initz-list-unloaded-module-face + '((((class color)) (:foreground "gray")) + (t (:italic t))) + "Face used to initz list unloaded module." + :group 'initz-face) + +(provide 'initz-vars) + +;;; initz-vars.el ends here diff --git a/lisp/initz.el b/lisp/initz.el new file mode 100644 index 0000000..2caad35 --- /dev/null +++ b/lisp/initz.el @@ -0,0 +1,350 @@ +;;; initz.el --- Handles the switching of various startup initialization files + +;; Copyright (C) 2001-2002 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: startup, init + +;; This file is part of Initz. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: +;; + +;;; Code: + +(require 'install) +(require 'product) +(require 'initz-vars) +(require 'initz-globals) +(require 'initz-util) +(eval-when-compile (require 'cl)) +(eval-and-compile + (autoload 'initz-error "initz-error" nil t) + (autoload 'initz-list "initz-list" nil t) + (autoload 'initz-list-new-file "initz-list" nil t)) + +(product-provide 'initz + (product-define "Initz" nil '(0 0 11))) + +(defun initz-version (&optional arg) + "Return Initz version. +If it is called interactively, version string is appeared on minibuffer. +If ARG is specified, don't display code name." + (interactive "P") + (let ((product-info (product-string-1 'initz (not arg)))) + (if (interactive-p) + (message "%s" product-info) + product-info))) + +(defconst initz-done-message-format + "Loading %s init files for %s...done") + +(defun initz-message (mesg) + "If `initz-verbose' is non-nil, print MESG." + (when initz-verbose (message mesg))) + +(defmacro initz-message-no-log (string &rest args) + "Like `message', except that message logging is disabled." + (if (featurep 'xemacs) + (if args + `(display-message 'no-log (format ,string ,@args)) + `(display-message 'no-log ,string)) + `(let (message-log-max) + (message ,string ,@args)))) + +(defun initz-trim-separator (string) + "Trim `initz-separator-string' from STRING." + (let ((temp string)) + (when (string-match (concat "^" initz-separator-string "+") temp) + (setq temp (substring temp (match-end 0)))) + (when (string-match (concat initz-separator-string "+$") temp) + (setq temp (substring temp 0 (match-beginning 0)))) + temp)) + +(defconst initz-init-alist + `((argument . ("argument" + ,(let ((args initz-null-string)) + (mapc + (function (lambda (arg) + (unless (string= args initz-null-string) + (setq args (concat args + initz-separator-string))) + (setq arg (initz-trim-separator arg)) + (setq args (concat args arg)))) + (cdr command-line-args)) + args))) + (flavor . ("flavor" ,initz-flavor)) + (host . ("host" ,(system-name))) + (system . ("system" ,(symbol-name system-type))) + (misc . (,initz-null-string ,initz-null-string)))) + +(defun initz-get-init-value (sym type) + "Return the TYPE's value of SYM from `initz-init-alist'." + (let ((list (cdr (assq sym initz-init-alist))) + (count 0)) + (unless (null list) + (catch 'found + (mapc + (function (lambda (temp) + (if (eq type temp) + (let ((elem (nth count list))) + (when (and (eq type 'prefix) + (not (string= elem initz-null-string))) + (setq elem (concat initz-separator-string + elem))) + (throw 'found elem)) + (setq count (incf count))))) + '(dir prefix)) + nil)))) + +(defun initz-directory (kind) + "Return the directory of KIND." + (let ((dir (cond + ((eq kind 'startup) "startup") + ((eq kind 'flavor) initz-flavor) + (t initz-null-string)))) + (expand-file-name dir initz-directory))) + +(defun initz-startup-directory (sym) + "Return the startup directory of SYM." + (expand-file-name + (initz-get-init-value sym 'dir) + (initz-directory 'startup))) + +(defun initz-flavor-directory (sym) + "Return the flavor directory of SYM." + (expand-file-name + (initz-get-init-value sym 'dir) + (initz-directory 'flavor))) + +(defun initz-get-kind (file) + "Return the kind of FILE." + (catch 'found + (mapc + (function (lambda (kind) + (when (string-match (initz-directory kind) file) + (throw 'found kind)))) + '(startup flavor)) + nil)) + +(defun initz-get-dir (file) + "Return dir of the FILE." + (let ((file (file-name-directory file)) + (directory (initz-directory (initz-get-kind file)))) + (when (string-match "/$" file) + (setq file (substring file 0 (1- (length file))))) + (catch 'found + (if (string= file directory) + (throw 'found 'misc) + (when (string-match (concat directory "\\(.+\\)") file) + (let ((dir (substring (match-string 1 file) 1))) + (mapc + (function (lambda (alist) + (when (string= (nth 0 (cdr alist)) dir) + (throw 'found (car alist))))) + initz-init-alist)))) + nil))) + +(defun initz-get-correspondence-file (init-file) + "Return correspondence file of the INIT-FILE." + (let* ((file (file-name-nondirectory init-file)) + (kind (if (eq (initz-get-kind init-file) 'startup) + 'flavor + 'startup)) + (directory (expand-file-name + (initz-get-init-value (initz-get-dir init-file) 'dir) + (initz-directory kind)))) + (expand-file-name (if (eq kind 'startup) + (substring file 0 (1- (length file))) + (concat file "c")) + directory))) + +(defun initz-get-files (kind dir) + "Return files of the directory made by KIND and DIR." + (let ((directory (expand-file-name + (initz-get-init-value dir 'dir) + (initz-directory kind))) + (prefix (regexp-quote + (concat initz-prefix + (initz-get-init-value dir 'prefix)))) + (ext (if (eq kind 'startup) "\\.el$" "\\.elc$"))) + (unless (and (not (eq dir 'misc)) + (string= prefix initz-prefix)) + (directory-files + directory t (concat "^\\(" prefix "\\|" + prefix initz-separator-string + initz-module-regexp "\\)" ext))))) + +(defun initz-make-directory (sym) + "Make SYM's directory." + (mapc + (function (lambda (kind) + (let ((directory (expand-file-name + (initz-get-init-value sym 'dir) + (initz-directory kind)))) + (unless (file-directory-p directory) + (make-directory directory t))))) + '(startup flavor))) + +(defun initz-make-directories () + "Make initz directories." + (interactive) + (mapc + (function (lambda (alist) + (let ((sym (car alist))) + (initz-make-directory sym)))) + initz-init-alist)) + +(defun initz-delete-file (flavor-file) + "Delete the FLAVOR-FILE when startup-file was deleted." + (let ((startup-file (initz-get-correspondence-file flavor-file))) + (unless (file-exists-p startup-file) + (delete-file flavor-file)))) + +(defun initz-delete-files (sym) + "Delete files in the SYM's directory when startup-file was deleted." + (let ((flavor-files (initz-get-files 'flavor sym))) + (mapc + (function (lambda (flavor-file) + (initz-delete-file flavor-file))) + flavor-files))) + +(defun initz-delete () + "Delete the initz startup files." + (interactive) + (initz-make-directories) + (mapc + (function (lambda (alist) + (let ((sym (car alist))) + (initz-delete-files sym)))) + initz-init-alist)) + +(defun initz-compile-file (startup-file) + "Compile the STARTUP-FILE." + (let ((flavor-file (initz-get-correspondence-file startup-file))) + (when (file-newer-than-file-p startup-file flavor-file) + (condition-case nil + (unless (save-window-excursion + (byte-compile-file startup-file)) + (error nil)) + (error + ;; Use `initz-ignore-list' instead of `initz-ignore-list-internal' + ;; purposely. + (unless (member (initz-get-module-name startup-file) + initz-ignore-list) + (add-to-list 'initz-compile-error-files startup-file)) + nil))))) + +(defun initz-compile-files (sym) + "Compile files in the SYM's directory." + (let ((startup-files (initz-get-files 'startup sym)) + compiled-files) + (mapc + (function (lambda (startup-file) + (initz-compile-file startup-file))) + startup-files) + (setq compiled-files (directory-files + (initz-startup-directory sym) nil "\\.elc$")) + (install-files compiled-files (initz-startup-directory sym) + (initz-flavor-directory sym) t t))) + +(defun initz-compile () + "Compile the initz startup files." + (interactive) + (initz-delete) + (setq initz-compile-error-files nil) + (mapc + (function (lambda (alist) + (let ((sym (car alist))) + (initz-compile-files sym)))) + initz-init-alist) + (and initz-compile-error-files (eq initz-verbose 'errors) + (initz-error))) + +(defun initz-load-file (flavor-file &optional unload) + "Load the FLAVOR-FILE." + (let* ((module (initz-get-module-name flavor-file)) + (mesg (format (if unload + initz-unload-module-message-format + initz-load-module-message-format) + module))) + (if (or (member module initz-ignore-list-internal) + (and initz-load-list-internal + (not (member module initz-load-list-internal)))) + (initz-message (concat mesg "ignored")) + (unless (and initz-interactively + (not (y-or-n-p + (format initz-load-module-ask-message-format + module)))) + (initz-message mesg) + (condition-case nil + (let*((base-name (initz-get-base-name flavor-file)) + (feature (intern base-name))) + (if unload + (unload-feature feature t) + (when (memq feature features) + (unload-feature feature t)) + (require feature)) + (initz-message (concat mesg "done"))) + (error (add-to-list 'initz-load-error-files + (initz-get-correspondence-file flavor-file)) + (initz-message (concat mesg "failed")) + nil)))))) + +(defun initz-load-files (sym) + "Load files in the SYM's directory." + (let ((flavor-files (initz-get-files 'flavor sym))) + (mapc + (function (lambda (flavor-file) + (initz-load-file flavor-file))) + flavor-files))) + +(defun initz-load () + "Load the initz startup files." + (interactive) + (initz-compile) + (setq initz-load-error-files nil) + (initz-add-to-load-path (initz-directory 'flavor)) + ;; tricky + (setq initz-load-list-internal initz-load-list) + (setq initz-ignore-list-internal initz-ignore-list) + (mapc + (function (lambda (alist) + (let ((sym (car alist))) + (initz-load-files sym)))) + initz-init-alist) + (and initz-load-error-files (eq initz-verbose 'errors) + (initz-error))) + +(defun initz-done () + "Initz done." + (initz-message (format initz-done-message-format + (initz-version) initz-flavor))) + +;;;###autoload +(defun initz-startup () + "Initz startup." + (interactive) + (unless noninteractive + (initz-load) + (initz-done))) + +(provide 'initz) + +;;; initz.el ends here diff --git a/sample/README b/sample/README new file mode 100644 index 0000000..e69de29 diff --git a/sample/dot.emacs b/sample/dot.emacs new file mode 100644 index 0000000..f42aef0 --- /dev/null +++ b/sample/dot.emacs @@ -0,0 +1,15 @@ +;;; .emacs + +(require 'initz) +(add-hook 'after-init-hook 'initz-startup) + +;(setq initz-interactively t) +;(setq initz-verbose 'messages) +;(setq initz-list-default-node-status 'expand) + +;(setq initz-load-list '()) +;(setq initz-ignore-list '("test")) + +;;; load path +;(initz-add-to-load-path `("~/share/emacs/site-lisp" +; ,(concat "~/share/" initz-flavor "/site-lisp"))) diff --git a/sample/startup/flavor/init-emacs20.el b/sample/startup/flavor/init-emacs20.el new file mode 100644 index 0000000..1a8b8b2 --- /dev/null +++ b/sample/startup/flavor/init-emacs20.el @@ -0,0 +1,5 @@ +;;; init-emacs20.el --- init file for emacs20. + +(menu-bar-mode -1) + +(provide 'init-emacs20) diff --git a/sample/startup/flavor/init-xemacs21.el b/sample/startup/flavor/init-xemacs21.el new file mode 100644 index 0000000..9645ae4 --- /dev/null +++ b/sample/startup/flavor/init-xemacs21.el @@ -0,0 +1,9 @@ +;;; init-xemacs21.el --- init file for xemacs21. + +(setq progress-feedback-use-echo-area t) +(set-specifier default-toolbar-visible-p nil) +(set-specifier menubar-visible-p nil) +(if (featurep 'gutter) + (set-specifier default-gutter-visible-p nil)) + +(provide 'init-xemacs21) diff --git a/sample/startup/host/init-host1-skk.el b/sample/startup/host/init-host1-skk.el new file mode 100644 index 0000000..01a663f --- /dev/null +++ b/sample/startup/host/init-host1-skk.el @@ -0,0 +1,6 @@ +;;; init-host1-skk.el --- init file for host1-skk. + +(when (locate-library "skk") + (setq skk-large-jisyo "/usr/share/skk/SKK-JISYO.L")) + +(provide 'init-host1-skk) diff --git a/sample/startup/host/init-host2-skk.el b/sample/startup/host/init-host2-skk.el new file mode 100644 index 0000000..02a8dd3 --- /dev/null +++ b/sample/startup/host/init-host2-skk.el @@ -0,0 +1,6 @@ +;;; init-host2-skk.el --- init file for host2-skk. + +(when (locate-library "skk") + (setq skk-large-jisyo "/usr/local/share/skk/SKK-JISYO.L")) + +(provide 'init-host2-skk) diff --git a/sample/startup/init-skk.el b/sample/startup/init-skk.el new file mode 100644 index 0000000..fe7bde5 --- /dev/null +++ b/sample/startup/init-skk.el @@ -0,0 +1,10 @@ +;;; initz-skk.el --- init file for skk. + +(when (locate-library "skk") + (setq skk-auto-okuri-process t) + (setq skk-japanese-message-and-error t) + (setq skk-keep-record nil) + (global-set-key "\C-x\C-j" 'skk-mode) + (autoload 'skk-mode "skk" nil t)) + +(provide 'init-skk) diff --git a/sample/startup/init-test.el b/sample/startup/init-test.el new file mode 100644 index 0000000..23d5523 --- /dev/null +++ b/sample/startup/init-test.el @@ -0,0 +1,5 @@ +;;; initz-test.el --- init file for test. + +(setq test "test") + +(provide 'init-test) -- 1.7.10.4