From 8f3a2c2659ddee1ae84b4b8bb28f6c388f87fd0f Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 5 Aug 2013 08:14:43 +0400 Subject: New macro to iterate over live buffers similar to frames. * buffer.h (FOR_EACH_LIVE_BUFFER): New macro. (Vbuffer_alist, Qpriority, Qbefore_string, Qafter_string): Declare buffer-related variables here to offload lisp.h. * buffer.c (Vbuffer_alist): Adjust comment. (Fget_file_buffer, get_truename_buffer, Fother_buffer) (other_buffer_safely): * data.c (store_symval_forwarding): * dispnew.c (Fframe_or_buffer_changed_p): * fileio.c (Fdo_auto_save): * filelock.c (unlock_all_files): * minibuf.c (read_minibuf): Use FOR_EACH_LIVE_BUFFER. --- src/buffer.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index dfc6b8bcc02..f9154d42b03 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -108,9 +108,9 @@ static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, static void swap_out_buffer_local_variables (struct buffer *b); static void reset_buffer_local_variables (struct buffer *, bool); -/* Alist of all buffer names vs the buffers. */ -/* This used to be a variable, but is no longer, - to prevent lossage due to user rplac'ing this alist or its elements. */ +/* Alist of all buffer names vs the buffers. This used to be + a Lisp-visible variable, but is no longer, to prevent lossage + due to user rplac'ing this alist or its elements. */ Lisp_Object Vbuffer_alist; static Lisp_Object Qkill_buffer_query_functions; @@ -478,8 +478,7 @@ If there is no such live buffer, return nil. See also `find-buffer-visiting'. */) (register Lisp_Object filename) { - register Lisp_Object tail, buf, tem; - Lisp_Object handler; + register Lisp_Object tail, buf, handler; CHECK_STRING (filename); filename = Fexpand_file_name (filename, Qnil); @@ -494,13 +493,10 @@ See also `find-buffer-visiting'. */) return BUFFERP (handled_buf) ? handled_buf : Qnil; } - for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) + FOR_EACH_LIVE_BUFFER (tail, buf) { - buf = Fcdr (XCAR (tail)); - if (!BUFFERP (buf)) continue; if (!STRINGP (BVAR (XBUFFER (buf), filename))) continue; - tem = Fstring_equal (BVAR (XBUFFER (buf), filename), filename); - if (!NILP (tem)) + if (!NILP (Fstring_equal (BVAR (XBUFFER (buf), filename), filename))) return buf; } return Qnil; @@ -509,15 +505,12 @@ See also `find-buffer-visiting'. */) Lisp_Object get_truename_buffer (register Lisp_Object filename) { - register Lisp_Object tail, buf, tem; + register Lisp_Object tail, buf; - for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) + FOR_EACH_LIVE_BUFFER (tail, buf) { - buf = Fcdr (XCAR (tail)); - if (!BUFFERP (buf)) continue; if (!STRINGP (BVAR (XBUFFER (buf), file_truename))) continue; - tem = Fstring_equal (BVAR (XBUFFER (buf), file_truename), filename); - if (!NILP (tem)) + if (!NILP (Fstring_equal (BVAR (XBUFFER (buf), file_truename), filename))) return buf; } return Qnil; @@ -1581,10 +1574,8 @@ exists, return the buffer `*scratch*' (creating it if necessary). */) } /* Consider alist of all buffers next. */ - tail = Vbuffer_alist; - for (; CONSP (tail); tail = XCDR (tail)) + FOR_EACH_LIVE_BUFFER (tail, buf) { - buf = Fcdr (XCAR (tail)); if (candidate_buffer (buf, buffer) /* If the frame has a buffer_predicate, disregard buffers that don't fit the predicate. */ @@ -1621,12 +1612,9 @@ other_buffer_safely (Lisp_Object buffer) { Lisp_Object tail, buf; - for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) - { - buf = Fcdr (XCAR (tail)); - if (candidate_buffer (buf, buffer)) - return buf; - } + FOR_EACH_LIVE_BUFFER (tail, buf) + if (candidate_buffer (buf, buffer)) + return buf; buf = Fget_buffer (build_string ("*scratch*")); if (NILP (buf)) -- cgit v1.2.1 From e30b79c1c52a4428189ca148c73e7ecc993c6f6a Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 6 Aug 2013 10:53:09 +0400 Subject: Use region cache to speedup bidi_find_paragraph_start. * src/buffer.h (struct buffer): New member bidi_paragraph_cache. Rename cache_long_line_scans to cache_long_scans. * src/buffer.c (bset_cache_long_line_scans): Rename to bset_cache_long_scans. (Fget_buffer_create, Fmake_indirect_buffer, Fkill_buffer) (Fbuffer_swap_text, init_buffer_once): Take bidi_paragraph_cache into account. (syms_of_buffer): Rename cache-long-line-scans to cache-long-scans. Adjust docstring. * src/search.c (newline_cache_on_off): * src/indent.c (width_run_cache_on_off): Adjust users. * src/bidi.c (bidi_paragraph_cache_on_off): New function. (bidi_find_paragraph_start): Use bidi_paragraph_cache if needed. * src/insdel.c (prepare_to_modify_buffer): Invalidate bidi_paragraph_cache if enabled. * doc/lispref/positions.texi (Motion by Screen Lines): * doc/lispref/display.texi (Truncation): Rename `cache-long-line-scans' to `cache-long-scans'. --- src/buffer.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index f9154d42b03..339175d9078 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -203,9 +203,9 @@ bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) b->INTERNAL_FIELD (buffer_file_coding_system) = val; } static void -bset_cache_long_line_scans (struct buffer *b, Lisp_Object val) +bset_cache_long_scans (struct buffer *b, Lisp_Object val) { - b->INTERNAL_FIELD (cache_long_line_scans) = val; + b->INTERNAL_FIELD (cache_long_scans) = val; } static void bset_case_fold_search (struct buffer *b, Lisp_Object val) @@ -583,6 +583,7 @@ even if it is dead. The return value is never nil. */) b->newline_cache = 0; b->width_run_cache = 0; + b->bidi_paragraph_cache = 0; bset_width_table (b, Qnil); b->prevent_redisplay_optimizations_p = 1; @@ -806,6 +807,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) b->newline_cache = 0; b->width_run_cache = 0; + b->bidi_paragraph_cache = 0; bset_width_table (b, Qnil); name = Fcopy_sequence (name); @@ -1945,6 +1947,11 @@ cleaning up all windows currently displaying the buffer to be killed. */) free_region_cache (b->width_run_cache); b->width_run_cache = 0; } + if (b->bidi_paragraph_cache) + { + free_region_cache (b->bidi_paragraph_cache); + b->bidi_paragraph_cache = 0; + } bset_width_table (b, Qnil); unblock_input (); bset_undo_list (b, Qnil); @@ -2355,6 +2362,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; swapfield (newline_cache, struct region_cache *); swapfield (width_run_cache, struct region_cache *); + swapfield (bidi_paragraph_cache, struct region_cache *); current_buffer->prevent_redisplay_optimizations_p = 1; other_buffer->prevent_redisplay_optimizations_p = 1; swapfield (overlays_before, struct Lisp_Overlay *); @@ -5169,7 +5177,7 @@ init_buffer_once (void) bset_buffer_file_coding_system (&buffer_defaults, Qnil); XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); - bset_cache_long_line_scans (&buffer_defaults, Qnil); + bset_cache_long_scans (&buffer_defaults, Qnil); bset_file_truename (&buffer_defaults, Qnil); XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); @@ -5233,7 +5241,7 @@ init_buffer_once (void) XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx; - XSETFASTINT (BVAR (&buffer_local_flags, cache_long_line_scans), idx); ++idx; + XSETFASTINT (BVAR (&buffer_local_flags, cache_long_scans), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx; @@ -6120,8 +6128,8 @@ If the value of the variable is t, undo information is not recorded. */); DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil, doc: /* Non-nil means the mark and region are currently active in this buffer. */); - DEFVAR_PER_BUFFER ("cache-long-line-scans", &BVAR (current_buffer, cache_long_line_scans), Qnil, - doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly. + DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR (current_buffer, cache_long_scans), Qnil, + doc: /* Non-nil means that Emacs should use caches in attempt to speedup buffer scans. Normally, the line-motion functions work by scanning the buffer for newlines. Columnar operations (like `move-to-column' and @@ -6131,18 +6139,24 @@ buffer's lines are very long (say, more than 500 characters), these motion functions will take longer to execute. Emacs may also take longer to update the display. -If `cache-long-line-scans' is non-nil, these motion functions cache the +If `cache-long-scans' is non-nil, these motion functions cache the results of their scans, and consult the cache to avoid rescanning regions of the buffer until the text is modified. The caches are most beneficial when they prevent the most searching---that is, when the buffer contains long lines and large regions of characters with the same, fixed screen width. -When `cache-long-line-scans' is non-nil, processing short lines will +When `cache-long-scans' is non-nil, processing short lines will become slightly slower (because of the overhead of consulting the cache), and the caches will use memory roughly proportional to the number of newlines and characters whose screen width varies. +Bidirectional editing also requires buffer scans to find paragraph +separators. If you have large paragraphs or no paragraph separators +at all, these scans may be slow. If `cache-long-scans' is non-nil, +results of these scans are cached. This doesn't help too much if +paragraphs are of the reasonable (few thousands of characters) size. + The caches require no explicit maintenance; their accuracy is maintained internally by the Emacs primitives. Enabling or disabling the cache should not affect the behavior of any of the motion -- cgit v1.2.1 From d2a95ffb4eeed87b00c9ac1c8eec7d39b06226e5 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 7 Aug 2013 17:21:59 +0400 Subject: Prefer selected_window to Fselected_window, likewise for frames. * buffer.c (Fbuffer_swap_text): * data.c (Fvariable_binding_locus): * window.c (run_window_configuration_change_hook): Adjust users. * w16select.c (Fw16_set_clipboard_data, Fw16_get_clipboard_data): Use decode_live_frame. --- src/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 339175d9078..ce4b44c87c3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2409,7 +2409,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, live window points to that window's buffer. So since we just swapped the markers between the two buffers, we need to undo the effect of this swap for window markers. */ - Lisp_Object w = Fselected_window (), ws = Qnil; + Lisp_Object w = selected_window, ws = Qnil; Lisp_Object buf1, buf2; XSETBUFFER (buf1, current_buffer); XSETBUFFER (buf2, other_buffer); -- cgit v1.2.1 From 7d652d97681c4f1b67018f44f64c619ef5edd990 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 10 Aug 2013 18:30:20 -0700 Subject: Omit some unnecessary casts. Many of these go back to the old pre-C89 days, when they may have been needed, but we've been assuming C89 or later for a while now. * alloc.c (live_string_p, live_cons_p, live_symbol_p) (live_float_p, live_misc_p, live_vector_p): * buffer.c (compare_overlays, cmp_for_strings, mmap_find) (mmap_alloc, alloc_buffer_text, enlarge_buffer_text) (defvar_per_buffer): * callint.c (Fcall_interactively): * doc.c (Fsubstitute_command_keys): * filelock.c (get_boot_time): * frame.c (xrdb_get_resource): * gtkutil.c (hierarchy_ch_cb, qttip_cb, style_changed_cb) (delete_cb, xg_dialog_response_cb, xg_maybe_add_timer) (xg_get_file_name_from_selector, menuitem_destroy_callback) (menuitem_highlight_callback, menu_destroy_callback) (xg_update_menu_item, xg_modify_menubar_widgets, menubar_map_cb) (xg_tool_bar_callback, xg_get_tool_bar_widgets) (xg_tool_bar_detach_callback, xg_tool_bar_attach_callback) (xg_tool_bar_help_callback, tb_size_cb): * image.c (xpm_alloc_color, png_read_from_memory) (png_read_from_file, png_load_body, our_memory_skip_input_data) (jpeg_memory_src, jpeg_file_src, imagemagick_load_image) (syms_of_image): * keymap.c (describe_map): * nsfns.m (Fns_display_monitor_attributes_list): * nsmenu.m (process_dialog:): * nsterm.m (hold_event): * process.c (wait_reading_process_output): * regex.c (REGEX_REALLOCATE, re_set_registers, re_exec, regexec): * scroll.c (do_direct_scrolling, scrolling_1): * termcap.c (tgetent): * window.c (check_window_containing, add_window_to_list) (freeze_window_starts): * xdisp.c (compare_overlay_entries, vmessage): * xfns.c (x_window, x_get_monitor_attributes_xinerama) (x_get_monitor_attributes_xrandr) (Fx_display_monitor_attributes_list, x_display_info_for_name) (Fx_open_connection, file_dialog_cb, file_dialog_unmap_cb): * xfont.c (xfont_match, xfont_open): * xmenu.c (x_menu_wait_for_event, menu_highlight_callback) (menubar_selection_callback, menu_position_func) (popup_selection_callback, create_and_show_popup_menu) (dialog_selection_callback, create_and_show_dialog): * xrdb.c (x_get_string_resource): (main) [TESTRM]: * xsmfns.c (x_session_check_input): * xterm.c (x_draw_glyphless_glyph_string_foreground) (xm_scroll_callback, xg_scroll_callback, xg_end_scroll_callback) (xaw_jump_callback, xaw_scroll_callback): Omit unnecessary casts. --- src/buffer.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index ce4b44c87c3..5244b7043dc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3146,8 +3146,8 @@ struct sortvec static int compare_overlays (const void *v1, const void *v2) { - const struct sortvec *s1 = (const struct sortvec *) v1; - const struct sortvec *s2 = (const struct sortvec *) v2; + const struct sortvec *s1 = v1; + const struct sortvec *s2 = v2; if (s1->priority != s2->priority) return s1->priority < s2->priority ? -1 : 1; if (s1->beg != s2->beg) @@ -3253,8 +3253,8 @@ static ptrdiff_t overlay_str_len; static int cmp_for_strings (const void *as1, const void *as2) { - struct sortstr *s1 = (struct sortstr *)as1; - struct sortstr *s2 = (struct sortstr *)as2; + struct sortstr const *s1 = as1; + struct sortstr const *s2 = as2; if (s1->size != s2->size) return s2->size < s1->size ? -1 : 1; if (s1->priority != s2->priority) @@ -4752,7 +4752,7 @@ static struct mmap_region * mmap_find (void *start, void *end) { struct mmap_region *r; - char *s = (char *) start, *e = (char *) end; + char *s = start, *e = end; for (r = mmap_regions; r; r = r->next) { @@ -4911,7 +4911,7 @@ mmap_alloc (void **var, size_t nbytes) } else { - struct mmap_region *r = (struct mmap_region *) p; + struct mmap_region *r = p; r->nbytes_specified = nbytes; r->nbytes_mapped = map; @@ -5051,7 +5051,7 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) memory_full (nbytes); } - b->text->beg = (unsigned char *) p; + b->text->beg = p; unblock_input (); } @@ -5079,7 +5079,7 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) memory_full (nbytes); } - BUF_BEG_ADDR (b) = (unsigned char *) p; + BUF_BEG_ADDR (b) = p; unblock_input (); } @@ -5397,11 +5397,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, bo_fwd->predicate = predicate; sym->declared_special = 1; sym->redirect = SYMBOL_FORWARDED; - { - /* I tried to do the job without a cast, but it seems impossible. - union Lisp_Fwd *fwd; &(fwd->u_buffer_objfwd) = bo_fwd; */ - SET_SYMBOL_FWD (sym, (union Lisp_Fwd *)bo_fwd); - } + SET_SYMBOL_FWD (sym, (union Lisp_Fwd *) bo_fwd); XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym); if (PER_BUFFER_IDX (offset) == 0) -- cgit v1.2.1 From 70ff8240e489fc5ff8635a415b78b8881054dc23 Mon Sep 17 00:00:00 2001 From: Xue Fuqiao Date: Sat, 17 Aug 2013 06:32:24 +0800 Subject: Another doc fix for `buffer-undo-list'. --- src/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 5244b7043dc..58530248abc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -6106,7 +6106,7 @@ An entry (apply FUN-NAME . ARGS) means undo the change with An entry (apply DELTA BEG END FUN-NAME . ARGS) supports selective undo in the active region. BEG and END is the range affected by this entry -and DELTA is the number of bytes added or deleted in that range by +and DELTA is the number of characters added or deleted in that range by this change. An entry (MARKER . DISTANCE) indicates that the marker MARKER -- cgit v1.2.1 From 43aac990c339c0fc3304aa476ebc8ea8467f107e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 27 Aug 2013 11:47:55 -0700 Subject: Simplify EMACS_TIME-related code. This portability layer is no longer needed, since Emacs has been using struct timespec as a portability layer for some time. Merge from gnulib, incorporating: 2013-08-27 timespec: new convenience constants and function * src/atimer.h, src/buffer.h, src/dispextern.h, src/xgselect.h: Include rather than "systime.h"; that's all that's needed now. * src/dispnew.c: Include rather than "systime.h"; that's all that's needed now. * src/systime.h (EMACS_TIME): Remove. All uses changed to struct timespec. (EMACS_TIME_RESOLUTION): Remove. All uses changed to TIMESPEC_RESOLUTION. (LOG10_EMACS_TIME_RESOLUTION): Remove. All uses changed to LOG10_TIMESPEC_RESOLUTION. (EMACS_SECS, emacs_secs_addr): Remove. All uses changed to tv_sec. (EMACS_NSECS): Remove. All uses changed to tv_nsec. (make_emacs_time): Remove. All used changed to make_timespec. (invalid_timespec): Rename from invalid_emacs_time. All uses changed. (current_timespec): Rename from current_emacs_time. All uses changed. (add_emacs_time): Remove. All uses changed to timespec_add. (sub_emacs_time): Remove. All uses change dot timespec_sub. (EMACS_TIME_SIGN): Remove. All uses changed to timespec_sign. (timespec_valid_p): Rename from EMACS_TIME_VALID_P. All uses changed. (EMACS_TIME_FROM_DOUBLE): Remove. All uses changed to dtotimespec. (EMACS_TIME_TO_DOUBLE): Remove. All uses changed to timespectod. (current_timespec): Rename from current_emacs_time. All uses changed. (EMACS_TIME_EQ, EMACS_TIME_LT, EMACS_TIME_LE): Remove. All uses changed to timespec_cmp. * src/xgselect.c: Include , since our .h files don't. --- src/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 58530248abc..7bc98a8b1d3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -933,7 +933,7 @@ reset_buffer (register struct buffer *b) bset_filename (b, Qnil); bset_file_truename (b, Qnil); bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil); - b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); + b->modtime = make_timespec (0, UNKNOWN_MODTIME_NSECS); b->modtime_size = -1; XSETFASTINT (BVAR (b, save_length), 0); b->last_window_start = 1; -- cgit v1.2.1 From 6bdcbfe1e33fa27b7c19042de6b0f69be12aad45 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 28 Aug 2013 12:33:12 +0400 Subject: * buffer.c (Foverlays_at, Foverlays_in, Fnext_overlay_change) (Fprevious_overlay_change): Fast path for buffer with no overlays. --- src/buffer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 7bc98a8b1d3..1495bd65de7 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4161,6 +4161,9 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return Qnil; + len = 10; /* We can't use alloca here because overlays_at can call xrealloc. */ overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4193,6 +4196,9 @@ end of the buffer. */) CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); + if (!buffer_has_overlays ()) + return Qnil; + len = 10; overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4221,6 +4227,9 @@ the value is (point-max). */) CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return make_number (ZV); + len = 10; overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4260,6 +4269,9 @@ the value is (point-min). */) CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return make_number (BEGV); + /* At beginning of buffer, we know the answer; avoid bug subtracting 1 below. */ if (XINT (pos) == BEGV) -- cgit v1.2.1 From b1cf96dec798e85874002803d16f9848b73d4f70 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 3 Sep 2013 17:29:38 +0400 Subject: * buffer.c (Fmake_overlay, Fmove_overlay): * intervals.c (set_point_from_marker): * print.c (PRINTPREPARE): Prefer signal_error to plain error and report unsuitable marker too. --- src/buffer.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 1495bd65de7..c811890aefe 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3834,7 +3834,8 @@ for the front of the overlay advance when text is inserted there The fifth arg REAR-ADVANCE, if non-nil, makes the marker for the rear of the overlay advance when text is inserted there \(which means the text *is* included in the overlay). */) - (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, Lisp_Object front_advance, Lisp_Object rear_advance) + (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, + Lisp_Object front_advance, Lisp_Object rear_advance) { Lisp_Object overlay; struct buffer *b; @@ -3843,12 +3844,11 @@ for the rear of the overlay advance when text is inserted there XSETBUFFER (buffer, current_buffer); else CHECK_BUFFER (buffer); - if (MARKERP (beg) - && ! EQ (Fmarker_buffer (beg), buffer)) - error ("Marker points into wrong buffer"); - if (MARKERP (end) - && ! EQ (Fmarker_buffer (end), buffer)) - error ("Marker points into wrong buffer"); + + if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer)) + signal_error ("Marker points into wrong buffer", beg); + if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer)) + signal_error ("Marker points into wrong buffer", end); CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); @@ -3974,12 +3974,10 @@ buffer. */) if (NILP (Fbuffer_live_p (buffer))) error ("Attempt to move overlay to a dead buffer"); - if (MARKERP (beg) - && ! EQ (Fmarker_buffer (beg), buffer)) - error ("Marker points into wrong buffer"); - if (MARKERP (end) - && ! EQ (Fmarker_buffer (end), buffer)) - error ("Marker points into wrong buffer"); + if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer)) + signal_error ("Marker points into wrong buffer", beg); + if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer)) + signal_error ("Marker points into wrong buffer", end); CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); -- cgit v1.2.1 From bc923770d292650f38458a220343929b9973ba90 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 3 Sep 2013 18:40:09 +0400 Subject: * buffer.c (drop_overlay): * fileio.c (restore_point_unwind): Prefer unchain_marker to Fset_marker (X, Qnil, ...) (which is the same but a bit slower). --- src/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index c811890aefe..0bcb608dbd3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -888,8 +888,8 @@ drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) eassert (b == XBUFFER (Fmarker_buffer (ov->start))); modify_overlay (b, marker_position (ov->start), marker_position (ov->end)); - Fset_marker (ov->start, Qnil, Qnil); - Fset_marker (ov->end, Qnil, Qnil); + unchain_marker (XMARKER (ov->start)); + unchain_marker (XMARKER (ov->end)); } -- cgit v1.2.1