Mercurial > hg > xemacs-beta
annotate lisp/packages.el @ 4981:4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
-------------------- ChangeLog entries follow: --------------------
modules/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c:
* postgresql/postgresql.c (CHECK_LIVE_CONNECTION):
* postgresql/postgresql.c (Fpq_connectdb):
* postgresql/postgresql.c (Fpq_connect_start):
* postgresql/postgresql.c (Fpq_lo_import):
* postgresql/postgresql.c (Fpq_lo_export):
* ldap/eldap.c (Fldap_open):
* ldap/eldap.c (Fldap_search_basic):
* ldap/eldap.c (Fldap_add):
* ldap/eldap.c (Fldap_modify):
* ldap/eldap.c (Fldap_delete):
* canna/canna_api.c (Fcanna_initialize):
* canna/canna_api.c (Fcanna_store_yomi):
* canna/canna_api.c (Fcanna_parse):
* canna/canna_api.c (Fcanna_henkan_begin):
EXTERNAL_TO_C_STRING returns its argument instead of storing it
in a parameter, and is renamed to EXTERNAL_TO_ITEXT. Similar
things happen to related macros. See entry in src/ChangeLog.
More Mule-izing of postgresql.c. Extract out common code
between `pq-connectdb' and `pq-connect-start'. Fix places
that signal an error string using a formatted string to instead
follow the standard and have a fixed reason followed by the
particular error message stored as one of the frobs.
src/ChangeLog addition:
2010-02-05 Ben Wing <ben@xemacs.org>
* console-msw.c (write_string_to_mswindows_debugging_output):
* console-msw.c (Fmswindows_message_box):
* console-x.c (x_perhaps_init_unseen_key_defaults):
* console.c:
* database.c (dbm_get):
* database.c (dbm_put):
* database.c (dbm_remove):
* database.c (berkdb_get):
* database.c (berkdb_put):
* database.c (berkdb_remove):
* database.c (Fopen_database):
* device-gtk.c (gtk_init_device):
* device-msw.c (msprinter_init_device_internal):
* device-msw.c (msprinter_default_printer):
* device-msw.c (msprinter_init_device):
* device-msw.c (sync_printer_with_devmode):
* device-msw.c (Fmsprinter_select_settings):
* device-x.c (sanity_check_geometry_resource):
* device-x.c (Dynarr_add_validified_lisp_string):
* device-x.c (x_init_device):
* device-x.c (Fx_put_resource):
* device-x.c (Fx_valid_keysym_name_p):
* device-x.c (Fx_set_font_path):
* dialog-msw.c (push_lisp_string_as_unicode):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-msw.c (handle_file_dialog_box):
* dialog-x.c (dbox_descriptor_to_widget_value):
* editfns.c (Fformat_time_string):
* editfns.c (Fencode_time):
* editfns.c (Fset_time_zone_rule):
* emacs.c (make_argc_argv):
* emacs.c (Fdump_emacs):
* emodules.c (emodules_load):
* eval.c:
* eval.c (maybe_signal_error_1):
* event-msw.c (Fdde_alloc_advise_item):
* event-msw.c (mswindows_dde_callback):
* event-msw.c (mswindows_wnd_proc):
* fileio.c (report_error_with_errno):
* fileio.c (Fsysnetunam):
* fileio.c (Fdo_auto_save):
* font-mgr.c (extract_fcapi_string):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_filename):
* frame-gtk.c (gtk_set_frame_text_value):
* frame-gtk.c (gtk_create_widgets):
* frame-msw.c (mswindows_init_frame_1):
* frame-msw.c (mswindows_set_title_from_ibyte):
* frame-msw.c (msprinter_init_frame_3):
* frame-x.c (x_set_frame_text_value):
* frame-x.c (x_set_frame_properties):
* frame-x.c (start_drag_internal_1):
* frame-x.c (x_cde_transfer_callback):
* frame-x.c (x_create_widgets):
* glyphs-eimage.c (my_jpeg_output_message):
* glyphs-eimage.c (jpeg_instantiate):
* glyphs-eimage.c (gif_instantiate):
* glyphs-eimage.c (png_instantiate):
* glyphs-eimage.c (tiff_instantiate):
* glyphs-gtk.c (xbm_instantiate_1):
* glyphs-gtk.c (gtk_xbm_instantiate):
* glyphs-gtk.c (gtk_xpm_instantiate):
* glyphs-gtk.c (gtk_xface_instantiate):
* glyphs-gtk.c (cursor_font_instantiate):
* glyphs-gtk.c (gtk_redisplay_widget):
* glyphs-gtk.c (gtk_widget_instantiate_1):
* glyphs-gtk.c (gtk_add_tab_item):
* glyphs-msw.c (mswindows_xpm_instantiate):
* glyphs-msw.c (bmp_instantiate):
* glyphs-msw.c (mswindows_resource_instantiate):
* glyphs-msw.c (xbm_instantiate_1):
* glyphs-msw.c (mswindows_xbm_instantiate):
* glyphs-msw.c (mswindows_xface_instantiate):
* glyphs-msw.c (mswindows_redisplay_widget):
* glyphs-msw.c (mswindows_widget_instantiate):
* glyphs-msw.c (add_tree_item):
* glyphs-msw.c (add_tab_item):
* glyphs-msw.c (mswindows_combo_box_instantiate):
* glyphs-msw.c (mswindows_widget_query_string_geometry):
* glyphs-x.c (x_locate_pixmap_file):
* glyphs-x.c (xbm_instantiate_1):
* glyphs-x.c (x_xbm_instantiate):
* glyphs-x.c (extract_xpm_color_names):
* glyphs-x.c (x_xpm_instantiate):
* glyphs-x.c (x_xface_instantiate):
* glyphs-x.c (autodetect_instantiate):
* glyphs-x.c (safe_XLoadFont):
* glyphs-x.c (cursor_font_instantiate):
* glyphs-x.c (x_redisplay_widget):
* glyphs-x.c (Fchange_subwindow_property):
* glyphs-x.c (x_widget_instantiate):
* glyphs-x.c (x_tab_control_redisplay):
* glyphs.c (pixmap_to_lisp_data):
* gui-x.c (menu_separator_style_and_to_external):
* gui-x.c (add_accel_and_to_external):
* gui-x.c (button_item_to_widget_value):
* hpplay.c (player_error_internal):
* hpplay.c (play_sound_file):
* hpplay.c (play_sound_data):
* intl.c (Fset_current_locale):
* lisp.h:
* menubar-gtk.c (gtk_xemacs_set_accel_keys):
* menubar-msw.c (populate_menu_add_item):
* menubar-msw.c (populate_or_checksum_helper):
* menubar-x.c (menu_item_descriptor_to_widget_value_1):
* nt.c (init_user_info):
* nt.c (get_long_basename):
* nt.c (nt_get_resource):
* nt.c (init_mswindows_environment):
* nt.c (get_cached_volume_information):
* nt.c (mswindows_readdir):
* nt.c (read_unc_volume):
* nt.c (mswindows_stat):
* nt.c (mswindows_getdcwd):
* nt.c (mswindows_executable_type):
* nt.c (Fmswindows_short_file_name):
* ntplay.c (nt_play_sound_file):
* objects-gtk.c:
* objects-gtk.c (gtk_valid_color_name_p):
* objects-gtk.c (gtk_initialize_font_instance):
* objects-gtk.c (gtk_font_list):
* objects-msw.c (font_enum_callback_2):
* objects-msw.c (parse_font_spec):
* objects-x.c (x_parse_nearest_color):
* objects-x.c (x_valid_color_name_p):
* objects-x.c (x_initialize_font_instance):
* objects-x.c (x_font_instance_truename):
* objects-x.c (x_font_list):
* objects-xlike-inc.c (XFUN):
* objects-xlike-inc.c (xft_find_charset_font):
* process-nt.c (mswindows_report_winsock_error):
* process-nt.c (nt_create_process):
* process-nt.c (get_internet_address):
* process-nt.c (nt_open_network_stream):
* process-unix.c:
* process-unix.c (allocate_pty):
* process-unix.c (get_internet_address):
* process-unix.c (unix_canonicalize_host_name):
* process-unix.c (unix_open_network_stream):
* realpath.c:
* select-common.h (lisp_data_to_selection_data):
* select-gtk.c (symbol_to_gtk_atom):
* select-gtk.c (atom_to_symbol):
* select-msw.c (symbol_to_ms_cf):
* select-msw.c (mswindows_register_selection_data_type):
* select-x.c (symbol_to_x_atom):
* select-x.c (x_atom_to_symbol):
* select-x.c (hack_motif_clipboard_selection):
* select-x.c (Fx_store_cutbuffer_internal):
* sound.c (Fplay_sound_file):
* sound.c (Fplay_sound):
* sound.h (sound_perror):
* sysdep.c:
* sysdep.c (qxe_allocating_getcwd):
* sysdep.c (qxe_execve):
* sysdep.c (copy_in_passwd):
* sysdep.c (qxe_getpwnam):
* sysdep.c (qxe_ctime):
* sysdll.c (dll_open):
* sysdll.c (dll_function):
* sysdll.c (dll_variable):
* sysdll.c (search_linked_libs):
* sysdll.c (dll_error):
* sysfile.h:
* sysfile.h (PATHNAME_CONVERT_OUT_TSTR):
* sysfile.h (PATHNAME_CONVERT_OUT_UTF_8):
* sysfile.h (PATHNAME_CONVERT_OUT):
* sysfile.h (LISP_PATHNAME_CONVERT_OUT):
* syswindows.h (ITEXT_TO_TSTR):
* syswindows.h (LOCAL_FILE_FORMAT_TO_TSTR):
* syswindows.h (TSTR_TO_LOCAL_FILE_FORMAT):
* syswindows.h (LOCAL_FILE_FORMAT_TO_INTERNAL_MSWIN):
* syswindows.h (LISP_LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR):
* text.h:
* text.h (eicpy_ext_len):
* text.h (enum new_dfc_src_type):
* text.h (EXTERNAL_TO_ITEXT):
* text.h (GET_STRERROR):
* tooltalk.c (check_status):
* tooltalk.c (Fadd_tooltalk_message_arg):
* tooltalk.c (Fadd_tooltalk_pattern_attribute):
* tooltalk.c (Fadd_tooltalk_pattern_arg):
* win32.c (tstr_to_local_file_format):
* win32.c (mswindows_lisp_error_1):
* win32.c (mswindows_report_process_error):
* win32.c (Fmswindows_shell_execute):
* win32.c (mswindows_read_link_1):
Changes involving external/internal format conversion,
mostly code cleanup and renaming.
1. Eliminate the previous macros like LISP_STRING_TO_EXTERNAL
that stored its result in a parameter. The new version of
LISP_STRING_TO_EXTERNAL returns its result through the
return value, same as the previous NEW_LISP_STRING_TO_EXTERNAL.
Use the new-style macros throughout the code.
2. Rename C_STRING_TO_EXTERNAL and friends to ITEXT_TO_EXTERNAL,
in keeping with overall naming rationalization involving
Itext and related types.
Macros involved in previous two:
EXTERNAL_TO_C_STRING -> EXTERNAL_TO_ITEXT
EXTERNAL_TO_C_STRING_MALLOC -> EXTERNAL_TO_ITEXT_MALLOC
SIZED_EXTERNAL_TO_C_STRING -> SIZED_EXTERNAL_TO_ITEXT
SIZED_EXTERNAL_TO_C_STRING_MALLOC -> SIZED_EXTERNAL_TO_ITEXT_MALLOC
C_STRING_TO_EXTERNAL -> ITEXT_TO_EXTERNAL
C_STRING_TO_EXTERNAL_MALLOC -> ITEXT_TO_EXTERNAL_MALLOC
LISP_STRING_TO_EXTERNAL
LISP_STRING_TO_EXTERNAL_MALLOC
LISP_STRING_TO_TSTR
C_STRING_TO_TSTR -> ITEXT_TO_TSTR
TSTR_TO_C_STRING -> TSTR_TO_ITEXT
The following four still return their values through parameters,
since they have more than one value to return:
C_STRING_TO_SIZED_EXTERNAL -> ITEXT_TO_SIZED_EXTERNAL
LISP_STRING_TO_SIZED_EXTERNAL
C_STRING_TO_SIZED_EXTERNAL_MALLOC -> ITEXT_TO_SIZED_EXTERNAL_MALLOC
LISP_STRING_TO_SIZED_EXTERNAL_MALLOC
Sometimes additional casts had to be inserted, since the old
macros played strange games and completely defeated the type system
of the store params.
3. Rewrite many places where direct calls to TO_EXTERNAL_FORMAT
occurred with calls to one of the convenience macros listed above,
or to make_extstring().
4. Eliminate SIZED_C_STRING macros (they were hardly used, anyway)
and use a direct call to TO_EXTERNAL_FORMAT or TO_INTERNAL_FORMAT.
4. Use LISP_PATHNAME_CONVERT_OUT in many places instead of something
like LISP_STRING_TO_EXTERNAL(..., Qfile_name).
5. Eliminate some temporary variables that are no longer necessary
now that we return a value rather than storing it into a variable.
6. Some Mule-izing in database.c.
7. Error functions:
-- A bit of code cleanup in maybe_signal_error_1.
-- Eliminate report_file_type_error; it's just an alias for
signal_error_2 with params in a different order.
-- Fix some places in the hostname-handling code that directly
inserted externally-retrieved error strings into the
supposed ASCII "reason" param instead of doing the right thing
and sticking text descriptive of what was going on in "reason"
and putting the external message in a frob.
8. Use Ascbyte instead of CIbyte in process-unix.c and maybe one
or two other places.
9. Some code cleanup in copy_in_passwd() in sysdep.c.
10. Fix a real bug due to accidental variable shadowing in
tstr_to_local_file_format() in win32.c.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Feb 2010 11:02:24 -0600 |
parents | 9c6ea1581159 |
children | 6b6b0f8ab749 |
rev | line source |
---|---|
428 | 1 ;;; packages.el --- Low level support for XEmacs packages |
2 | |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
2557 | 4 ;; Copyright (C) 2002, 2003, 2004 Ben Wing. |
428 | 5 |
6 ;; Author: Steven L Baur <steve@xemacs.org> | |
7 ;; Maintainer: Steven L Baur <steve@xemacs.org> | |
8 ;; Keywords: internal, lisp, dumped | |
9 | |
10 ;; This file is part of XEmacs. | |
11 | |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | |
13 ;; under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
25 ;; 02111-1307, USA. | |
26 | |
27 ;;; Synched up with: Not in FSF | |
28 | |
29 ;;; Commentary: | |
30 | |
31 ;; This file is dumped with XEmacs. | |
32 | |
33 ;; This file provides low level facilities for XEmacs startup -- | |
34 ;; particularly regarding the package setup. This code has to run in | |
35 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp | |
36 ;; environment. Pay special attention: | |
37 | |
38 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead. | |
39 ;; (this goes for any package loaded before `subr.el'.) | |
40 ;; | |
41 ;; - not to use macros, because they are not yet available (and this | |
442 | 42 ;; file must be loadable uncompiled.) Built in macros, such as |
43 ;; `when' and `unless' are fine, of course. | |
428 | 44 ;; |
45 ;; - not to use `defcustom'. If you must add user-customizable | |
46 ;; variables here, use `defvar', and add the variable to | |
47 ;; `cus-start.el'. | |
48 | |
49 ;; Because of all this, make sure that the stuff you put here really | |
50 ;; belongs here. | |
51 | |
52 ;; This file requires find-paths.el. | |
53 | |
54 ;;; Code: | |
55 | |
56 ;;; Package versioning | |
57 | |
58 (defvar packages-package-list nil | |
454 | 59 "Database of installed packages and version numbers") |
428 | 60 |
2456 | 61 ;;; Directories and paths |
62 | |
63 ;;; Terminology: | |
64 | |
65 ;;; A *package hierarchy* is a directory that contains a collection of | |
66 ;;; packages; it has lisp/, info/, etc/ etc. subdirectories that | |
67 ;;; contain the files constituting the packages. | |
68 | |
69 ;;; A *package directory* contains package hierarchies---the package | |
70 ;;; hierarchies are typically in directories "xemacs-packages", | |
71 ;;; "mule-packages", and so on. A package hierarchy might only be | |
72 ;;; applicable for specific variants of XEmacs. | |
73 | |
74 ;;; Package hierarchies come in "early", "late", and "last" variants, | |
75 ;;; depending on their relative location in the various paths. | |
76 ;;; "Early" hierarchies are typically in the user's home directory, | |
77 ;;; "late" hierarchies are typically part of the XEmacs installation, | |
78 ;;; and "last" package hierarchies are for special purposes, such as | |
79 ;;; making the packages of some previous XEmacs version available. | |
428 | 80 |
81 (defvar packages-load-path-depth 1 | |
82 "Depth of load-path search in package hierarchies.") | |
83 | |
84 (defvar packages-data-path-depth 1 | |
85 "Depth of data-path search in package hierarchies.") | |
86 | |
2456 | 87 (defvar early-package-hierarchies nil |
88 "Package hierarchies early in the load path.") | |
428 | 89 |
90 (defvar early-package-load-path nil | |
91 "Load path for packages early in the load path.") | |
92 | |
2456 | 93 (defvar late-package-hierarchies nil |
94 "Package hierarchies late in the load path.") | |
428 | 95 |
96 (defvar late-package-load-path nil | |
97 "Load path for packages late in the load path.") | |
98 | |
2456 | 99 (defvar last-package-hierarchies nil |
100 "Package hierarchies last in the load path.") | |
428 | 101 |
102 (defvar last-package-load-path nil | |
103 "Load path for packages last in the load path.") | |
104 | |
2456 | 105 (defun packages-package-hierarchy-directory-names () |
106 "Returns a list package hierarchy directory names. | |
107 These are the valid immediate directory names of package | |
108 directories, directories with higher priority first" | |
4919
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
109 (delq nil `("site-packages" |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
110 ,(when (featurep 'infodock) "infodock-packages") |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
111 ,(when (featurep 'mule) "mule-packages") |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
112 "xemacs-packages"))) |
428 | 113 |
114 (defun package-get-key-1 (info key) | |
115 "Locate keyword `key' in list." | |
116 (cond ((null info) | |
117 nil) | |
118 ((eq (car info) key) | |
119 (nth 1 info)) | |
120 (t (package-get-key-1 (cddr info) key)))) | |
121 | |
122 (defun package-get-key (name key) | |
123 "Get info `key' from package `name'." | |
124 (let ((info (assq name packages-package-list))) | |
125 (when info | |
126 (package-get-key-1 (cdr info) key)))) | |
127 | |
128 (defun package-provide (name &rest attributes) | |
129 (let ((info (if (and attributes (floatp (car attributes))) | |
130 (list :version (car attributes)) | |
131 attributes))) | |
132 (setq packages-package-list | |
133 (cons (cons name info) (remassq name packages-package-list))))) | |
134 | |
2557 | 135 (defun package-suppress (package file form) |
136 "Set up a package-suppress condition FORM for FILE in PACKAGE. | |
137 When XEmacs searches for a file in the load path, it will ignore FILE | |
138 if FORM evaluates to non-nil." | |
139 (setq load-suppress-alist | |
140 (acons (expand-file-name file load-file-name) form | |
141 load-suppress-alist))) | |
142 | |
428 | 143 (defun package-require (name version) |
144 (let ((pkg (assq name packages-package-list))) | |
145 (cond ((null pkg) | |
1410 | 146 (error 'invalid-state |
147 (format "Package %s has not been loaded into this XEmacsen" | |
148 name))) | |
428 | 149 ((< (package-get-key name :version) version) |
1410 | 150 (error 'search-failed |
151 (format "Need version %g of package %s, got version %g" | |
2252 | 152 version name (package-get-key name :version)))) |
428 | 153 (t t)))) |
154 | |
155 (defun package-delete-name (name) | |
156 (let (pkg) | |
157 ;; Delete ALL versions of package. | |
158 ;; This is pretty memory-intensive, as we use copy-alist when deleting | |
159 ;; package entries, to prevent side-effects in functions that call this | |
160 ;; one. | |
161 (while (setq pkg (assq name packages-package-list)) | |
162 (setq packages-package-list (delete pkg (copy-alist | |
1365 | 163 packages-package-list)))))) |
428 | 164 |
165 ;;; Build time stuff | |
166 | |
167 (defvar autoload-file-name "auto-autoloads.el" | |
168 "Filename that autoloads are expected to be found in.") | |
169 | |
1330 | 170 ;; Moved from help.el. |
428 | 171 ;; Unlike the FSF version, our `locate-library' uses the `locate-file' |
172 ;; primitive, which should make it lightning-fast. | |
173 | |
174 (defun locate-library (library &optional nosuffix path interactive-call) | |
175 "Show the precise file name of Emacs library LIBRARY. | |
176 This command searches the directories in `load-path' like `M-x load-library' | |
177 to find the file that `M-x load-library RET LIBRARY RET' would load. | |
178 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | |
179 to the specified name LIBRARY. | |
180 | |
181 If the optional third arg PATH is specified, that list of directories | |
182 is used instead of `load-path'." | |
624 | 183 (interactive (list (read-library-name "Locate library: ") |
428 | 184 nil nil |
185 t)) | |
186 (let ((result | |
187 (locate-file | |
188 library | |
189 (or path load-path) | |
190 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist) | |
191 (and (boundp 'find-file-hooks) | |
192 (member 'crypt-find-file-hook find-file-hooks))) | |
193 ;; Compression involved. | |
194 (if nosuffix | |
448 | 195 '("" ".gz" ".Z" ".bz2") |
196 '(".elc" ".elc.gz" "elc.Z" ".elc.bz2" | |
197 ".el" ".el.gz" ".el.Z" ".el.bz2" | |
198 "" ".gz" ".Z" ".bz2"))) | |
428 | 199 (t |
200 ;; No compression. | |
201 (if nosuffix | |
202 "" | |
203 '(".elc" ".el" ""))))))) | |
204 (and interactive-call | |
205 (if result | |
206 (message "Library is file %s" result) | |
207 (message "No library %s in search path" library))) | |
208 result)) | |
209 | |
210 (defun packages-add-suffix (str) | |
211 (if (null (string-match "\\.el\\'" str)) | |
212 (concat str ".elc") | |
213 str)) | |
214 | |
215 (defun packages-list-autoloads-path () | |
216 "List autoloads from precomputed load-path." | |
217 (let ((path load-path) | |
218 autoloads) | |
219 (while path | |
220 (if (file-exists-p (concat (car path) | |
221 autoload-file-name)) | |
222 (setq autoloads (cons (concat (car path) | |
223 autoload-file-name) | |
224 autoloads))) | |
225 (setq path (cdr path))) | |
226 autoloads)) | |
227 | |
228 (defun packages-list-autoloads (source-directory) | |
229 "List autoload files in (what will be) the normal lisp search path. | |
230 This function is used during build to find where the global symbol files so | |
231 they can be perused for their useful information." | |
232 (let ((files (directory-files (file-name-as-directory source-directory) | |
233 t ".*")) | |
234 file autolist) | |
235 ;; (print (prin1-to-string source-directory)) | |
236 ;; (print (prin1-to-string files)) | |
237 (while (setq file (car-safe files)) | |
238 (if (and (file-directory-p file) | |
239 (file-exists-p (concat (file-name-as-directory file) | |
240 autoload-file-name))) | |
241 (setq autolist (cons (concat (file-name-as-directory file) | |
242 autoload-file-name) | |
243 autolist))) | |
244 (setq files (cdr files))) | |
245 autolist)) | |
246 | |
247 ;; The following function cannot be called from a bare temacs | |
248 (defun packages-new-autoloads () | |
249 "Return autoloads files that have been added or modified since XEmacs dump." | |
250 (require 'loadhist) | |
251 (let ((me (concat invocation-directory invocation-name)) | |
252 (path load-path) | |
253 result dir) | |
254 (while path | |
255 (setq dir (file-truename (car path))) | |
256 (let ((autoload-file (file-name-sans-extension (concat | |
257 dir | |
258 autoload-file-name)))) | |
259 ;; Check for: | |
260 ;; 1. An auto-autoload file that hasn't provided a feature (because | |
261 ;; it has been installed since XEmacs was dumped). | |
262 ;; 2. auto-autoload.el being newer than the executable | |
263 ;; 3. auto-autoload.elc being newer than the executable (the .el | |
264 ;; could be missing or compressed) | |
265 (when (or (and (null (file-provides autoload-file)) | |
266 (or (file-exists-p (concat autoload-file ".elc")) | |
267 (file-exists-p (concat autoload-file ".el")))) | |
268 (and (file-newer-than-file-p (concat autoload-file ".el") me) | |
269 (setq autoload-file (concat autoload-file ".el"))) | |
270 (and (file-newer-than-file-p (concat autoload-file | |
271 ".elc") | |
272 me) | |
273 (setq autoload-file (concat autoload-file ".elc")))) | |
274 (push autoload-file result))) | |
275 (setq path (cdr path))) | |
276 result)) | |
277 | |
278 ;; The following function cannot be called from a bare temacs | |
279 (defun packages-reload-autoloads () | |
280 "Reload new or updated auto-autoloads files. | |
281 This is an extremely dangerous function to call after the user-init-files | |
282 is run. Don't call it or you'll be sorry." | |
283 (let ((autoload-list (packages-new-autoloads))) | |
284 (while autoload-list | |
285 (let* ((autoload-file (car autoload-list)) | |
286 (feature (car-safe (file-provides autoload-file)))) | |
287 (when feature | |
288 ;; (message "(unload-feature %S)" feature) | |
289 (unload-feature feature)) | |
290 (condition-case nil | |
291 (load autoload-file) | |
292 (t nil))) | |
293 (setq autoload-list (cdr autoload-list))))) | |
294 | |
295 ;; Data-directory is really a list now. Provide something to search it for | |
296 ;; directories. | |
297 | |
298 (defun locate-data-directory-list (name &optional dir-list) | |
299 "Locate the matching list of directories in a search path DIR-LIST. | |
300 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
301 (unless dir-list | |
302 (setq dir-list data-directory-list)) | |
303 (let (found found-dir found-dir-list) | |
304 (while dir-list | |
305 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
306 found-dir (file-directory-p found)) | |
307 (and found-dir | |
308 (setq found-dir-list (cons found found-dir-list))) | |
309 (setq dir-list (cdr dir-list))) | |
310 (nreverse found-dir-list))) | |
311 | |
312 ;; Data-directory is really a list now. Provide something to search it for | |
313 ;; a directory. | |
314 | |
315 (defun locate-data-directory (name &optional dir-list) | |
316 "Locate a directory in a search path DIR-LIST (a list of directories). | |
317 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
318 (unless dir-list | |
319 (setq dir-list data-directory-list)) | |
320 (let (found found-dir) | |
321 (while (and (null found-dir) dir-list) | |
322 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
323 found-dir (file-directory-p found)) | |
324 (or found-dir | |
325 (setq found nil)) | |
326 (setq dir-list (cdr dir-list))) | |
327 found)) | |
328 | |
329 ;; Data-directory is really a list now. Provide something to search it for | |
330 ;; files. | |
331 | |
332 (defun locate-data-file (name &optional dir-list) | |
333 "Locate a file in a search path DIR-LIST (a list of directories). | |
334 If no DIR-LIST is supplied, it defaults to `data-directory-list'. | |
335 This function is basically a wrapper over `locate-file'." | |
633 | 336 (locate-file name (or dir-list data-directory-list))) |
428 | 337 |
338 ;; Path setup | |
339 | |
2456 | 340 (defun packages-find-package-hierarchies-named (package-directories base) |
341 "Find a set of package hierarchies within an XEmacs installation. | |
342 PACKAGE-DIRECTORIES is a list of package directories. | |
343 BASE is a subdirectory name for the hierarchy. | |
344 Returns list of hierarchies." | |
345 (paths-directories-which-exist | |
346 (mapcar #'(lambda (package-directory) | |
3179 | 347 (file-name-as-directory |
348 (concat (file-name-as-directory package-directory) | |
349 base))) | |
2456 | 350 package-directories))) |
428 | 351 |
352 (defun packages-split-path (path) | |
353 "Split PATH at \"\", return pair with two components. | |
354 The second component is shared with PATH." | |
355 (let ((reverse-tail '()) | |
356 (rest path)) | |
357 (while (and rest (null (string-equal "" (car rest)))) | |
358 (setq reverse-tail (cons (car rest) reverse-tail)) | |
359 (setq rest (cdr rest))) | |
360 (if (null rest) | |
361 (cons path nil) | |
362 (cons (nreverse reverse-tail) (cdr rest))))) | |
363 | |
364 (defun packages-split-package-path (package-path) | |
365 "Split up PACKAGE-PATH into early, late and last components. | |
366 The separation is by \"\" components. | |
2456 | 367 This returns |
368 (LIST EARLY-PACKAGE-HIERARCHIES LATE-PACKAGE-HIERARCHIES LAST-PACKAGE-HIERARCHIES)." | |
428 | 369 ;; When in doubt, it's late |
370 (let* ((stuff (packages-split-path package-path)) | |
371 (early (and (cdr stuff) (car stuff))) | |
372 (late+last (or (cdr stuff) (car stuff))) | |
373 (stuff (packages-split-path late+last)) | |
374 (late (car stuff)) | |
375 (last (cdr stuff))) | |
2456 | 376 (list (mapcar #'file-name-as-directory early) |
377 (mapcar #'file-name-as-directory late) | |
378 (mapcar #'file-name-as-directory last)))) | |
428 | 379 |
380 (defun packages-deconstruct (list consumer) | |
2456 | 381 "Deconstruct LIST and feed it to CONSUMER. |
382 CONSUMER is a function that accepts the elements of LISTS as separate arguments." | |
428 | 383 (apply consumer list)) |
384 | |
2456 | 385 (defun packages-find-installation-package-directories (roots) |
386 "Find the package directories in the XEmacs installation. | |
387 ROOTS is a list of installation roots." | |
4919
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
388 (union (paths-find-version-directories roots (list "") nil nil nil t) |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
389 (paths-find-site-directories roots (list "") nil) :test #'equal)) |
428 | 390 |
3179 | 391 (defun packages-find-package-hierarchies (package-directories &optional envvar default) |
2456 | 392 "Find package hierarchies in a list of package directories. |
393 PACKAGE-DIRECTORIES is a list of package directories. | |
3179 | 394 DEFAULT is a default list of package hierarchies. |
395 ENVVAR is the name of an environment variable that may override | |
396 the default." | |
397 (let* ((envvar-value (and envvar (getenv envvar))) | |
398 (package-directories | |
399 (if envvar-value | |
400 (split-path envvar-value) | |
401 package-directories))) | |
402 | |
403 (or (and (not envvar-value) default) | |
404 (let ((package-hierarchies '()) | |
405 (hierarchy-directories (packages-package-hierarchy-directory-names))) | |
406 (while hierarchy-directories | |
407 (setq package-hierarchies | |
408 (nconc package-hierarchies | |
409 (packages-find-package-hierarchies-named | |
410 package-directories | |
411 (car hierarchy-directories)))) | |
412 (setq hierarchy-directories (cdr hierarchy-directories))) | |
413 package-hierarchies)))) | |
2456 | 414 |
415 (defun packages-find-all-package-hierarchies (roots) | |
3179 | 416 "Find the package hierarchies. |
2456 | 417 ROOTS is a list of installation roots. |
418 Returns a list of three directory lists, the first being the list of early | |
419 hierarchies, the second that of the late hierarchies, and the third the | |
420 list of the last hierarchies." | |
3179 | 421 ;; EMACSPACKAGEPATH is a historical kludge |
428 | 422 (let ((envvar-value (getenv "EMACSPACKAGEPATH"))) |
3179 | 423 (cond |
424 (envvar-value | |
3184 | 425 (packages-deconstruct |
426 (packages-split-package-path (paths-decode-directory-path envvar-value)) | |
427 ;; we get package *directories* | |
428 #'(lambda (early late last) | |
429 (list | |
430 (packages-find-package-hierarchies early | |
431 "EMACSEARLYPACKAGES") | |
432 (packages-find-package-hierarchies late | |
433 "EMACSLATEPACKAGES") | |
434 (packages-find-package-hierarchies last | |
435 "EMACSLATEPACKAGES"))))) | |
436 ;; --with-package-path is also a historical kludge | |
3179 | 437 (configure-package-path |
428 | 438 (packages-deconstruct |
439 (packages-split-package-path configure-package-path) | |
3184 | 440 ;; we get package *hierarchies* |
3179 | 441 #'(lambda (early late last) |
2456 | 442 (list |
443 (packages-find-package-hierarchies (list user-init-directory) | |
3179 | 444 "EMACSEARLYPACKAGES" |
445 early) | |
2456 | 446 (packages-find-package-hierarchies (packages-find-installation-package-directories roots) |
3179 | 447 "EMACSLATEPACKAGES" |
448 | |
449 late) | |
2456 | 450 (packages-find-package-hierarchies '() |
3179 | 451 "EMACSLASTPACKAGES" |
452 last))))) | |
453 (t | |
454 (list | |
455 (packages-find-package-hierarchies (or configure-early-package-directories | |
456 (list user-init-directory)) | |
457 "EMACSEARLYPACKAGES") | |
458 (packages-find-package-hierarchies (or configure-late-package-directories | |
459 (packages-find-installation-package-directories roots)) | |
460 "EMACSLATEPACKAGES") | |
461 (packages-find-package-hierarchies configure-last-package-directories | |
462 "EMACSLASTPACKAGES")))))) | |
463 | |
2456 | 464 (defun packages-find-package-library-path (package-hierarchies suffixes) |
428 | 465 "Construct a path into a component of the packages hierarchy. |
2456 | 466 PACKAGE-HIERARCHIES is a list of package hierarchies. |
467 SUFFIXES is a list of names of hierarchy subdirectories to look for." | |
428 | 468 (let ((directories |
469 (apply | |
470 #'nconc | |
2456 | 471 (mapcar #'(lambda (hierarchy) |
428 | 472 (mapcar #'(lambda (suffix) |
2456 | 473 (file-name-as-directory (concat hierarchy suffix))) |
428 | 474 suffixes)) |
2456 | 475 package-hierarchies)))) |
428 | 476 (paths-directories-which-exist directories))) |
477 | |
2456 | 478 (defun packages-find-package-load-path (package-hierarchies) |
428 | 479 "Construct the load-path component for packages. |
2456 | 480 PACKAGE-HIERARCHIES is a list of package hierarchies." |
428 | 481 (paths-find-recursive-load-path |
2456 | 482 (packages-find-package-library-path package-hierarchies |
428 | 483 '("lisp")) |
484 packages-load-path-depth)) | |
485 | |
2456 | 486 (defun packages-find-package-exec-path (package-hierarchies) |
428 | 487 "Construct the exec-path component for packages. |
2456 | 488 PACKAGE-HIERARCHIES is a list of package hierarchies." |
489 (packages-find-package-library-path package-hierarchies | |
428 | 490 (list (paths-construct-path |
491 (list "bin" system-configuration)) | |
492 "lib-src"))) | |
493 | |
2456 | 494 (defun packages-find-package-info-path (package-hierarchies) |
428 | 495 "Construct the info-path component for packages. |
2456 | 496 PACKAGE-HIERARCHIES is a list of package directories." |
497 (packages-find-package-library-path package-hierarchies '("info"))) | |
428 | 498 |
2456 | 499 (defun packages-find-package-data-path (package-hierarchies) |
428 | 500 "Construct the data-path component for packages. |
2456 | 501 PACKAGE-HIERARCHIES is a list of package hierachies." |
428 | 502 (paths-find-recursive-load-path |
2456 | 503 (packages-find-package-library-path package-hierarchies |
428 | 504 '("etc")) |
505 packages-data-path-depth)) | |
506 | |
507 ;; Loading package initialization files | |
508 | |
509 (defun packages-load-package-lisps (package-load-path base) | |
510 "Load all Lisp files of a certain name along a load path. | |
511 BASE is the base name of the files." | |
512 (mapcar #'(lambda (dir) | |
793 | 513 (let ((file-name (expand-file-name base dir))) |
514 (with-trapping-errors | |
515 :operation (format "Autoload %s" file-name) | |
516 :class 'packages | |
517 (load file-name t t)))) | |
518 package-load-path)) | |
428 | 519 |
520 (defun packages-load-package-auto-autoloads (package-load-path) | |
521 "Load auto-autoload files along a load path." | |
522 (packages-load-package-lisps package-load-path | |
523 (file-name-sans-extension autoload-file-name))) | |
524 | |
525 (defun packages-handle-package-dumped-lisps (handle package-load-path) | |
526 "Load dumped-lisp.el files along a load path. | |
527 Call HANDLE on each file off definitions of PACKAGE-LISP there." | |
528 (mapcar #'(lambda (dir) | |
529 (let ((file-name (expand-file-name "dumped-lisp.el" dir))) | |
530 (if (file-exists-p file-name) | |
531 (let (package-lisp | |
532 ;; 20.4 packages could set this | |
533 preloaded-file-list) | |
534 (load file-name) | |
535 ;; dumped-lisp.el could have set this ... | |
536 (if package-lisp | |
537 (mapcar #'(lambda (base) | |
538 (funcall handle base)) | |
539 package-lisp)))))) | |
540 package-load-path)) | |
541 | |
542 (defun packages-load-package-dumped-lisps (package-load-path) | |
543 "Load dumped-lisp.el files along a load path. | |
444 | 544 Also load files off PACKAGE-LISP definitions there." |
428 | 545 (packages-handle-package-dumped-lisps #'load package-load-path)) |
546 | |
547 (defun packages-collect-package-dumped-lisps (package-load-path) | |
548 "Load dumped-lisp.el files along a load path. | |
444 | 549 Return list of files off PACKAGE-LISP definitions there." |
428 | 550 (let ((*files* '())) |
551 (packages-handle-package-dumped-lisps | |
552 #'(lambda (file) | |
553 (setq *files* (cons file *files*))) | |
554 package-load-path) | |
555 (reverse *files*))) | |
556 | |
557 (provide 'packages) | |
558 | |
559 ;;; packages.el ends here |