comparison lisp/bytecomp.el @ 502:7039e6323819

[xemacs-hg @ 2001-05-04 22:41:46 by ben] ----------------------- byte-comp warning fixes ----------------- New functions for cleanly eliminating byte-compiler warnings. Their definitions require no changes at all in bytecomp.el, meaning that any package that wants to use them and be compatible with older versions of XEmacs need only copy the code and rename the functions (i.e. prefix them with the package name). Eliminate byte-compiler warnings using the new functions in bytecomp-runtime.el. Move coding-system-put,get,category, since they're not Mule-specific and are used in prefer-coding-system. font.el was incredibly ugly. Clean it up. Avoid using defsubst for any exported functions, to avoid possible compatibility problems if we later change the internal interface. (It happened before, with face accessors, between 19.8 and 19.9). Fix tons of warnings. Clean up (new function gpm-is-supported-p eliminates duplicate code in gpm-create/delete-device-hook) and eliminate warnings. ---------- make byte-recompile-directory work in the --------- core `lisp' dir, even in the absence of a Mule XEmacs (i.e. make it skip the Mule files rather than trying to compile them). now you should be able to do `touch *.el' in the `lisp' dir, then M-x byte-recompile-directory, and get no warnings. Avoid trying to compile Mule files in byte-recompile-directory when we're not in a Mule XEmacs, since we're highly likely to get syntax errors. Add a coding-system cookie to all Mule files so that byte-recompile-directory ignores them. Magic cookie function moved to files.el from code-files.el (for use by bytecomp even in a non-coding-system XEmacs), and changed names and semantics for use by bytecomp. NOTE: IMO this is an internal function that we can change as we like (and there is absolutely no code anywhere else using the function). ---------------- GUI improvements: menus, help ------------------- Rearrange order of keymap declarations to be alphabetical. Improve help on help to include all bindings, and group by category. Add bindings for new Info commands. Remove warnings. Use command-hyper-apropos in place of command-apropos. Add a function to do the equivalent of command-apropos. Evals its help-text argument so you can put expressions there. Used now by help-for-help. Add binding to continue text searches. Expand index searches to work over multiple info documents. Add commands to search text/index in User and Lispref. Add new entry, "Uncomment Region" (parallels "Comment Out Region"). Redo Help menu; add bindings for new Info commands to search the index or text of the User and Lispref manuals. Add command for mark-paragraph, activate-region. Make Edit->R accelerator be rectangle, not register (more commonly used), and put rectangle first. Fix the Edit Init File entry to never load the .elc file. Simplify the default-popup-menu. Add Cmds->Tabs menu. Use kp-left not kp_left, etc. ---------------- Miscellaneous bug fixes/cleanup ------------------- byte-compiler-options: Correct doc string. easy-menu-do-define: fix extra quote. fill-paragraph-or-region:Rewrite to be more correct -- use call-interactively so that we always get exactly the same behavior as if the functions were called directly. No need to fiddle with zmacs-region-stays, now that bogus clearing of it (2001-04-28 src/ChangeLog) is removed. Put dialog titles back in -- this time correctly. Fix various other problems with leaks and such. key-sequence-list-description: Clean up fun to always correctly canonicalize. Clean up Kinsoku comments, synch comment-region with FSF 20.7. * simple.el (region-exists-p): * simple.el (region-active-p): Add comment about which one is correct to use in menu specs. * sound.el (load-sound-file): Minor code clean up. * startup.el: * startup.el (command-line-early): * startup.el (initial-scratch-message): Comment changes. Add info about sample.init.el to splash screen. Improve initial-scratch-message and clarify purpose of Scratch buffer. Fix byte-compile warning. ------------------------ Added features ------------------------- Add new variable to control whether etags checks all parent directories for tag files. (On by default.) * hash-table.el: New file, useful utility functions. * dumped-lisp.el (preloaded-file-list): Dump hash-table.el. ------------ notable bug fix: Windows event code -------------- Get critical quit working. ------------ notable bug fix and new feature: regex code -------------- Shy groups were implemented in a horrible, half-assed way that would cause them to screw up regex searching in most cases. Fixed to work correctly. Also extended back-reference syntax past 9. Only is recognized as such if there are at least that many non-shy groups; and optionally will warn about such uses, to catch old code that might be using them differently. (Added variable to control this in search.c -- `warn-about-possibly-incompatible-back- references', on by default for the moment. Declared in lisp.h. ---------------- process/SIGIO improvements ------------------- define USE_GETADDRINFO to replace more complex conditional, and use it. the code conditionalized on this in unix_open_network_stream had *serious* problems handling errors. it's now fixed, and major amounts of duplicate code between the two versions were combined. don't disable SIGIO and other interrupts unless CONNECT_NEEDS_SLOWED_INTERRUPTS is defined -- don't penalize OS's without bugs. similarly for a freebsd bug that was affecting all OS's. * s\ultrix.h: define CONNECT_NEEDS_SLOWED_INTERRUPTS, since that's the OS mentioned as having a kernel bug. * sysdep.c (request_sigio_on_device): * sysdep.c (unrequest_sigio_on_device): fix SIGIO problems on Linux. add check for O_ASYNC in case it's defined and FASYNC isn't. add comment about other ways to do SIGIO on Linux. * callproc.c (Fold_call_process_internal): * process.c (Fstart_process_internal): Deal with the possibility that `default-directory' doesn't have terminating slash. Correct comments about vfork. ---------------- Miscellaneous bug fixes/cleanup ------------------- * callint.c (Finteractive): Add lots of documentation -- exactly what the Lisp equivalents of all the interactive specs are. * console.h (struct console): change type of quit_char to Emchar. * event-msw.c (lstream_type_create_mswindows_selectable): spacing change. Eliminate events-mod.h and combine into events.h. * emacs.c: * emacs.c (make_arg_list_1): * emacs.c (main_1): A couple of char->Extbyte changes, add a comment. * glyphs-msw.c: Correct indentation of function defns to not exceed 80 cols. Try (sort of) to fix some code that sets the colors of the progress gauge. (Commented out) * keymap.c (syms_of_keymap): use DEFSYMBOL. * process.c (read_process_output): No need to fiddle with zmacs_region_stays, now that bogus clearing of it (see below) is removed. * search.c (Freplace_match): warning fix.
author ben
date Fri, 04 May 2001 22:42:35 +0000
parents 1ccc32a20af4
children 2b0ea82d329f
comparison
equal deleted inserted replaced
501:0a255b32b157 502:7039e6323819
418 418
419 (defvar byte-recompile-directory-ignore-errors-p nil 419 (defvar byte-recompile-directory-ignore-errors-p nil
420 "If true, then `byte-recompile-directory' will continue compiling even 420 "If true, then `byte-recompile-directory' will continue compiling even
421 when an error occurs in a file. This is bound to t by 421 when an error occurs in a file. This is bound to t by
422 `batch-byte-recompile-directory'.") 422 `batch-byte-recompile-directory'.")
423
424 (defvar byte-recompile-ignore-uncompilable-mule-files t
425 "If non-nil, `byte-recompile-*' ignores non-ASCII .el files in a non-Mule
426 XEmacs. This assumes that such files have a -*- coding: ??? -*- magic
427 cookie in their first line or a ;;;###coding system: magic cookie
428 early in the file.")
423 429
424 (defvar byte-recompile-directory-recursively t 430 (defvar byte-recompile-directory-recursively t
425 "*If true, then `byte-recompile-directory' will recurse on subdirectories.") 431 "*If true, then `byte-recompile-directory' will recurse on subdirectories.")
426 432
427 (defvar byte-compile-constants nil 433 (defvar byte-compile-constants nil
941 (concat "file " byte-compile-current-file) 947 (concat "file " byte-compile-current-file)
942 (concat "buffer " (buffer-name byte-compile-current-file))) 948 (concat "buffer " (buffer-name byte-compile-current-file)))
943 " at " (current-time-string) "\n") 949 " at " (current-time-string) "\n")
944 (setq byte-compile-current-file nil)))) 950 (setq byte-compile-current-file nil))))
945 951
952 (defvar byte-compile-inbuffer)
953 (defvar byte-compile-outbuffer)
954
946 (defun byte-compile-warn (format &rest args) 955 (defun byte-compile-warn (format &rest args)
947 (setq format (apply 'format format args)) 956 (setq format (apply 'format format args))
948 (if byte-compile-error-on-warn 957 (if byte-compile-error-on-warn
949 (error "%s" format) ; byte-compile-file catches and logs it 958 (error "%s" format) ; byte-compile-file catches and logs it
950 (byte-compile-log-1 (concat "** " format) t) 959 (byte-compile-log-1 (concat "** " format) t)
960
961 ;; This was a first attempt to add line numbers to the
962 ;; byte-compilation output. Unfortunately, it doesn't work
963 ;; perfectly: it reports the line number at the end of the form
964 ;; (which may be an entire function), rather than the line number
965 ;; of the actual problem. Doing this right is hard because we
966 ;; currently use the built-in Lisp parser to parse the entire form
967 ;; at once. What we basically need is a whole separate parser
968 ;; that annotates its output with line numbers. For example, we
969 ;; might modify the parser in lread.c so that, with the right
970 ;; option set, it replaces every Lisp object contained in the
971 ;; structure it returns with a cons of that object and the line
972 ;; number it was found on (determined by counting newlines,
973 ;; starting from some arbitrary point). You then have two
974 ;; options: (a) Modify the byte compiler so that everything that
975 ;; compiles a form deals with the new annotated form rather than
976 ;; the old one, or (b) The byte compiler saves this structure
977 ;; while converting it into a normal structure that's given to the
978 ;; various form handlers, which need no (or less) modification.
979 ;; In the former case, finding the line number is trivial because
980 ;; it's in the form. In the latter case, finding the line number
981 ;; depends on having a unique Lisp object that can be looked up in
982 ;; the annotated structure -- i.e. a list, vector, or string.
983 ;; You'd have to look at the various places where errors are spit
984 ;; out (not very many, really), and make sure that such a unique
985 ;; object is available. Then you do a depth-first search through
986 ;; the annotated structure to find the object.
987 ;;
988 ;; An alternative way of doing (b) that's probably much more
989 ;; efficient (and easier to implement) is simply to have the
990 ;; parser in lread.c annotate every unique object using a separate
991 ;; hash table. This also eliminates the need for a search to find
992 ;; the line number. In order to be fine-grained enough to get at
993 ;; every symbol in a form -- e.g. if we want to pinpoint a
994 ;; particular undefined variable in a function call -- we need to
995 ;; annotate every cons, not just each list. We still have
996 ;; (probably unimportant) problems with vectors, since all we have
997 ;; is the start of the vector. If we cared about this, we could
998 ;; store in the hash table a list of the line numbers for each
999 ;; item in the vector, not just its start.
1000 ;;
1001 ;; --ben
1002
1003 ; (byte-compile-log-1 (concat "** line: "
1004 ; (save-excursion
1005 ; (set-buffer byte-compile-inbuffer)
1006 ; (int-to-string (line-number)))
1007 ; " "
1008 ; format) t)
951 ;;; RMS says: 1009 ;;; RMS says:
952 ;;; It is useless to flash warnings too fast to be read. 1010 ;;; It is useless to flash warnings too fast to be read.
953 ;;; Besides, they will all be shown at the end. 1011 ;;; Besides, they will all be shown at the end.
954 ;;; and comments out the next two lines. 1012 ;;; and comments out the next two lines.
955 (or noninteractive ; already written on stdout. 1013 (or noninteractive ; already written on stdout.
1434 (setq directories 1492 (setq directories
1435 (nconc directories (list source)))) 1493 (nconc directories (list source))))
1436 ;; It is an ordinary file. Decide whether to compile it. 1494 ;; It is an ordinary file. Decide whether to compile it.
1437 (if (and (string-match emacs-lisp-file-regexp source) 1495 (if (and (string-match emacs-lisp-file-regexp source)
1438 (not (auto-save-file-name-p source)) 1496 (not (auto-save-file-name-p source))
1497 ;; make sure not a mule file we can't handle.
1498 (or (not byte-recompile-ignore-uncompilable-mule-files)
1499 (featurep 'mule)
1500 (not (find-coding-system-magic-cookie-in-file
1501 source)))
1439 (setq dest (byte-compile-dest-file source)) 1502 (setq dest (byte-compile-dest-file source))
1440 (if (file-exists-p dest) 1503 (if (file-exists-p dest)
1441 ;; File was already compiled. 1504 ;; File was already compiled.
1442 (or force (file-newer-than-file-p source dest)) 1505 (or force (file-newer-than-file-p source dest))
1443 ;; No compiled file exists yet. 1506 ;; No compiled file exists yet.
1478 (setq dest (byte-compile-dest-file filename)) 1541 (setq dest (byte-compile-dest-file filename))
1479 (if (file-exists-p dest) 1542 (if (file-exists-p dest)
1480 (file-newer-than-file-p filename dest) 1543 (file-newer-than-file-p filename dest)
1481 (and force 1544 (and force
1482 (or (eq 0 force) 1545 (or (eq 0 force)
1483 (y-or-n-p (concat "Compile " filename "? ")))))) 1546 (y-or-n-p (concat "Compile " filename "? ")))))
1547 (or (not byte-recompile-ignore-uncompilable-mule-files)
1548 (featurep 'mule)
1549 (not (find-coding-system-magic-cookie-in-file filename))))
1484 (byte-compile-file filename)))) 1550 (byte-compile-file filename))))
1485 1551
1486 ;;;###autoload 1552 ;;;###autoload
1487 (defun byte-compile-file (filename &optional load) 1553 (defun byte-compile-file (filename &optional load)
1488 "Compile a file of Lisp code named FILENAME into a file of byte code. 1554 "Compile a file of Lisp code named FILENAME into a file of byte code.
1619 (cond (arg 1685 (cond (arg
1620 (message "Compiling from buffer... done.") 1686 (message "Compiling from buffer... done.")
1621 (prin1 value (current-buffer)) 1687 (prin1 value (current-buffer))
1622 (insert "\n")) 1688 (insert "\n"))
1623 ((message "%s" (prin1-to-string value))))))) 1689 ((message "%s" (prin1-to-string value)))))))
1624
1625 (defvar byte-compile-inbuffer)
1626 (defvar byte-compile-outbuffer)
1627 1690
1628 (defun byte-compile-from-buffer (byte-compile-inbuffer filename &optional eval) 1691 (defun byte-compile-from-buffer (byte-compile-inbuffer filename &optional eval)
1629 ;; buffer --> output-buffer, or buffer --> eval form, return nil 1692 ;; buffer --> output-buffer, or buffer --> eval form, return nil
1630 (let (byte-compile-outbuffer 1693 (let (byte-compile-outbuffer
1631 ;; Prevent truncation of flonums and lists as we read and print them 1694 ;; Prevent truncation of flonums and lists as we read and print them