Mercurial > hg > xemacs-beta
annotate lisp/bytecomp-runtime.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 | 018e13fdeaeb |
children | 0d43872986b6 |
rev | line source |
---|---|
428 | 1 ;;; bytecomp-runtime.el --- byte-compiler support for inlining |
2 | |
3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc. | |
4949
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
4 ;; Copyright (C) 2002, 2010 Ben Wing. |
428 | 5 |
6 ;; Author: Jamie Zawinski <jwz@jwz.org> | |
7 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no> | |
8 ;; Maintainer: XEmacs Development Team | |
9 ;; Keywords: internal, dumped | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
13 ;; XEmacs is free software; you can redistribute it and/or modify it | |
14 ;; under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; XEmacs is distributed in the hope that it will be useful, but | |
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 ;; General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with XEmacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Synched up with: FSF 19.30. | |
29 | |
30 ;;; Commentary: | |
31 | |
32 ;; This file is dumped with XEmacs. | |
33 | |
34 ;; The code in this file should always be loaded, because it defines things | |
35 ;; like "defsubst" which should work interpreted as well. The code in | |
36 ;; bytecomp.el and byte-optimize.el can be loaded as needed. | |
37 | |
38 ;; interface to selectively inlining functions. | |
39 ;; This only happens when source-code optimization is turned on. | |
40 | |
41 ;;; Code: | |
42 | |
43 ;; Redefined in byte-optimize.el. | |
44 ;; This is not documented--it's not clear that we should promote it. | |
45 (fset 'inline 'progn) | |
46 (put 'inline 'lisp-indent-hook 0) | |
47 | |
48 | |
49 ;;; Interface to inline functions. | |
50 | |
51 ;; FSF comments the next two out, but I see no reason to do so. --ben | |
52 (defmacro proclaim-inline (&rest fns) | |
53 "Cause the named functions to be open-coded when called from compiled code. | |
54 They will only be compiled open-coded when `byte-optimize' is true." | |
55 (cons 'eval-and-compile | |
56 (apply | |
57 'nconc | |
58 (mapcar | |
59 #'(lambda (x) | |
60 `((or (memq (get ',x 'byte-optimizer) | |
61 '(nil byte-compile-inline-expand)) | |
62 (error | |
63 "%s already has a byte-optimizer, can't make it inline" | |
64 ',x)) | |
65 (put ',x 'byte-optimizer 'byte-compile-inline-expand))) | |
66 fns)))) | |
67 | |
68 | |
69 (defmacro proclaim-notinline (&rest fns) | |
70 "Cause the named functions to no longer be open-coded." | |
71 (cons 'eval-and-compile | |
72 (apply | |
73 'nconc | |
74 (mapcar | |
75 #'(lambda (x) | |
76 `((if (eq (get ',x 'byte-optimizer) | |
77 'byte-compile-inline-expand) | |
78 (put ',x 'byte-optimizer nil)))) | |
79 fns)))) | |
80 | |
81 ;; This has a special byte-hunk-handler in bytecomp.el. | |
82 (defmacro defsubst (name arglist &rest body) | |
83 "Define an inline function. The syntax is just like that of `defun'." | |
84 (or (memq (get name 'byte-optimizer) | |
85 '(nil byte-compile-inline-expand)) | |
86 (error "`%s' is a primitive" name)) | |
87 (list 'prog1 | |
88 (cons 'defun (cons name (cons arglist body))) | |
89 (list 'proclaim-inline name))) | |
90 ; Instead of the above line, FSF has this: | |
91 ; (list 'eval-and-compile | |
92 ; (list 'put (list 'quote name) | |
93 ; ''byte-optimizer ''byte-compile-inline-expand)))) | |
94 | |
2444 | 95 (defun make-obsolete (fn new &optional when) |
991 | 96 "Make the byte-compiler warn that function FN is obsolete. |
428 | 97 The warning will say that NEW should be used instead. |
2444 | 98 If NEW is a string, that is the `use instead' message. |
99 If provided, WHEN should be a string indicating when the function | |
100 was first made obsolete, for example a date or a release number." | |
428 | 101 (interactive "aMake function obsolete: \nxObsoletion replacement: ") |
102 (let ((handler (get fn 'byte-compile))) | |
103 (if (eq 'byte-compile-obsolete handler) | |
104 (setcar (get fn 'byte-obsolete-info) new) | |
105 (put fn 'byte-obsolete-info (cons new handler)) | |
106 (put fn 'byte-compile 'byte-compile-obsolete))) | |
107 fn) | |
108 | |
2444 | 109 (defun make-obsolete-variable (var new &optional when) |
991 | 110 "Make the byte-compiler warn that variable VAR is obsolete, |
428 | 111 and NEW should be used instead. If NEW is a string, then that is the |
2444 | 112 `use instead' message. |
113 If provided, WHEN should be a string indicating when the variable | |
114 was first made obsolete, for example a date or a release number." | |
428 | 115 (interactive |
116 (list | |
117 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) | |
118 (if (equal str "") (error "")) | |
119 (intern str)) | |
120 (car (read-from-string (read-string "Obsoletion replacement: "))))) | |
121 (put var 'byte-obsolete-variable new) | |
122 var) | |
123 | |
124 ;; By overwhelming demand, we separate out truly obsolete symbols from | |
125 ;; those that are present for GNU Emacs compatibility. | |
126 (defun make-compatible (fn new) | |
991 | 127 "Make the byte-compiler know that function FN is provided for compatibility. |
428 | 128 The warning will say that NEW should be used instead. |
129 If NEW is a string, that is the `use instead' message." | |
130 (interactive "aMake function compatible: \nxCompatible replacement: ") | |
131 (let ((handler (get fn 'byte-compile))) | |
132 (if (eq 'byte-compile-compatible handler) | |
133 (setcar (get fn 'byte-compatible-info) new) | |
134 (put fn 'byte-compatible-info (cons new handler)) | |
135 (put fn 'byte-compile 'byte-compile-compatible))) | |
136 fn) | |
137 | |
138 (defun make-compatible-variable (var new) | |
991 | 139 "Make the byte-compiler know that variable VAR is provided for compatibility, |
428 | 140 and NEW should be used instead. If NEW is a string, then that is the |
141 `use instead' message." | |
142 (interactive | |
143 (list | |
144 (let ((str (completing-read "Make variable compatible: " | |
145 obarray 'boundp t))) | |
146 (if (equal str "") (error "")) | |
147 (intern str)) | |
148 (car (read-from-string (read-string "Compatible replacement: "))))) | |
149 (put var 'byte-compatible-variable new) | |
150 var) | |
151 | |
152 (put 'dont-compile 'lisp-indent-hook 0) | |
153 (defmacro dont-compile (&rest body) | |
154 "Like `progn', but the body always runs interpreted (not compiled). | |
155 If you think you need this, you're probably making a mistake somewhere." | |
156 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) | |
157 | |
158 | |
159 ;;; interface to evaluating things at compile time and/or load time | |
160 ;;; these macro must come after any uses of them in this file, as their | |
161 ;;; definition in the file overrides the magic definitions on the | |
162 ;;; byte-compile-macro-environment. | |
163 | |
164 (put 'eval-when-compile 'lisp-indent-hook 0) | |
165 (defmacro eval-when-compile (&rest body) | |
166 "Like `progn', but evaluates the body at compile time. | |
167 The result of the body appears to the compiler as a quoted constant." | |
168 ;; Not necessary because we have it in b-c-initial-macro-environment | |
169 ;; (list 'quote (eval (cons 'progn body))) | |
170 (cons 'progn body)) | |
171 | |
172 (put 'eval-and-compile 'lisp-indent-hook 0) | |
173 (defmacro eval-and-compile (&rest body) | |
174 "Like `progn', but evaluates the body at compile time and at load time." | |
175 ;; Remember, it's magic. | |
176 (cons 'progn body)) | |
177 | |
178 ;;; From Emacs 20. | |
179 (put 'eval-when-feature 'lisp-indent-hook 1) | |
180 (defmacro eval-when-feature (feature &rest body) | |
181 "Run the body forms when FEATURE is featurep, be it now or later. | |
182 Called (eval-when-feature (FEATURE [. FILENAME]) BODYFORMS...). | |
183 If (featurep 'FEATURE), evals now; otherwise adds an elt to | |
184 `after-load-alist' (which see), using FEATURE as filename if FILENAME is nil." | |
185 (let ((file (or (cdr feature) (symbol-name (car feature))))) | |
186 `(let ((bodythunk #'(lambda () ,@body))) | |
187 (if (featurep ',(car feature)) | |
188 (funcall bodythunk) | |
189 (setq after-load-alist (cons '(,file . (list 'lambda '() bodythunk)) | |
190 after-load-alist)))))) | |
502 | 191 |
192 | |
193 | |
194 ;;; Functions to cleanly eliminate warnings about undefined functions | |
195 ;;; or variables when the code knows what it's doing. These macros DO | |
196 ;;; NOT rely on any byte-compiler changes, and thus can be copied into | |
197 ;;; a package and used within it. | |
198 | |
199 ;; NOTE: As a result of the above requirement, the macros rely on | |
200 ;; "tricks" to get the warnings suppressed. A cleaner way, of course, | |
201 ;; would be to extend the byte compiler to provide a proper interface. | |
202 | |
203 ;; #### Should we require an unquoted symbol rather than a quoted one, | |
204 ;; as we currently do? The quoting gets no generality, as `eval' is | |
205 ;; called at compile time. But most functions and macros want quoted | |
206 ;; arguments, and I find it extremely confusing to deal with cases | |
207 ;; such as `throw' requiring a quoted argument but `block' an unquoted | |
208 ;; one. | |
209 | |
210 (put 'with-boundp 'lisp-indent-function 1) | |
771 | 211 (defmacro with-boundp (variables &rest body) |
212 "Evaluate BODY, but do not issue bytecomp warnings about VARIABLES undefined. | |
213 VARIABLES can be a symbol or a list of symbols and must be quoted. When | |
214 compiling this file, the warnings `reference to free variable VARIABLE' and | |
215 `assignment to free variable VARIABLE' will not occur anywhere in BODY, for | |
216 any of the listed variables. This is a clean way to avoid such warnings. | |
776 | 217 |
218 See also `if-boundp', `when-boundp', and `and-boundp' (ways to | |
219 conditionalize on a variable being bound and avoid warnings), | |
220 `declare-boundp' (issue a variable call without warnings), and | |
221 `globally-declare-boundp' (avoid warnings throughout a file about a | |
222 variable)." | |
771 | 223 (setq variables (eval variables)) |
224 (unless (consp variables) | |
225 (setq variables (list variables))) | |
502 | 226 `(progn |
771 | 227 (declare (special ,@variables)) |
502 | 228 ,@body)) |
229 | |
230 (put 'if-boundp 'lisp-indent-function 2) | |
771 | 231 (defmacro if-boundp (variable then &rest else) |
232 "Equivalent to (if (boundp VARIABLE) THEN ELSE) but handles bytecomp warnings. | |
233 VARIABLE should be a quoted symbol. When compiling this file, the warnings | |
234 `reference to free variable VARIABLE' and `assignment to free variable | |
235 VARIABLE' will not occur anywhere in the if-statement. This is a clean way | |
776 | 236 to avoid such warnings. See also `with-boundp' and friends." |
771 | 237 `(with-boundp ,variable |
238 (if (boundp ,variable) ,then ,@else))) | |
502 | 239 |
771 | 240 (put 'when-boundp 'lisp-indent-function 1) |
241 (defmacro when-boundp (variable &rest body) | |
242 "Equivalent to (when (boundp VARIABLE) BODY) but handles bytecomp warnings. | |
243 VARIABLE should be a quoted symbol. When compiling this file, the warnings | |
244 `reference to free variable VARIABLE' and `assignment to free variable | |
245 VARIABLE' will not occur anywhere in the when-statement. This is a clean | |
776 | 246 way to avoid such warnings. See also `with-boundp' and friends." |
771 | 247 `(with-boundp ,variable |
248 (when (boundp ,variable) ,@body))) | |
249 | |
776 | 250 (put 'and-boundp 'lisp-indent-function 1) |
251 (defmacro and-boundp (variable &rest args) | |
252 "Equivalent to (and (boundp VARIABLE) ARGS) but handles bytecomp warnings. | |
253 VARIABLE should be a quoted symbol. When compiling this file, the warnings | |
254 `reference to free variable VARIABLE' and `assignment to free variable | |
255 VARIABLE' will not occur anywhere in the and-statement. This is a clean | |
256 way to avoid such warnings. See also `with-boundp' and friends." | |
257 `(with-boundp ,variable | |
258 (and (boundp ,variable) ,@args))) | |
259 | |
771 | 260 (defmacro declare-boundp (variable) |
261 "Evaluate VARIABLE without bytecomp warnings about the symbol. | |
262 | |
502 | 263 Sample usage is |
264 | |
265 (declare-boundp gpm-minor-mode) | |
266 | |
267 which is equivalent to | |
268 | |
771 | 269 (with-boundp 'gpm-minor-mode |
776 | 270 gpm-minor-mode) |
271 | |
272 See also `with-boundp' and friends." | |
771 | 273 `(with-boundp ',variable ,variable)) |
502 | 274 |
771 | 275 (defmacro globally-declare-boundp (variables) |
276 "Declare that all free uses of VARIABLES in this file are valid. | |
277 VARIABLES can be a symbol or a list of symbols and must be quoted. | |
502 | 278 |
771 | 279 When compiling this file, the warnings `reference to free variable |
280 VARIABLE' and `assignment to free variable VARIABLE' will not occur | |
281 regardless of where references to VARIABLE occur in the file. | |
502 | 282 |
776 | 283 In general, you should *NOT* use this; use `with-boundp' or its friends to |
284 wrap individual uses, as necessary. That way, you're more likely to | |
285 remember to put in the explicit checks for the variable's existence that | |
286 are usually necessary. However, `globally-declare-boundp' is better in | |
287 some circumstances, such as when writing an ELisp package that makes | |
288 integral use of optionally-compiled-in functionality (typically, an | |
289 interface onto a system library) and checks for the existence of the | |
290 functionality at some entry point to the package. See | |
291 `globally-declare-fboundp' for more information." | |
771 | 292 (setq variables (eval variables)) |
293 (if (not (consp variables)) | |
294 (setq variables (list variables))) | |
502 | 295 `(progn |
296 ;; (defvar FOO) has no side effects. | |
771 | 297 ,@(mapcar #'(lambda (sym) `(defvar ,sym)) variables))) |
502 | 298 |
299 (defun byte-compile-with-fboundp (form) | |
300 (byte-compile-form (cons 'progn (cdr (cdr form)))) | |
301 ;; Unfortunately, byte-compile-unresolved-functions is used not only | |
302 ;; for unresolved-function warnings, but also in connection with the | |
303 ;; following warnings: | |
304 | |
305 ;; "defsubst %s was used before it was defined" | |
306 ;; "%s being defined to take %s%s, but was previously called with %s" | |
307 | |
308 ;; By hacking byte-compile-unresolved-functions like this, we | |
309 ;; effectively disable these warnings. But code should not be using | |
310 ;; `with-fboundp' with a function defined later on in the same | |
311 ;; file, so this is not a big deal. | |
312 | |
313 (let ((symbols (eval (car (cdr form))))) | |
314 (unless (consp symbols) | |
315 (setq symbols (list symbols))) | |
316 (setq symbols (mapcar #'(lambda (sym) (cons sym nil)) symbols)) | |
317 (setq byte-compile-unresolved-functions | |
318 (set-difference byte-compile-unresolved-functions symbols | |
319 :key #'car)) | |
320 )) | |
321 | |
322 ;; EEEEEEEEVIL hack. We need to create our own byte-compilation | |
323 ;; method so that the proper variables are bound while compilation | |
324 ;; takes place (which is when the warnings get noticed and batched | |
325 ;; up). What we really want to do is make `with-fboundp' a macro | |
326 ;; that simply `progn's its BODY; but GOD DAMN IT, macros can't have | |
327 ;; their own byte-compilation methods! So we make `with-fboundp' a | |
328 ;; macro calling `with-fboundp-1', which is cleverly aliased to | |
329 ;; progn. This way we can put a byte-compilation method on | |
330 ;; `with-fboundp-1', and when interpreting, progn will duly skip | |
331 ;; the first, quoted argument, i.e. the symbol name. (We could make | |
332 ;; `with-fboundp-1' a regular function, but then we'd have to thunk | |
333 ;; BODY and eval it at runtime. We could probably just do this using | |
334 ;; (apply 'progn BODY), but the existing method is more obviously | |
335 ;; guaranteed to work.) | |
336 ;; | |
337 ;; In defense, cl-macs.el does a very similar thing with | |
338 ;; `cl-block-wrapper'. | |
339 | |
340 (put 'with-fboundp-1 'byte-compile 'byte-compile-with-fboundp) | |
341 (defalias 'with-fboundp-1 'progn) | |
342 | |
343 (put 'with-fboundp 'lisp-indent-function 1) | |
771 | 344 (defmacro with-fboundp (functions &rest body) |
345 "Evaluate BODY, but do not issue bytecomp warnings about FUNCTIONS undefined. | |
346 FUNCTIONS can be a symbol or a list of symbols and must be quoted. When | |
347 compiling this file, the warning `the function FUNCTION is not known to be | |
348 defined' will not occur anywhere in BODY, for any of the listed functions. | |
776 | 349 This is a clean way to avoid such warnings. |
350 | |
351 See also `if-fboundp', `when-fboundp', and `and-fboundp' (ways to | |
352 conditionalize on a function being bound and avoid warnings), | |
353 `declare-fboundp' (issue a function call without warnings), and | |
354 `globally-declare-fboundp' (avoid warnings throughout a file about a | |
355 function)." | |
771 | 356 `(with-fboundp-1 ,functions ,@body)) |
502 | 357 |
358 (put 'if-fboundp 'lisp-indent-function 2) | |
771 | 359 (defmacro if-fboundp (function then &rest else) |
360 "Equivalent to (if (fboundp FUNCTION) THEN ELSE) but handles bytecomp warnings. | |
361 FUNCTION should be a quoted symbol. When compiling this file, the warning | |
362 `the function FUNCTION is not known to be defined' will not occur anywhere | |
363 in the if-statement. This is a clean way to avoid such warnings. See also | |
776 | 364 `with-fboundp' and friends." |
771 | 365 `(with-fboundp ,function |
366 (if (fboundp ,function) ,then ,@else))) | |
367 | |
368 (put 'when-fboundp 'lisp-indent-function 1) | |
369 (defmacro when-fboundp (function &rest body) | |
370 "Equivalent to (when (fboundp FUNCTION) BODY) but handles bytecomp warnings. | |
371 FUNCTION should be a quoted symbol. When compiling this file, the warning | |
372 `the function FUNCTION is not known to be defined' will not occur anywhere | |
776 | 373 in the when-statement. This is a clean way to avoid such warnings. See also |
374 `with-fboundp' and friends." | |
771 | 375 `(with-fboundp ,function |
376 (when (fboundp ,function) ,@body))) | |
502 | 377 |
776 | 378 (put 'and-fboundp 'lisp-indent-function 1) |
379 (defmacro and-fboundp (function &rest args) | |
380 "Equivalent to (and (fboundp FUNCTION) ARGS) but handles bytecomp warnings. | |
381 FUNCTION should be a quoted symbol. When compiling this file, the warning | |
382 `the function FUNCTION is not known to be defined' will not occur anywhere | |
383 in the and-statement. This is a clean way to avoid such warnings. See also | |
384 `with-fboundp' and friends." | |
385 `(with-fboundp ,function | |
386 (and (fboundp ,function) ,@args))) | |
387 | |
502 | 388 (defmacro declare-fboundp (form) |
389 "Execute FORM (a function call) without bytecomp warnings about the call. | |
390 Sample usage is | |
391 | |
392 (declare-fboundp (x-keysym-on-keyboard-sans-modifiers-p 'backspace)) | |
393 | |
394 which is equivalent to | |
395 | |
396 (with-fboundp 'x-keysym-on-keyboard-sans-modifiers-p | |
776 | 397 (x-keysym-on-keyboard-sans-modifiers-p 'backspace)) |
398 | |
399 See also `with-fboundp' and friends." | |
502 | 400 `(with-fboundp ',(car form) ,form)) |
401 | |
771 | 402 (defmacro globally-declare-fboundp (functions) |
403 "Declare that all calls to function FUNCTIONS in this file are valid. | |
404 FUNCTIONS can be a symbol or a list of symbols and must be quoted. | |
502 | 405 |
771 | 406 When compiling this file, the warning `the function FUNCTION is not known |
407 to be defined' will not occur regardless of where calls to FUNCTION occur | |
408 in the file. | |
502 | 409 |
776 | 410 In general, you should *NOT* use this; use `with-fboundp' or its friends to |
411 wrap individual uses, as necessary. That way, you're more likely to | |
412 remember to put in the explicit checks for the function's existence that | |
413 are usually necessary. However, `globally-declare-fboundp' is better in | |
414 some circumstances, such as when writing an ELisp package that makes | |
415 integral use of optionally-compiled-in functionality (typically, an | |
416 interface onto a system library) and checks for the existence of the | |
417 functionality at some entry point to the package. The file `ldap.el' is a | |
418 good example: It provides a layer on top of the optional LDAP ELisp | |
419 primitives, makes calls to them throughout its code, and verifies the | |
420 presence of LDAP support at load time. Putting calls to `declare-fboundp' | |
421 throughout the code would be a major annoyance." | |
502 | 422 (when (cl-compiling-file) |
771 | 423 (setq functions (eval functions)) |
424 (if (not (consp functions)) | |
425 (setq functions (list functions))) | |
502 | 426 ;; Another hack. This works because the autoload environment is |
427 ;; currently used ONLY to suppress warnings, and the actual | |
428 ;; autoload definition is not used. (NOTE: With this definition, | |
429 ;; we will get spurious "multiple autoloads for %s" warnings if we | |
771 | 430 ;; have an autoload later in the file for any functions in FUNCTIONS. |
502 | 431 ;; This is not something that code should ever do, though.) |
432 (setq byte-compile-autoload-environment | |
771 | 433 (append (mapcar #'(lambda (sym) (cons sym nil)) functions) |
502 | 434 byte-compile-autoload-environment))) |
435 nil) | |
436 | |
437 (defun byte-compile-with-byte-compiler-warnings-suppressed (form) | |
438 (let ((byte-compile-warnings byte-compile-warnings) | |
439 (types (car (cdr form)))) | |
440 (unless (consp types) | |
441 (setq types (list types))) | |
442 (if (eq byte-compile-warnings t) | |
443 (setq byte-compile-warnings byte-compile-default-warnings)) | |
444 (setq byte-compile-warnings (set-difference byte-compile-warnings types)) | |
445 (byte-compile-form (cons 'progn (cdr (cdr form)))))) | |
446 | |
447 ;; Same hack here as with `with-fboundp'. | |
448 (put 'with-byte-compiler-warnings-suppressed-1 'byte-compile | |
449 'byte-compile-with-byte-compiler-warnings-suppressed) | |
450 (defalias 'with-byte-compiler-warnings-suppressed-1 'progn) | |
451 | |
452 (put 'with-byte-compiler-warnings-suppressed 'lisp-indent-function 1) | |
453 (defmacro with-byte-compiler-warnings-suppressed (type &rest body) | |
454 "Evaluate BODY, but do not issue bytecomp warnings TYPE. | |
455 TYPE should be one of `redefine', `callargs', `subr-callargs', | |
456 `free-vars', `unresolved', `unused-vars', `obsolete', or `pedantic', | |
457 or a list of one or more of these symbols. (See `byte-compile-warnings'.) | |
458 TYPE must be quoted. | |
459 | |
460 NOTE: You should *NOT* under normal circumstances be using this! | |
461 There are better ways of avoiding most of these warnings. In particular: | |
462 | |
463 -- use (declare (special ...)) if you are making use of | |
464 dynamically-scoped variables. | |
776 | 465 -- use `with-fboundp' and friends to avoid warnings about undefined functions |
771 | 466 when you know the function actually exists. |
776 | 467 -- use `with-boundp' and friends to avoid warnings about undefined variables |
771 | 468 when you know the variable actually exists. |
502 | 469 -- use `with-obsolete-variable' or `with-obsolete-function' if you |
470 are purposely using such a variable or function." | |
471 `(with-byte-compiler-warnings-suppressed-1 ,type ,@body)) | |
472 | |
473 ;; #### These should be more clever. You could (e.g.) try fletting | |
474 ;; `byte-compile-obsolete' or temporarily removing the obsolete info | |
475 ;; from the symbol and putting it back with an unwind-protect. (Or | |
476 ;; better, modify the byte-compiler to provide a proper solution, and | |
477 ;; fix these macros to use it if available, or fall back on the way | |
478 ;; below. Remember, these definitions need to work with an unchanged | |
479 ;; byte compiler so that they can be copied and used in packages.) | |
480 | |
481 (put 'with-obsolete-variable 'lisp-indent-function 1) | |
482 (defmacro with-obsolete-variable (symbol &rest body) | |
483 "Evaluate BODY but do not warn about usage of obsolete variable SYMBOL. | |
826 | 484 SYMBOL must be quoted and can be a list of SYMBOLS. See also |
485 `with-obsolete-function'." | |
502 | 486 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body)) |
487 | |
488 (put 'with-obsolete-function 'lisp-indent-function 1) | |
489 (defmacro with-obsolete-function (symbol &rest body) | |
490 "Evaluate BODY but do not warn about usage of obsolete function SYMBOL. | |
826 | 491 SYMBOL must be quoted and can be a list of SYMBOLS. See also |
492 `with-obsolete-variable'." | |
502 | 493 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body)) |
428 | 494 |
495 | |
4949
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
496 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
497 (defmacro error-unless-tests-match (test &optional source) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
498 "Signal an error unless TEST matches when being compiled and loaded. |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
499 This is for use in a file that will be byte-compiled. Unless TEST has the |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
500 same nilness or non-nilness when the file is compiled and loaded, an error |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
501 will be signalled. SOURCE is the name of the source file." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
502 (let ((source (eval source))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
503 `(unless (eq (not ,test) ,(not (eval test))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
504 (error ,(format "This file was compiled with `%s' %s, |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
505 but it was %s when run. This file needs to be compiled with |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
506 the same value for the expression as when it is run. Please delete |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
507 %s and rebuild." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
508 test (if (eval test) "true" "false") |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
509 (if (eval test) "false" "true") |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
510 (cond |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
511 ((null source) "the .elc for this file") |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
512 ((string-match "\.elc$" source) source) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
513 ((string-match "\.el$" source) (concat source "c")) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
514 (t (concat source ".elc")))))))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
515 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
516 (defun byte-compile-file-being-compiled () |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
517 "When byte-compiling a file, return the name of the file being compiled. |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
518 Return nil otherwise." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
519 (or |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
520 ;;The first of these, but not the second, seems to work noninteractively; |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
521 ;;vice-versa interactively. This is because interactively a *Compile Log* |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
522 ;;buffer is created and byte-compile-log-1 inserts a "Compiling file ..." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
523 ;;message into thelog buffer, and then sets byte-compile-current-file to |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
524 ;;nil to indicate that the message shouldn't be printed again. |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
525 (and-boundp 'byte-compile-current-file byte-compile-current-file) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
526 (and-boundp 'byte-compile-log-buffer |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
527 (with-current-buffer byte-compile-log-buffer |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
528 (save-excursion |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
529 (and (re-search-backward "Compiling file \\(.*\\) at " nil t) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
530 (match-string 1))))))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
531 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
532 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
533 (defmacro compiled-if (test if &rest else) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
534 "Like a regular `if' statement but the TEST will be evalled at compile time. |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
535 If TEST doesn't match at compile time and load time, an error will be |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
536 signalled." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
537 (let ((being-compiled (byte-compile-file-being-compiled))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
538 `(progn |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
539 (error-unless-tests-match ,test ,being-compiled) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
540 ,(if (eval test) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
541 if |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
542 `(progn ,else))))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
543 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
544 (defmacro compiled-when (test &rest when) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
545 "Like a regular `when' statement but the TEST will be evalled at compile time. |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
546 See `compiled-if'." |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
547 `(compiled-if ,test (progn ,@when))) |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
548 |
018e13fdeaeb
compile-related functions added, for use in Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
2444
diff
changeset
|
549 |
428 | 550 ;;; Interface to file-local byte-compiler parameters. |
551 ;;; Redefined in bytecomp.el. | |
552 | |
553 ;;; The great RMS speaketh: | |
554 ;;; | |
555 ;;; I nuked this because it's not a good idea for users to think of | |
556 ;;; using it. These options are a matter of installation preference, | |
557 ;;; and have nothing to do with particular source files; it's a | |
558 ;;; mistake to suggest to users that they should associate these with | |
559 ;;; particular source files. There is hardly any reason to change | |
560 ;;; these parameters, anyway. --rms. | |
561 ;;; | |
562 ;;; But I'll leave this stuff alone. --ben | |
563 | |
564 (put 'byte-compiler-options 'lisp-indent-hook 0) | |
565 (defmacro byte-compiler-options (&rest args) | |
566 "Set some compilation-parameters for this file. | |
567 This will affect only the file in which it appears; this does nothing when | |
568 evaluated, or when loaded from a .el file. | |
569 | |
570 Each argument to this macro must be a list of a key and a value. | |
571 | |
572 Keys: Values: Corresponding variable: | |
573 | |
574 verbose t, nil byte-compile-verbose | |
575 optimize t, nil, source, byte byte-optimize | |
576 warnings list of warnings byte-compile-warnings | |
577 file-format emacs19, emacs20 byte-compile-emacs19-compatibility | |
578 | |
579 The value specified with the `warnings' option must be a list, containing | |
580 some subset of the following flags: | |
581 | |
582 free-vars references to variables not in the current lexical scope. | |
583 unused-vars references to non-global variables bound but not referenced. | |
584 unresolved calls to unknown functions. | |
585 callargs lambda calls with args that don't match the definition. | |
502 | 586 subr-callargs calls to subrs with args that don't match the definition. |
428 | 587 redefine function cell redefined from a macro to a lambda or vice |
588 versa, or redefined to take a different number of arguments. | |
502 | 589 obsolete use of an obsolete function or variable. |
590 pedantic warn of use of compatible symbols. | |
428 | 591 |
592 If the first element if the list is `+' or `-' then the specified elements | |
593 are added to or removed from the current set of warnings, instead of the | |
594 entire set of warnings being overwritten. | |
595 | |
596 For example, something like this might appear at the top of a source file: | |
597 | |
598 (byte-compiler-options | |
599 (optimize t) | |
600 (warnings (- callargs)) ; Don't warn about arglist mismatch | |
601 (warnings (+ unused-vars)) ; Do warn about unused bindings | |
602 (file-format emacs19))" | |
603 nil) | |
604 | |
605 ;;; bytecomp-runtime.el ends here |