aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2013-10-29 12:11:50 -0400
committerStefan Monnier2013-10-29 12:11:50 -0400
commit3472b6c682817242f8b6134dea06a6ce4777e419 (patch)
tree5e1fb55e804a07a91ad431b95b1e168df0ea7bf1 /src
parent2d9783e0b938d0e3550fee7efbb3c6b8b5f18462 (diff)
downloademacs-3472b6c682817242f8b6134dea06a6ce4777e419.tar.gz
emacs-3472b6c682817242f8b6134dea06a6ce4777e419.zip
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support. (rectangle-mark): New command. (rectangle--region): New var. (deactivate-mark-hook): Reset rectangle--region. (rectangle--extract-region, rectangle--insert-for-yank) (rectangle--highlight-for-redisplay) (rectangle--unhighlight-for-redisplay): New functions. (region-extract-function, redisplay-unhighlight-region-function) (redisplay-highlight-region-function): Use them to handle rectangular region. * lisp/simple.el (region-extract-function): New var. (delete-backward-char, delete-forward-char, deactivate-mark): Use it. (kill-new, kill-append): Remove obsolete `yank-handler' argument. (kill-region): Replace obsolete `yank-handler' arg with `region'. (copy-region-as-kill, kill-ring-save): Add `region' argument. (redisplay-unhighlight-region-function) (redisplay-highlight-region-function): New vars. (redisplay--update-region-highlight): New function. (pre-redisplay-function): Use it. (exchange-point-and-mark): Don't deactivate the mark before reactivate-it anyway. * lisp/comint.el (comint-kill-region): Remove yank-handler argument. * lisp/delsel.el (delete-backward-char, backward-delete-char-untabify) (delete-char): Remove property, since it's now part of their default behavior. (self-insert-iso): Remove property since this command doesn't exist. * src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function. (syms_of_xdisp): Declare pre-redisplay-function. (markpos_of_region): Remove function. (init_iterator, compute_stop_pos, handle_face_prop) (face_before_or_after_it_pos, reseat_to_string) (get_next_display_element, window_buffer_changed) (redisplay_internal, try_cursor_movement, redisplay_window) (try_window_reusing_current_matrix, try_window_id, display_line) (note_mode_line_or_margin_highlight, note_mouse_highlight) (display_string, mouse_face_from_buffer_pos): Remove region handling. * src/window.h (struct window): Remove field `region_showing'. * src/dispextern.h (struct it): Remove region_beg/end_charpos. (face_at_buffer_position, face_for_overlay_string) (face_at_string_position): Update prototypes. * src/xfaces.c (face_at_buffer_position, face_for_overlay_string) (face_at_string_position): Remove `region_beg' and `region_end' args. * src/fontset.c (Finternal_char_font): * src/font.c (font_at, font_range): Adjust calls accordingly. * src/insdel.c (Qregion_extract_function): New var. (syms_of_insdel): Initialize it. (prepare_to_modify_buffer_1): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog24
-rw-r--r--src/dispextern.h11
-rw-r--r--src/font.c6
-rw-r--r--src/fontset.c2
-rw-r--r--src/insdel.c11
-rw-r--r--src/window.h4
-rw-r--r--src/xdisp.c155
-rw-r--r--src/xfaces.c44
8 files changed, 70 insertions, 187 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 287215392db..06e71e33fde 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,27 @@
12013-10-29 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
4 (syms_of_xdisp): Declare pre-redisplay-function.
5 (markpos_of_region): Remove function.
6 (init_iterator, compute_stop_pos, handle_face_prop)
7 (face_before_or_after_it_pos, reseat_to_string)
8 (get_next_display_element, window_buffer_changed)
9 (redisplay_internal, try_cursor_movement, redisplay_window)
10 (try_window_reusing_current_matrix, try_window_id, display_line)
11 (note_mode_line_or_margin_highlight, note_mouse_highlight)
12 (display_string, mouse_face_from_buffer_pos): Remove region handling.
13 * window.h (struct window): Remove field `region_showing'.
14 * dispextern.h (struct it): Remove region_beg/end_charpos.
15 (face_at_buffer_position, face_for_overlay_string)
16 (face_at_string_position): Update prototypes.
17 * xfaces.c (face_at_buffer_position, face_for_overlay_string)
18 (face_at_string_position): Remove `region_beg' and `region_end' args.
19 * fontset.c (Finternal_char_font):
20 * font.c (font_at, font_range): Adjust calls accordingly.
21 * insdel.c (Qregion_extract_function): New var.
22 (syms_of_insdel): Initialize it.
23 (prepare_to_modify_buffer_1): Use it.
24
12013-10-29 Dmitry Antipov <dmantipov@yandex.ru> 252013-10-29 Dmitry Antipov <dmantipov@yandex.ru>
2 26
3 Prefer 'unsigned long' to 'long unsigned int' and 'unsigned long int'. 27 Prefer 'unsigned long' to 'long unsigned int' and 'unsigned long int'.
diff --git a/src/dispextern.h b/src/dispextern.h
index 0d225e9616f..dd64ae1921f 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2214,10 +2214,6 @@ struct it
2214 used for overlay strings and strings from display properties. */ 2214 used for overlay strings and strings from display properties. */
2215 ptrdiff_t string_nchars; 2215 ptrdiff_t string_nchars;
2216 2216
2217 /* Start and end of a visible region; -1 if the region is not
2218 visible in the window. */
2219 ptrdiff_t region_beg_charpos, region_end_charpos;
2220
2221 /* Position at which redisplay end trigger functions should be run. */ 2217 /* Position at which redisplay end trigger functions should be run. */
2222 ptrdiff_t redisplay_end_trigger_charpos; 2218 ptrdiff_t redisplay_end_trigger_charpos;
2223 2219
@@ -3325,7 +3321,7 @@ void init_baud_rate (int);
3325void init_sigio (int); 3321void init_sigio (int);
3326void ignore_sigio (void); 3322void ignore_sigio (void);
3327 3323
3328/* Defined in xfaces.c */ 3324/* Defined in xfaces.c. */
3329 3325
3330#ifdef HAVE_X_WINDOWS 3326#ifdef HAVE_X_WINDOWS
3331void unload_color (struct frame *, unsigned long); 3327void unload_color (struct frame *, unsigned long);
@@ -3352,16 +3348,13 @@ void init_frame_faces (struct frame *);
3352void free_frame_faces (struct frame *); 3348void free_frame_faces (struct frame *);
3353void recompute_basic_faces (struct frame *); 3349void recompute_basic_faces (struct frame *);
3354int face_at_buffer_position (struct window *w, ptrdiff_t pos, 3350int face_at_buffer_position (struct window *w, ptrdiff_t pos,
3355 ptrdiff_t region_beg, ptrdiff_t region_end,
3356 ptrdiff_t *endptr, ptrdiff_t limit, 3351 ptrdiff_t *endptr, ptrdiff_t limit,
3357 int mouse, int base_face_id); 3352 int mouse, int base_face_id);
3358int face_for_overlay_string (struct window *w, ptrdiff_t pos, 3353int face_for_overlay_string (struct window *w, ptrdiff_t pos,
3359 ptrdiff_t region_beg, ptrdiff_t region_end,
3360 ptrdiff_t *endptr, ptrdiff_t limit, 3354 ptrdiff_t *endptr, ptrdiff_t limit,
3361 int mouse, Lisp_Object overlay); 3355 int mouse, Lisp_Object overlay);
3362int face_at_string_position (struct window *w, Lisp_Object string, 3356int face_at_string_position (struct window *w, Lisp_Object string,
3363 ptrdiff_t pos, ptrdiff_t bufpos, 3357 ptrdiff_t pos, ptrdiff_t bufpos,
3364 ptrdiff_t region_beg, ptrdiff_t region_end,
3365 ptrdiff_t *endptr, enum face_id, int mouse); 3358 ptrdiff_t *endptr, enum face_id, int mouse);
3366int merge_faces (struct frame *, Lisp_Object, int, int); 3359int merge_faces (struct frame *, Lisp_Object, int, int);
3367int compute_char_face (struct frame *, int, Lisp_Object); 3360int compute_char_face (struct frame *, int, Lisp_Object);
@@ -3369,7 +3362,7 @@ void free_all_realized_faces (Lisp_Object);
3369extern Lisp_Object Qforeground_color, Qbackground_color; 3362extern Lisp_Object Qforeground_color, Qbackground_color;
3370extern char unspecified_fg[], unspecified_bg[]; 3363extern char unspecified_fg[], unspecified_bg[];
3371 3364
3372/* Defined in xfns.c */ 3365/* Defined in xfns.c. */
3373 3366
3374#ifdef HAVE_X_WINDOWS 3367#ifdef HAVE_X_WINDOWS
3375void gamma_correct (struct frame *, XColor *); 3368void gamma_correct (struct frame *, XColor *);
diff --git a/src/font.c b/src/font.c
index aaa02c20e48..1e1670b21af 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3669,10 +3669,10 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3669 ptrdiff_t endptr; 3669 ptrdiff_t endptr;
3670 3670
3671 if (STRINGP (string)) 3671 if (STRINGP (string))
3672 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr, 3672 face_id = face_at_string_position (w, string, pos, 0, &endptr,
3673 DEFAULT_FACE_ID, 0); 3673 DEFAULT_FACE_ID, 0);
3674 else 3674 else
3675 face_id = face_at_buffer_position (w, pos, -1, -1, &endptr, 3675 face_id = face_at_buffer_position (w, pos, &endptr,
3676 pos + 100, 0, -1); 3676 pos + 100, 0, -1);
3677 face = FACE_FROM_ID (f, face_id); 3677 face = FACE_FROM_ID (f, face_id);
3678 } 3678 }
@@ -3716,7 +3716,7 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
3716 { 3716 {
3717 int face_id; 3717 int face_id;
3718 3718
3719 face_id = face_at_buffer_position (w, pos, 0, 0, &ignore, 3719 face_id = face_at_buffer_position (w, pos, &ignore,
3720 *limit, 0, -1); 3720 *limit, 0, -1);
3721 face = FACE_FROM_ID (XFRAME (w->frame), face_id); 3721 face = FACE_FROM_ID (XFRAME (w->frame), face_id);
3722 } 3722 }
diff --git a/src/fontset.c b/src/fontset.c
index 15fdf9f41a0..090c097c929 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1875,7 +1875,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1875 return Qnil; 1875 return Qnil;
1876 w = XWINDOW (window); 1876 w = XWINDOW (window);
1877 f = XFRAME (w->frame); 1877 f = XFRAME (w->frame);
1878 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, 1878 face_id = face_at_buffer_position (w, pos, &dummy,
1879 pos + 100, 0, -1); 1879 pos + 100, 0, -1);
1880 } 1880 }
1881 if (! CHAR_VALID_P (c)) 1881 if (! CHAR_VALID_P (c))
diff --git a/src/insdel.c b/src/insdel.c
index 0eb80c04d99..7e6182deb91 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1778,6 +1778,8 @@ modify_text (ptrdiff_t start, ptrdiff_t end)
1778 bset_point_before_scroll (current_buffer, Qnil); 1778 bset_point_before_scroll (current_buffer, Qnil);
1779} 1779}
1780 1780
1781Lisp_Object Qregion_extract_function;
1782
1781/* Check that it is okay to modify the buffer between START and END, 1783/* Check that it is okay to modify the buffer between START and END,
1782 which are char positions. 1784 which are char positions.
1783 1785
@@ -1843,6 +1845,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
1843#endif /* not CLASH_DETECTION */ 1845#endif /* not CLASH_DETECTION */
1844 1846
1845 /* If `select-active-regions' is non-nil, save the region text. */ 1847 /* If `select-active-regions' is non-nil, save the region text. */
1848 /* FIXME: Move this to Elisp (via before-change-functions). */
1846 if (!NILP (BVAR (current_buffer, mark_active)) 1849 if (!NILP (BVAR (current_buffer, mark_active))
1847 && !inhibit_modification_hooks 1850 && !inhibit_modification_hooks
1848 && XMARKER (BVAR (current_buffer, mark))->buffer 1851 && XMARKER (BVAR (current_buffer, mark))->buffer
@@ -1854,10 +1857,8 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
1854 { 1857 {
1855 ptrdiff_t b = marker_position (BVAR (current_buffer, mark)); 1858 ptrdiff_t b = marker_position (BVAR (current_buffer, mark));
1856 ptrdiff_t e = PT; 1859 ptrdiff_t e = PT;
1857 if (b < e) 1860 Vsaved_region_selection
1858 Vsaved_region_selection = make_buffer_string (b, e, 0); 1861 = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
1859 else if (b > e)
1860 Vsaved_region_selection = make_buffer_string (e, b, 0);
1861 } 1862 }
1862 1863
1863 signal_before_change (start, end, preserve_ptr); 1864 signal_before_change (start, end, preserve_ptr);
@@ -2202,5 +2203,7 @@ as well as hooks attached to text properties and overlays. */);
2202 inhibit_modification_hooks = 0; 2203 inhibit_modification_hooks = 0;
2203 DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks"); 2204 DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks");
2204 2205
2206 DEFSYM (Qregion_extract_function, "region-extract-function");
2207
2205 defsubr (&Scombine_after_change_execute); 2208 defsubr (&Scombine_after_change_execute);
2206} 2209}
diff --git a/src/window.h b/src/window.h
index cc4332ccf7f..f619b82e8a3 100644
--- a/src/window.h
+++ b/src/window.h
@@ -341,10 +341,6 @@ struct window
341 y-direction (smooth scrolling). */ 341 y-direction (smooth scrolling). */
342 int vscroll; 342 int vscroll;
343 343
344 /* If we have highlighted the region (or any part of it), the mark
345 (region start) position; otherwise zero. */
346 ptrdiff_t region_showing;
347
348 /* Z_BYTE - buffer position of the last glyph in the current matrix of W. 344 /* Z_BYTE - buffer position of the last glyph in the current matrix of W.
349 Should be nonnegative, and only valid if window_end_valid is nonzero. */ 345 Should be nonnegative, and only valid if window_end_valid is nonzero. */
350 ptrdiff_t window_end_bytepos; 346 ptrdiff_t window_end_bytepos;
diff --git a/src/xdisp.c b/src/xdisp.c
index d62bc6ba96c..5cd2c2badcc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2601,24 +2601,6 @@ check_window_end (struct window *w)
2601 2601
2602#endif /* GLYPH_DEBUG and ENABLE_CHECKING */ 2602#endif /* GLYPH_DEBUG and ENABLE_CHECKING */
2603 2603
2604/* Return mark position if current buffer has the region of non-zero length,
2605 or -1 otherwise. */
2606
2607static ptrdiff_t
2608markpos_of_region (void)
2609{
2610 if (!NILP (Vtransient_mark_mode)
2611 && !NILP (BVAR (current_buffer, mark_active))
2612 && XMARKER (BVAR (current_buffer, mark))->buffer != NULL)
2613 {
2614 ptrdiff_t markpos = XMARKER (BVAR (current_buffer, mark))->charpos;
2615
2616 if (markpos != PT)
2617 return markpos;
2618 }
2619 return -1;
2620}
2621
2622/*********************************************************************** 2604/***********************************************************************
2623 Iterator initialization 2605 Iterator initialization
2624 ***********************************************************************/ 2606 ***********************************************************************/
@@ -2647,7 +2629,6 @@ init_iterator (struct it *it, struct window *w,
2647 ptrdiff_t charpos, ptrdiff_t bytepos, 2629 ptrdiff_t charpos, ptrdiff_t bytepos,
2648 struct glyph_row *row, enum face_id base_face_id) 2630 struct glyph_row *row, enum face_id base_face_id)
2649{ 2631{
2650 ptrdiff_t markpos;
2651 enum face_id remapped_base_face_id = base_face_id; 2632 enum face_id remapped_base_face_id = base_face_id;
2652 2633
2653 /* Some precondition checks. */ 2634 /* Some precondition checks. */
@@ -2751,28 +2732,6 @@ init_iterator (struct it *it, struct window *w,
2751 /* Are multibyte characters enabled in current_buffer? */ 2732 /* Are multibyte characters enabled in current_buffer? */
2752 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 2733 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
2753 2734
2754 /* If visible region is of non-zero length, set IT->region_beg_charpos
2755 and IT->region_end_charpos to the start and end of a visible region
2756 in window IT->w. Set both to -1 to indicate no region. */
2757 markpos = markpos_of_region ();
2758 if (markpos >= 0
2759 /* Maybe highlight only in selected window. */
2760 && (/* Either show region everywhere. */
2761 highlight_nonselected_windows
2762 /* Or show region in the selected window. */
2763 || w == XWINDOW (selected_window)
2764 /* Or show the region if we are in the mini-buffer and W is
2765 the window the mini-buffer refers to. */
2766 || (MINI_WINDOW_P (XWINDOW (selected_window))
2767 && WINDOWP (minibuf_selected_window)
2768 && w == XWINDOW (minibuf_selected_window))))
2769 {
2770 it->region_beg_charpos = min (PT, markpos);
2771 it->region_end_charpos = max (PT, markpos);
2772 }
2773 else
2774 it->region_beg_charpos = it->region_end_charpos = -1;
2775
2776 /* Get the position at which the redisplay_end_trigger hook should 2735 /* Get the position at which the redisplay_end_trigger hook should
2777 be run, if it is to be run at all. */ 2736 be run, if it is to be run at all. */
2778 if (MARKERP (w->redisplay_end_trigger) 2737 if (MARKERP (w->redisplay_end_trigger)
@@ -3406,16 +3365,6 @@ compute_stop_pos (struct it *it)
3406 if (pos < it->stop_charpos) 3365 if (pos < it->stop_charpos)
3407 it->stop_charpos = pos; 3366 it->stop_charpos = pos;
3408 3367
3409 /* If showing the region, we have to stop at the region
3410 start or end because the face might change there. */
3411 if (it->region_beg_charpos > 0)
3412 {
3413 if (IT_CHARPOS (*it) < it->region_beg_charpos)
3414 it->stop_charpos = min (it->stop_charpos, it->region_beg_charpos);
3415 else if (IT_CHARPOS (*it) < it->region_end_charpos)
3416 it->stop_charpos = min (it->stop_charpos, it->region_end_charpos);
3417 }
3418
3419 /* Set up variables for computing the stop position from text 3368 /* Set up variables for computing the stop position from text
3420 property changes. */ 3369 property changes. */
3421 XSETBUFFER (object, current_buffer); 3370 XSETBUFFER (object, current_buffer);
@@ -3799,8 +3748,6 @@ handle_face_prop (struct it *it)
3799 new_face_id 3748 new_face_id
3800 = face_at_buffer_position (it->w, 3749 = face_at_buffer_position (it->w,
3801 IT_CHARPOS (*it), 3750 IT_CHARPOS (*it),
3802 it->region_beg_charpos,
3803 it->region_end_charpos,
3804 &next_stop, 3751 &next_stop,
3805 (IT_CHARPOS (*it) 3752 (IT_CHARPOS (*it)
3806 + TEXT_PROP_DISTANCE_LIMIT), 3753 + TEXT_PROP_DISTANCE_LIMIT),
@@ -3877,8 +3824,6 @@ handle_face_prop (struct it *it)
3877 base_face_id 3824 base_face_id
3878 = face_for_overlay_string (it->w, 3825 = face_for_overlay_string (it->w,
3879 IT_CHARPOS (*it), 3826 IT_CHARPOS (*it),
3880 it->region_beg_charpos,
3881 it->region_end_charpos,
3882 &next_stop, 3827 &next_stop,
3883 (IT_CHARPOS (*it) 3828 (IT_CHARPOS (*it)
3884 + TEXT_PROP_DISTANCE_LIMIT), 3829 + TEXT_PROP_DISTANCE_LIMIT),
@@ -3907,8 +3852,6 @@ handle_face_prop (struct it *it)
3907 it->string, 3852 it->string,
3908 IT_STRING_CHARPOS (*it), 3853 IT_STRING_CHARPOS (*it),
3909 bufpos, 3854 bufpos,
3910 it->region_beg_charpos,
3911 it->region_end_charpos,
3912 &next_stop, 3855 &next_stop,
3913 base_face_id, 0); 3856 base_face_id, 0);
3914 3857
@@ -4051,8 +3994,6 @@ face_before_or_after_it_pos (struct it *it, int before_p)
4051 it->string, 3994 it->string,
4052 charpos, 3995 charpos,
4053 bufpos, 3996 bufpos,
4054 it->region_beg_charpos,
4055 it->region_end_charpos,
4056 &next_check_charpos, 3997 &next_check_charpos,
4057 base_face_id, 0); 3998 base_face_id, 0);
4058 3999
@@ -4142,8 +4083,6 @@ face_before_or_after_it_pos (struct it *it, int before_p)
4142 /* Determine face for CHARSET_ASCII, or unibyte. */ 4083 /* Determine face for CHARSET_ASCII, or unibyte. */
4143 face_id = face_at_buffer_position (it->w, 4084 face_id = face_at_buffer_position (it->w,
4144 CHARPOS (pos), 4085 CHARPOS (pos),
4145 it->region_beg_charpos,
4146 it->region_end_charpos,
4147 &next_check_charpos, 4086 &next_check_charpos,
4148 limit, 0, -1); 4087 limit, 0, -1);
4149 4088
@@ -6441,9 +6380,6 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
6441 ptrdiff_t charpos, ptrdiff_t precision, int field_width, 6380 ptrdiff_t charpos, ptrdiff_t precision, int field_width,
6442 int multibyte) 6381 int multibyte)
6443{ 6382{
6444 /* No region in strings. */
6445 it->region_beg_charpos = it->region_end_charpos = -1;
6446
6447 /* No text property checks performed by default, but see below. */ 6383 /* No text property checks performed by default, but see below. */
6448 it->stop_charpos = -1; 6384 it->stop_charpos = -1;
6449 6385
@@ -7033,8 +6969,7 @@ get_next_display_element (struct it *it)
7033 INC_TEXT_POS (pos, it->multibyte_p); 6969 INC_TEXT_POS (pos, it->multibyte_p);
7034 6970
7035 next_face_id = face_at_buffer_position 6971 next_face_id = face_at_buffer_position
7036 (it->w, CHARPOS (pos), it->region_beg_charpos, 6972 (it->w, CHARPOS (pos), &ignore,
7037 it->region_end_charpos, &ignore,
7038 (IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT), 0, 6973 (IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT), 0,
7039 -1); 6974 -1);
7040 it->end_of_box_run_p 6975 it->end_of_box_run_p
@@ -10906,8 +10841,7 @@ buffer_shared_and_changed (void)
10906 && UNCHANGED_MODIFIED < MODIFF); 10841 && UNCHANGED_MODIFIED < MODIFF);
10907} 10842}
10908 10843
10909/* Nonzero if W's buffer was changed but not saved or Transient Mark mode 10844/* Nonzero if W's buffer was changed but not saved. */
10910 is enabled and mark of W's buffer was changed since last W's update. */
10911 10845
10912static int 10846static int
10913window_buffer_changed (struct window *w) 10847window_buffer_changed (struct window *w)
@@ -10916,9 +10850,7 @@ window_buffer_changed (struct window *w)
10916 10850
10917 eassert (BUFFER_LIVE_P (b)); 10851 eassert (BUFFER_LIVE_P (b));
10918 10852
10919 return (((BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star) 10853 return (((BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star));
10920 || ((!NILP (Vtransient_mark_mode) && !NILP (BVAR (b, mark_active)))
10921 != (w->region_showing != 0)));
10922} 10854}
10923 10855
10924/* Nonzero if W has %c in its mode line and mode line should be updated. */ 10856/* Nonzero if W has %c in its mode line and mode line should be updated. */
@@ -11273,6 +11205,10 @@ prepare_menu_bars (void)
11273 all_windows = (update_mode_lines 11205 all_windows = (update_mode_lines
11274 || buffer_shared_and_changed () 11206 || buffer_shared_and_changed ()
11275 || windows_or_buffers_changed); 11207 || windows_or_buffers_changed);
11208
11209 if (FUNCTIONP (Vpre_redisplay_function))
11210 safe_call1 (Vpre_redisplay_function, all_windows ? Qt : Qnil);
11211
11276 if (all_windows) 11212 if (all_windows)
11277 { 11213 {
11278 Lisp_Object tail, frame; 11214 Lisp_Object tail, frame;
@@ -13147,17 +13083,6 @@ redisplay_internal (void)
13147 clear_garbaged_frames (); 13083 clear_garbaged_frames ();
13148 } 13084 }
13149 13085
13150 /* If showing the region, and mark has changed, we must redisplay
13151 the whole window. The assignment to this_line_start_pos prevents
13152 the optimization directly below this if-statement. */
13153 if (((!NILP (Vtransient_mark_mode)
13154 && !NILP (BVAR (XBUFFER (w->contents), mark_active)))
13155 != (w->region_showing > 0))
13156 || (w->region_showing
13157 && w->region_showing
13158 != XINT (Fmarker_position (BVAR (XBUFFER (w->contents), mark)))))
13159 CHARPOS (this_line_start_pos) = 0;
13160
13161 /* Optimize the case that only the line containing the cursor in the 13086 /* Optimize the case that only the line containing the cursor in the
13162 selected window has changed. Variables starting with this_ are 13087 selected window has changed. Variables starting with this_ are
13163 set in display_line and record information about the line 13088 set in display_line and record information about the line
@@ -13317,13 +13242,7 @@ redisplay_internal (void)
13317 } 13242 }
13318 /* If highlighting the region, or if the cursor is in the echo area, 13243 /* If highlighting the region, or if the cursor is in the echo area,
13319 then we can't just move the cursor. */ 13244 then we can't just move the cursor. */
13320 else if (! (!NILP (Vtransient_mark_mode) 13245 else if (NILP (Vshow_trailing_whitespace)
13321 && !NILP (BVAR (current_buffer, mark_active)))
13322 && (EQ (selected_window,
13323 BVAR (current_buffer, last_selected_window))
13324 || highlight_nonselected_windows)
13325 && !w->region_showing
13326 && NILP (Vshow_trailing_whitespace)
13327 && !cursor_in_echo_area) 13246 && !cursor_in_echo_area)
13328 { 13247 {
13329 struct it it; 13248 struct it it;
@@ -15003,11 +14922,6 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15003 && !update_mode_lines 14922 && !update_mode_lines
15004 && !windows_or_buffers_changed 14923 && !windows_or_buffers_changed
15005 && !f->cursor_type_changed 14924 && !f->cursor_type_changed
15006 /* Can't use this case if highlighting a region. When a
15007 region exists, cursor movement has to do more than just
15008 set the cursor. */
15009 && markpos_of_region () < 0
15010 && !w->region_showing
15011 && NILP (Vshow_trailing_whitespace) 14925 && NILP (Vshow_trailing_whitespace)
15012 /* This code is not used for mini-buffer for the sake of the case 14926 /* This code is not used for mini-buffer for the sake of the case
15013 of redisplaying to replace an echo area message; since in 14927 of redisplaying to replace an echo area message; since in
@@ -15622,7 +15536,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15622 Move it back to a fully-visible line. */ 15536 Move it back to a fully-visible line. */
15623 new_vpos = window_box_height (w); 15537 new_vpos = window_box_height (w);
15624 } 15538 }
15625 else if (w->cursor.vpos >=0) 15539 else if (w->cursor.vpos >= 0)
15626 { 15540 {
15627 /* Some people insist on not letting point enter the scroll 15541 /* Some people insist on not letting point enter the scroll
15628 margin, even though this part handles windows that didn't 15542 margin, even though this part handles windows that didn't
@@ -15680,12 +15594,14 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15680 15594
15681 /* If we are highlighting the region, then we just changed 15595 /* If we are highlighting the region, then we just changed
15682 the region, so redisplay to show it. */ 15596 the region, so redisplay to show it. */
15683 if (markpos_of_region () >= 0) 15597 /* FIXME: We need to (re)run pre-redisplay-function! */
15598 /* if (markpos_of_region () >= 0)
15684 { 15599 {
15685 clear_glyph_matrix (w->desired_matrix); 15600 clear_glyph_matrix (w->desired_matrix);
15686 if (!try_window (window, startp, 0)) 15601 if (!try_window (window, startp, 0))
15687 goto need_larger_matrices; 15602 goto need_larger_matrices;
15688 } 15603 }
15604 */
15689 } 15605 }
15690 15606
15691#ifdef GLYPH_DEBUG 15607#ifdef GLYPH_DEBUG
@@ -16380,10 +16296,8 @@ try_window_reusing_current_matrix (struct window *w)
16380 || f->cursor_type_changed) 16296 || f->cursor_type_changed)
16381 return 0; 16297 return 0;
16382 16298
16383 /* Can't do this if region may have changed. */ 16299 /* Can't do this if showing trailing whitespace. */
16384 if (markpos_of_region () >= 0 16300 if (!NILP (Vshow_trailing_whitespace))
16385 || w->region_showing
16386 || !NILP (Vshow_trailing_whitespace))
16387 return 0; 16301 return 0;
16388 16302
16389 /* If top-line visibility has changed, give up. */ 16303 /* If top-line visibility has changed, give up. */
@@ -17181,19 +17095,10 @@ try_window_id (struct window *w)
17181 if (!w->window_end_valid) 17095 if (!w->window_end_valid)
17182 GIVE_UP (8); 17096 GIVE_UP (8);
17183 17097
17184 /* Can't use this if highlighting a region because a cursor movement
17185 will do more than just set the cursor. */
17186 if (markpos_of_region () >= 0)
17187 GIVE_UP (9);
17188
17189 /* Likewise if highlighting trailing whitespace. */ 17098 /* Likewise if highlighting trailing whitespace. */
17190 if (!NILP (Vshow_trailing_whitespace)) 17099 if (!NILP (Vshow_trailing_whitespace))
17191 GIVE_UP (11); 17100 GIVE_UP (11);
17192 17101
17193 /* Likewise if showing a region. */
17194 if (w->region_showing)
17195 GIVE_UP (10);
17196
17197 /* Can't use this if overlay arrow position and/or string have 17102 /* Can't use this if overlay arrow position and/or string have
17198 changed. */ 17103 changed. */
17199 if (overlay_arrows_changed_p ()) 17104 if (overlay_arrows_changed_p ())
@@ -19277,9 +19182,6 @@ display_line (struct it *it)
19277 return 0; 19182 return 0;
19278 } 19183 }
19279 19184
19280 /* Is IT->w showing the region? */
19281 it->w->region_showing = it->region_beg_charpos > 0 ? it->region_beg_charpos : 0;
19282
19283 /* Clear the result glyph row and enable it. */ 19185 /* Clear the result glyph row and enable it. */
19284 prepare_desired_row (row); 19186 prepare_desired_row (row);
19285 19187
@@ -22413,9 +22315,7 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st
22413 22315
22414 it->face_id 22316 it->face_id
22415 = face_at_string_position (it->w, face_string, face_string_pos, 22317 = face_at_string_position (it->w, face_string, face_string_pos,
22416 0, it->region_beg_charpos, 22318 0, &endptr, it->base_face_id, 0);
22417 it->region_end_charpos,
22418 &endptr, it->base_face_id, 0);
22419 face = FACE_FROM_ID (it->f, it->face_id); 22319 face = FACE_FROM_ID (it->f, it->face_id);
22420 it->face_box_p = face->box != FACE_NO_BOX; 22320 it->face_box_p = face->box != FACE_NO_BOX;
22421 } 22321 }
@@ -27419,7 +27319,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
27419 27319
27420 hlinfo->mouse_face_window = window; 27320 hlinfo->mouse_face_window = window;
27421 hlinfo->mouse_face_face_id 27321 hlinfo->mouse_face_face_id
27422 = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore, 27322 = face_at_buffer_position (w, mouse_charpos, &ignore,
27423 mouse_charpos + 1, 27323 mouse_charpos + 1,
27424 !hlinfo->mouse_face_hidden, -1); 27324 !hlinfo->mouse_face_hidden, -1);
27425 show_mouse_face (hlinfo, DRAW_MOUSE_FACE); 27325 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
@@ -28100,8 +28000,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
28100 28000
28101 hlinfo->mouse_face_face_id = face_at_string_position (w, string, 28001 hlinfo->mouse_face_face_id = face_at_string_position (w, string,
28102 charpos, 28002 charpos,
28103 0, 0, 0, 28003 0, &ignore,
28104 &ignore,
28105 glyph->face_id, 28004 glyph->face_id,
28106 1); 28005 1);
28107 show_mouse_face (hlinfo, DRAW_MOUSE_FACE); 28006 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
@@ -28402,7 +28301,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
28402 hlinfo->mouse_face_past_end = 0; 28301 hlinfo->mouse_face_past_end = 0;
28403 hlinfo->mouse_face_window = window; 28302 hlinfo->mouse_face_window = window;
28404 hlinfo->mouse_face_face_id 28303 hlinfo->mouse_face_face_id
28405 = face_at_string_position (w, object, pos, 0, 0, 0, &ignore, 28304 = face_at_string_position (w, object, pos, 0, &ignore,
28406 glyph->face_id, 1); 28305 glyph->face_id, 1);
28407 show_mouse_face (hlinfo, DRAW_MOUSE_FACE); 28306 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
28408 cursor = No_Cursor; 28307 cursor = No_Cursor;
@@ -28449,13 +28348,14 @@ note_mouse_highlight (struct frame *f, int x, int y)
28449 the first row visible in a window does not 28348 the first row visible in a window does not
28450 necessarily display the character whose position 28349 necessarily display the character whose position
28451 is the smallest. */ 28350 is the smallest. */
28452 Lisp_Object lim1 = 28351 Lisp_Object lim1
28453 NILP (BVAR (XBUFFER (buffer), bidi_display_reordering)) 28352 = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
28454 ? Fmarker_position (w->start) 28353 ? Fmarker_position (w->start)
28455 : Qnil; 28354 : Qnil;
28456 Lisp_Object lim2 = 28355 Lisp_Object lim2
28457 NILP (BVAR (XBUFFER (buffer), bidi_display_reordering)) 28356 = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
28458 ? make_number (BUF_Z (XBUFFER (buffer)) - w->window_end_pos) 28357 ? make_number (BUF_Z (XBUFFER (buffer))
28358 - w->window_end_pos)
28459 : Qnil; 28359 : Qnil;
28460 28360
28461 if (NILP (overlay)) 28361 if (NILP (overlay))
@@ -29788,6 +29688,13 @@ cursor shapes. */);
29788 DEFSYM (Qthin_space, "thin-space"); 29688 DEFSYM (Qthin_space, "thin-space");
29789 DEFSYM (Qzero_width, "zero-width"); 29689 DEFSYM (Qzero_width, "zero-width");
29790 29690
29691 DEFVAR_LISP ("pre-redisplay-function", Vpre_redisplay_function,
29692 doc: /* Function run just before redisplay.
29693It is called with one argument, which is the set of windows that are to
29694be redisplayed. This set can be nil (meaning, only the selected window),
29695or t (meaning all windows). */);
29696 Vpre_redisplay_function = intern ("ignore");
29697
29791 DEFSYM (Qglyphless_char_display, "glyphless-char-display"); 29698 DEFSYM (Qglyphless_char_display, "glyphless-char-display");
29792 Fput (Qglyphless_char_display, Qchar_table_extra_slots, make_number (1)); 29699 Fput (Qglyphless_char_display, Qchar_table_extra_slots, make_number (1));
29793 29700
diff --git a/src/xfaces.c b/src/xfaces.c
index 2145d7ff59d..f50fffc6419 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -5916,7 +5916,6 @@ compute_char_face (struct frame *f, int ch, Lisp_Object prop)
5916 5916
5917int 5917int
5918face_at_buffer_position (struct window *w, ptrdiff_t pos, 5918face_at_buffer_position (struct window *w, ptrdiff_t pos,
5919 ptrdiff_t region_beg, ptrdiff_t region_end,
5920 ptrdiff_t *endptr, ptrdiff_t limit, 5919 ptrdiff_t *endptr, ptrdiff_t limit,
5921 int mouse, int base_face_id) 5920 int mouse, int base_face_id)
5922{ 5921{
@@ -5937,8 +5936,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
5937 XSETFASTINT (position, pos); 5936 XSETFASTINT (position, pos);
5938 5937
5939 endpos = ZV; 5938 endpos = ZV;
5940 if (pos < region_beg && region_beg < endpos)
5941 endpos = region_beg;
5942 5939
5943 /* Get the `face' or `mouse_face' text property at POS, and 5940 /* Get the `face' or `mouse_face' text property at POS, and
5944 determine the next position at which the property changes. */ 5941 determine the next position at which the property changes. */
@@ -5974,8 +5971,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
5974 5971
5975 /* Optimize common cases where we can use the default face. */ 5972 /* Optimize common cases where we can use the default face. */
5976 if (noverlays == 0 5973 if (noverlays == 0
5977 && NILP (prop) 5974 && NILP (prop))
5978 && !(pos >= region_beg && pos < region_end))
5979 return default_face->id; 5975 return default_face->id;
5980 5976
5981 /* Begin with attributes from the default face. */ 5977 /* Begin with attributes from the default face. */
@@ -6002,15 +5998,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
6002 endpos = oendpos; 5998 endpos = oendpos;
6003 } 5999 }
6004 6000
6005 /* If in the region, merge in the region face. */
6006 if (pos >= region_beg && pos < region_end)
6007 {
6008 merge_named_face (f, Qregion, attrs, 0);
6009
6010 if (region_end < endpos)
6011 endpos = region_end;
6012 }
6013
6014 *endptr = endpos; 6001 *endptr = endpos;
6015 6002
6016 /* Look up a realized face with the given face attributes, 6003 /* Look up a realized face with the given face attributes,
@@ -6026,7 +6013,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
6026 6013
6027int 6014int
6028face_for_overlay_string (struct window *w, ptrdiff_t pos, 6015face_for_overlay_string (struct window *w, ptrdiff_t pos,
6029 ptrdiff_t region_beg, ptrdiff_t region_end,
6030 ptrdiff_t *endptr, ptrdiff_t limit, 6016 ptrdiff_t *endptr, ptrdiff_t limit,
6031 int mouse, Lisp_Object overlay) 6017 int mouse, Lisp_Object overlay)
6032{ 6018{
@@ -6045,8 +6031,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6045 XSETFASTINT (position, pos); 6031 XSETFASTINT (position, pos);
6046 6032
6047 endpos = ZV; 6033 endpos = ZV;
6048 if (pos < region_beg && region_beg < endpos)
6049 endpos = region_beg;
6050 6034
6051 /* Get the `face' or `mouse_face' text property at POS, and 6035 /* Get the `face' or `mouse_face' text property at POS, and
6052 determine the next position at which the property changes. */ 6036 determine the next position at which the property changes. */
@@ -6060,7 +6044,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6060 6044
6061 /* Optimize common case where we can use the default face. */ 6045 /* Optimize common case where we can use the default face. */
6062 if (NILP (prop) 6046 if (NILP (prop)
6063 && !(pos >= region_beg && pos < region_end)
6064 && NILP (Vface_remapping_alist)) 6047 && NILP (Vface_remapping_alist))
6065 return DEFAULT_FACE_ID; 6048 return DEFAULT_FACE_ID;
6066 6049
@@ -6072,15 +6055,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6072 if (!NILP (prop)) 6055 if (!NILP (prop))
6073 merge_face_ref (f, prop, attrs, 1, 0); 6056 merge_face_ref (f, prop, attrs, 1, 0);
6074 6057
6075 /* If in the region, merge in the region face. */
6076 if (pos >= region_beg && pos < region_end)
6077 {
6078 merge_named_face (f, Qregion, attrs, 0);
6079
6080 if (region_end < endpos)
6081 endpos = region_end;
6082 }
6083
6084 *endptr = endpos; 6058 *endptr = endpos;
6085 6059
6086 /* Look up a realized face with the given face attributes, 6060 /* Look up a realized face with the given face attributes,
@@ -6113,7 +6087,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6113int 6087int
6114face_at_string_position (struct window *w, Lisp_Object string, 6088face_at_string_position (struct window *w, Lisp_Object string,
6115 ptrdiff_t pos, ptrdiff_t bufpos, 6089 ptrdiff_t pos, ptrdiff_t bufpos,
6116 ptrdiff_t region_beg, ptrdiff_t region_end,
6117 ptrdiff_t *endptr, enum face_id base_face_id, 6090 ptrdiff_t *endptr, enum face_id base_face_id,
6118 int mouse_p) 6091 int mouse_p)
6119{ 6092{
@@ -6145,15 +6118,8 @@ face_at_string_position (struct window *w, Lisp_Object string,
6145 base_face = FACE_FROM_ID (f, base_face_id); 6118 base_face = FACE_FROM_ID (f, base_face_id);
6146 eassert (base_face); 6119 eassert (base_face);
6147 6120
6148 /* Optimize the default case that there is no face property and we 6121 /* Optimize the default case that there is no face property. */
6149 are not in the region. */
6150 if (NILP (prop) 6122 if (NILP (prop)
6151 && (base_face_id != DEFAULT_FACE_ID
6152 /* BUFPOS <= 0 means STRING is not an overlay string, so
6153 that the region doesn't have to be taken into account. */
6154 || bufpos <= 0
6155 || bufpos < region_beg
6156 || bufpos >= region_end)
6157 && (multibyte_p 6123 && (multibyte_p
6158 /* We can't realize faces for different charsets differently 6124 /* We can't realize faces for different charsets differently
6159 if we don't have fonts, so we can stop here if not working 6125 if we don't have fonts, so we can stop here if not working
@@ -6169,12 +6135,6 @@ face_at_string_position (struct window *w, Lisp_Object string,
6169 if (!NILP (prop)) 6135 if (!NILP (prop))
6170 merge_face_ref (f, prop, attrs, 1, 0); 6136 merge_face_ref (f, prop, attrs, 1, 0);
6171 6137
6172 /* If in the region, merge in the region face. */
6173 if (bufpos
6174 && bufpos >= region_beg
6175 && bufpos < region_end)
6176 merge_named_face (f, Qregion, attrs, 0);
6177
6178 /* Look up a realized face with the given face attributes, 6138 /* Look up a realized face with the given face attributes,
6179 or realize a new one for ASCII characters. */ 6139 or realize a new one for ASCII characters. */
6180 return lookup_face (f, attrs); 6140 return lookup_face (f, attrs);