Chong Yidong [Tue, 7 Jun 2011 18:32:12 +0000 (14:32 -0400)]
Some changes and re-organization for animated gif support.
* lisp/image.el (image-animate-max-time): Moved to image-mode.el.
(create-animated-image): Remove unnecessary function.
(image-animate): Rename from image-animate-start. New arg.
(image-animate-stop): Removed; just use image-animate-timer.
(image-animate-timer): Use car-safe.
(image-animate-timeout): Rename argument.
* lisp/image-mode.el (image-toggle-animation): New command.
(image-mode-map): Bind it to RET.
(image-mode): Update message.
(image-toggle-display-image): Avoid a spurious cache flush.
(image-transform-rotation): Doc fix.
(image-transform-properties): Return quickly in the normal case.
(image-animate-loop): Rename from image-animate-max-time.
Martin Rudalics [Tue, 7 Jun 2011 13:23:08 +0000 (15:23 +0200)]
Move get-lru-window and get-largest-window to window.el.
* window.c (window_loop): Remove handling of GET_LRU_WINDOW and
GET_LARGEST_WINDOW.
(Fget_lru_window, Fget_largest_window): Move to window.el.
* window.el (get-lru-window, get-largest-window): Move here from
window.c. Rename first argument to ALL-FRAMES. Rephrase
doc-strings.
(get-buffer-window-list): Rewrite using window-list-1. Rephrase
doc-string.
Martin Rudalics [Tue, 7 Jun 2011 12:51:07 +0000 (14:51 +0200)]
Make delete_all_subwindows argument a Lisp_Object.
* window.c (delete_window, Fset_window_configuration): Call
delete_all_subwindows with window as argument.
(delete_all_subwindows): Take a window as argument and not a
structure. Rewrite.
* window.h: delete_all_subwindows now takes a Lisp_Object as
argument.
* frame.c (delete_frame): Call delete_all_subwindows with root
window as argument.
Martin Rudalics [Mon, 6 Jun 2011 13:57:49 +0000 (15:57 +0200)]
Move some window-related functions from frame.c to window.c.
* lisp.h: Move EXFUNS for Fframe_root_window,
Fframe_first_window and Fset_frame_selected_window to window.h.
* window.h: Move EXFUNS for Fframe_root_window,
Fframe_first_window and Fset_frame_selected_window here from
lisp.h.
* frame.c (Fwindow_frame, Fframe_first_window)
(Fframe_root_window, Fframe_selected_window)
(Fset_frame_selected_window): Move to window.c.
(Factive_minibuffer_window): Move to minibuf.c.
(Fother_visible_frames_p): New function.
* minibuf.c (Factive_minibuffer_window): Move here from frame.c.
* window.c (Fwindow_frame): Move here from frame.c. Accept any
window as argument.
(Fframe_root_window, Fframe_first_window)
(Fframe_selected_window): Move here from frame.c. Accept frame
or arbitrary window as argument. Update doc-strings.
(Fminibuffer_window): Move up in code.
(Fwindow_minibuffer_p): Move up in code and simplify.
(Fset_frame_selected_window): Move here from frame.c. Marginal
rewrite.
(Fselected_window, select_window, Fselect_window): Move up in
code. Minor doc-string fixes.
Paul Eggert [Mon, 6 Jun 2011 08:29:01 +0000 (01:29 -0700)]
Check for overflow when converting integer to cons and back.
* charset.c (Fdefine_charset_internal, Fdecode_char):
Use cons_to_unsigned to catch overflow.
(Fencode_char): Use INTEGER_TO_CONS.
* composite.h (LGLYPH_CODE): Use cons_to_unsigned.
(LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
* data.c (long_to_cons, cons_to_long): Remove.
(cons_to_unsigned, cons_to_signed): New functions.
These signal an error for invalid or out-of-range values.
* dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
* fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
* font.c (Ffont_variation_glyphs):
* fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
* lisp.h: Include <intprops.h>.
(INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
(cons_to_signed, cons_to_unsigned): New decls.
(long_to_cons, cons_to_long): Remove decls.
* undo.c (record_first_change): Use INTEGER_TO_CONS.
(Fprimitive_undo): Use CONS_TO_INTEGER.
* xfns.c (Fx_window_property): Likewise.
* xselect.c: Include <limits.h>.
(x_own_selection, selection_data_to_lisp_data):
Use INTEGER_TO_CONS.
(x_handle_selection_request, x_handle_selection_clear)
(x_get_foreign_selection, Fx_disown_selection_internal)
(Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
(lisp_data_to_selection_data): Use cons_to_unsigned.
(x_fill_property_data): Use cons_to_signed.
Report values out of range.
Paul Eggert [Mon, 6 Jun 2011 06:16:12 +0000 (23:16 -0700)]
Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro.
* lisp.h (STRING_BYTES_MAX): New macro.
* alloc.c (Fmake_string):
* character.c (string_escape_byte8):
* coding.c (coding_alloc_by_realloc):
* doprnt.c (doprnt):
* editfns.c (Fformat):
* eval.c (verror):
Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
since they may not be the same number.
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents):
Likewise for BUF_BYTES_MAX.
Paul Eggert [Mon, 6 Jun 2011 06:10:06 +0000 (23:10 -0700)]
* image.c: Use ptrdiff_t, not int, for sizes.
(slurp_file): Switch from int to ptrdiff_t.
All uses changed.
(slurp_file): Check that file size fits in both size_t (for
malloc) and ptrdiff_t (for sanity and safety).
Paul Eggert [Mon, 6 Jun 2011 05:50:29 +0000 (22:50 -0700)]
Don't assume time_t can fit into int.
* buffer.h (struct buffer.modtime): Now time_t, not int.
* fileio.c (Fvisited_file_modtime): No need for time_t cast now.
* undo.c (Fprimitive_undo): Use time_t, not int, for time_t value.
Paul Eggert [Mon, 6 Jun 2011 05:48:28 +0000 (22:48 -0700)]
Minor fixes for signed vs unsigned integers.
* character.h (MAYBE_UNIFY_CHAR):
* charset.c (maybe_unify_char):
* keyboard.c (read_char, reorder_modifiers):
XINT -> XFASTINT, since the integer must be nonnegative.
* ftfont.c (ftfont_spec_pattern):
* keymap.c (access_keymap, silly_event_symbol_error):
XUINT -> XFASTINT, since the integer must be nonnegative.
(Fsingle_key_description, preferred_sequence_p): XUINT -> XINT,
since it makes no difference and we prefer signed.
* keyboard.c (record_char): Use XUINT when all the neighbors do.
(access_keymap): NATNUMP -> INTEGERP, since the integer must be
nonnegative.
* net/tramp-ftp.el:
* net/tramp-sh.el:
* net/tramp-smb.el: Set `tramp-autoload' cookie, and eval after
load "tramp.el" `tramp-set-completion-function'.
Stefan Monnier [Sat, 4 Jun 2011 12:31:34 +0000 (09:31 -0300)]
* lisp/shell.el: Require and use pcomplete.
(shell-dynamic-complete-functions): Add pcomplete-completions-at-point.
(shell-completion-vars): Set pcomplete-default-completion-function.
Eli Zaretskii [Sat, 4 Jun 2011 07:41:44 +0000 (10:41 +0300)]
Support bidi reordering of text covered by display properties.
src/bidi.c (bidi_copy_it): Use offsetof instead of emulating it.
(bidi_fetch_char, bidi_fetch_char_advance): New functions.
(bidi_cache_search, bidi_cache_iterator_state)
(bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak)
(bidi_level_of_next_char, bidi_move_to_visually_next): Support
character positions inside a run of characters covered by a
display string.
(bidi_paragraph_init, bidi_resolve_explicit_1)
(bidi_level_of_next_char): Call bidi_fetch_char and
bidi_fetch_char_advance instead of FETCH_CHAR and
FETCH_CHAR_ADVANCE.
(bidi_init_it): Initialize new members.
(LRE_CHAR, RLE_CHAR, PDF_CHAR, LRO_CHAR, RLO_CHAR): Remove macro
definitions.
(bidi_explicit_dir_char): Lookup character type in bidi_type_table,
instead of using explicit *_CHAR codes.
(bidi_resolve_explicit, bidi_resolve_weak): Use
FETCH_MULTIBYTE_CHAR instead of FETCH_CHAR, as reordering of
bidirectional text is supported only in multibyte buffers.
(bidi_init_it): Accept additional argument FRAME_WINDOW_P and use
it to initialize the frame_window_p member of struct bidi_it.
(bidi_cache_iterator_state, bidi_resolve_explicit_1)
(bidi_resolve_explicit, bidi_resolve_weak)
(bidi_level_of_next_char, bidi_move_to_visually_next): Abort if
bidi_it->nchars is non-positive.
(bidi_level_of_next_char): Don't try to lookup the cache for the
next/previous character if nothing is cached there yet, or if we
were just reseat()'ed to a new position.
src/xdisp.c (set_cursor_from_row): Set start and stop points
according to the row's direction when priming the loop that looks
for the glyph on which to display cursor.
(single_display_spec_intangible_p): Function deleted.
(display_prop_intangible_p): Reimplement to call
handle_display_spec instead of single_display_spec_intangible_p.
Accept 3 additional arguments needed by handle_display_spec. This
fixes incorrect cursor motion across display property with complex
values: lists, `(when COND...)' forms, etc.
(single_display_spec_string_p): Support property values that are
lists with the argument STRING its top-level element.
(display_prop_string_p): Fix the condition for processing a
property that is a list to be consistent with handle_display_spec.
(handle_display_spec): New function, refactored from the
last portion of handle_display_prop.
(compute_display_string_pos): Accept additional argument
FRAME_WINDOW_P. Call handle_display_spec to determine whether the
value of a `display' property is a "replacing spec".
(handle_single_display_spec): Accept 2 additional arguments BUFPOS
and FRAME_WINDOW_P. If IT is NULL, don't set up the iterator from
the display property, but just return a value indicating whether
the display property will replace the characters it covers.
(Fcurrent_bidi_paragraph_direction): Initialize the nchars and
frame_window_p members of struct bidi_it.
(compute_display_string_pos, compute_display_string_end): New
functions.
(push_it): Accept second argument POSITION, where pop_it should
jump to continue iteration.
(reseat_1): Initialize bidi_it.disp_pos.
src/keyboard.c (adjust_point_for_property): Adjust the call to
display_prop_intangible_p to its new signature.
src/dispextern.h (struct bidi_it): New member frame_window_p.
(bidi_init_it): Update prototypes.
(display_prop_intangible_p): Update prototype.
(compute_display_string_pos, compute_display_string_end): Declare
prototypes.
(struct bidi_it): New members nchars and disp_pos. ch_len is now
EMACS_INT.
Paul Eggert [Sat, 4 Jun 2011 02:49:51 +0000 (19:49 -0700)]
Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro.
* lisp.h (STRING_BYTES_MAX): New macro.
* alloc.c (Fmake_string):
* character.c (string_escape_byte8):
* coding.c (coding_alloc_by_realloc):
* doprnt.c (doprnt):
* editfns.c (Fformat):
* eval.c (verror):
Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
since they may not be the same number.
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents):
Likewise for BUF_BYTES_MAX.
Paul Eggert [Sat, 4 Jun 2011 02:02:36 +0000 (19:02 -0700)]
Use ptrdiff_t, not int, for sizes.
* image.c (slurp_file): Switch from int to ptrdiff_t.
All uses changed.
(slurp_file, svg_load): Check that file size fits in both
size_t (for malloc) and ptrdiff_t (for sanity and safety).
Paul Eggert [Fri, 3 Jun 2011 19:02:25 +0000 (12:02 -0700)]
Check for overflow when converting integer to cons and back.
* charset.c (Fdefine_charset_internal, Fdecode_char):
Use cons_to_unsigned to catch overflow.
(Fencode_char): Use INTEGER_TO_CONS.
* composite.h (LGLYPH_CODE): Use cons_to_unsigned.
(LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
* data.c (long_to_cons, cons_to_long): Remove.
(cons_to_unsigned, cons_to_signed): New functions.
These signal an error for invalid or out-of-range values.
* dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
* fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
* font.c (Ffont_variation_glyphs):
* fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
* lisp.h (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
(cons_to_signed, cons_to_unsigned): New decls.
(long_to_cons, cons_to_long): Remove decls.
* undo.c (record_first_change): Use INTEGER_TO_CONS.
(Fprimitive_undo): Use CONS_TO_INTEGER.
* xfns.c (Fx_window_property): Likewise.
* xselect.c (x_own_selection, selection_data_to_lisp_data):
Use INTEGER_TO_CONS.
(x_handle_selection_request, x_handle_selection_clear)
(x_get_foreign_selection, Fx_disown_selection_internal)
(Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
(lisp_data_to_selection_data): Use cons_to_unsigned.
(x_fill_property_data): Use cons_to_signed. Report values out of range.
Paul Eggert [Fri, 3 Jun 2011 18:42:59 +0000 (11:42 -0700)]
Fix doc for machines with wider system times such as time_t.
On such machines, it's now safe to assume that EMACS_INT is as
wide as the system times, so that shifting right by 16 will
result in an integer that always fits in EMACS_INT.
* dired.c (Ffile_attributes): Document large inode number handling.
* termhooks.h: Fix comment for large time stamp handling.
Paul Eggert [Fri, 3 Jun 2011 18:12:45 +0000 (11:12 -0700)]
Don't assume time_t can fit into int.
* buffer.h (struct buffer.modtime): Now time_t, not int.
* fileio.c (Fvisited_file_modtime): No need for time_t cast now.
* undo.c (Fprimitive_undo): Use time_t, not int, for time_t value.
Paul Eggert [Fri, 3 Jun 2011 18:11:17 +0000 (11:11 -0700)]
Minor fixes for signed vs unsigned integers.
* character.h (MAYBE_UNIFY_CHAR):
* charset.c (maybe_unify_char):
* keyboard.c (read_char, reorder_modifiers):
XINT -> XFASTINT, since the integer must be nonnegative.
* ftfont.c (ftfont_spec_pattern):
* keymap.c (access_keymap, silly_event_symbol_error):
XUINT -> XFASTINT, since the integer must be nonnegative.
(Fsingle_key_description, preferred_sequence_p): XUINT -> XINT,
since it makes no difference and we prefer signed.
* keyboard.c (record_char): Use XUINT when all the neighbors do.
(access_keymap): NATNUMP -> INTEGERP, since the integer must be
nonnegative.
Paul Eggert [Thu, 2 Jun 2011 06:15:15 +0000 (23:15 -0700)]
Don't assume time_t can fit into int.
* buffer.h (struct buffer.modtime): Now time_t, not int.
* fileio.c (Fvisited_file_modtime): No need for time_t cast now.
* undo.c (Fprimitive_undo): Use time_t, not int, for time_t value.