diff options
| author | Eli Zaretskii | 2017-07-17 17:50:37 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-17 17:50:37 +0300 |
| commit | d7f7fef1c1cdef206860a7075873de7d6c521d8d (patch) | |
| tree | abc7489210594cfdd4324404f1fe8155dfd58953 /src/buffer.c | |
| parent | 5e2ae74df54d4090c591c79ab13e7713c6654b9c (diff) | |
| download | emacs-d7f7fef1c1cdef206860a7075873de7d6c521d8d.tar.gz emacs-d7f7fef1c1cdef206860a7075873de7d6c521d8d.zip | |
Allow user control on what starts and ends a paragraph for bidi
* src/buffer.h (struct buffer): New members
bidi_paragraph_separate_re_ and bidi_paragraph_start_re_.
* src/buffer.c (bset_bidi_paragraph_start_re)
(bset_bidi_paragraph_separate_re): New setters/
(Fbuffer_swap_text): Swap the values of bidi-paragraph-start-re and
bidi-paragraph-separate-re.
(init_buffer_once): Init the values of bidi-paragraph-start-re and
bidi-paragraph-separate-re.
(syms_of_buffer) <bidi-paragraph-start-re, bidi-paragraph-separate-re>:
New per-buffer variables.
* src/bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start):
Support bidi-paragraph-start-re and bidi-paragraph-separate-re.
(bidi_move_to_visually_next): Handle correctly the case when the
separator matches an empty string. (Bug#27526)
* doc/emacs/mule.texi (Bidirectional Editing):
* doc/lispref/display.texi (Bidirectional Display): Document
bidi-paragraph-start-re and bidi-paragraph-separate-re.
* etc/NEWS: Mention bidi-paragraph-start-re and
bidi-paragraph-separate-re.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index e0972aac33c..649ddbe1839 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -173,6 +173,16 @@ bset_bidi_display_reordering (struct buffer *b, Lisp_Object val) | |||
| 173 | b->bidi_display_reordering_ = val; | 173 | b->bidi_display_reordering_ = val; |
| 174 | } | 174 | } |
| 175 | static void | 175 | static void |
| 176 | bset_bidi_paragraph_start_re (struct buffer *b, Lisp_Object val) | ||
| 177 | { | ||
| 178 | b->bidi_paragraph_start_re_ = val; | ||
| 179 | } | ||
| 180 | static void | ||
| 181 | bset_bidi_paragraph_separate_re (struct buffer *b, Lisp_Object val) | ||
| 182 | { | ||
| 183 | b->bidi_paragraph_separate_re_ = val; | ||
| 184 | } | ||
| 185 | static void | ||
| 176 | bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) | 186 | bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) |
| 177 | { | 187 | { |
| 178 | b->buffer_file_coding_system_ = val; | 188 | b->buffer_file_coding_system_ = val; |
| @@ -2322,6 +2332,8 @@ results, see Info node `(elisp)Swapping Text'. */) | |||
| 2322 | swapfield_ (enable_multibyte_characters, Lisp_Object); | 2332 | swapfield_ (enable_multibyte_characters, Lisp_Object); |
| 2323 | swapfield_ (bidi_display_reordering, Lisp_Object); | 2333 | swapfield_ (bidi_display_reordering, Lisp_Object); |
| 2324 | swapfield_ (bidi_paragraph_direction, Lisp_Object); | 2334 | swapfield_ (bidi_paragraph_direction, Lisp_Object); |
| 2335 | swapfield_ (bidi_paragraph_separate_re, Lisp_Object); | ||
| 2336 | swapfield_ (bidi_paragraph_start_re, Lisp_Object); | ||
| 2325 | /* FIXME: Not sure what we should do with these *_marker fields. | 2337 | /* FIXME: Not sure what we should do with these *_marker fields. |
| 2326 | Hopefully they're just nil anyway. */ | 2338 | Hopefully they're just nil anyway. */ |
| 2327 | swapfield_ (pt_marker, Lisp_Object); | 2339 | swapfield_ (pt_marker, Lisp_Object); |
| @@ -5121,6 +5133,8 @@ init_buffer_once (void) | |||
| 5121 | XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx; | 5133 | XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx; |
| 5122 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx; | 5134 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx; |
| 5123 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx; | 5135 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx; |
| 5136 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx; | ||
| 5137 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx; | ||
| 5124 | XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); | 5138 | XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); |
| 5125 | /* Make this one a permanent local. */ | 5139 | /* Make this one a permanent local. */ |
| 5126 | buffer_permanent_local_flags[idx++] = 1; | 5140 | buffer_permanent_local_flags[idx++] = 1; |
| @@ -5202,6 +5216,8 @@ init_buffer_once (void) | |||
| 5202 | bset_ctl_arrow (&buffer_defaults, Qt); | 5216 | bset_ctl_arrow (&buffer_defaults, Qt); |
| 5203 | bset_bidi_display_reordering (&buffer_defaults, Qt); | 5217 | bset_bidi_display_reordering (&buffer_defaults, Qt); |
| 5204 | bset_bidi_paragraph_direction (&buffer_defaults, Qnil); | 5218 | bset_bidi_paragraph_direction (&buffer_defaults, Qnil); |
| 5219 | bset_bidi_paragraph_start_re (&buffer_defaults, Qnil); | ||
| 5220 | bset_bidi_paragraph_separate_re (&buffer_defaults, Qnil); | ||
| 5205 | bset_cursor_type (&buffer_defaults, Qt); | 5221 | bset_cursor_type (&buffer_defaults, Qt); |
| 5206 | bset_extra_line_spacing (&buffer_defaults, Qnil); | 5222 | bset_extra_line_spacing (&buffer_defaults, Qnil); |
| 5207 | bset_cursor_in_non_selected_windows (&buffer_defaults, Qt); | 5223 | bset_cursor_in_non_selected_windows (&buffer_defaults, Qt); |
| @@ -5616,6 +5632,49 @@ This variable is never applied to a way of decoding a file while reading it. */ | |||
| 5616 | &BVAR (current_buffer, bidi_display_reordering), Qnil, | 5632 | &BVAR (current_buffer, bidi_display_reordering), Qnil, |
| 5617 | doc: /* Non-nil means reorder bidirectional text for display in the visual order. */); | 5633 | doc: /* Non-nil means reorder bidirectional text for display in the visual order. */); |
| 5618 | 5634 | ||
| 5635 | DEFVAR_PER_BUFFER ("bidi-paragraph-start-re", | ||
| 5636 | &BVAR (current_buffer, bidi_paragraph_start_re), Qnil, | ||
| 5637 | doc: /* If non-nil, a regexp matching a line that starts OR separates paragraphs. | ||
| 5638 | |||
| 5639 | The value of nil means to use empty lines as lines that start and | ||
| 5640 | separate paragraphs. | ||
| 5641 | |||
| 5642 | When Emacs displays bidirectional text, it by default computes | ||
| 5643 | the base paragraph direction separately for each paragraph. | ||
| 5644 | Setting this variable changes the places where paragraph base | ||
| 5645 | direction is recomputed. | ||
| 5646 | |||
| 5647 | The regexp is always matched after a newline, so it is best to | ||
| 5648 | anchor it by beginning it with a "^". | ||
| 5649 | |||
| 5650 | If you change the value of this variable, be sure to change | ||
| 5651 | the value of `bidi-paragraph-separate-re' accordingly. For | ||
| 5652 | example, to have a single newline behave as a paragraph separator, | ||
| 5653 | set both these variables to "^". | ||
| 5654 | |||
| 5655 | See also `bidi-paragraph-direction'. */); | ||
| 5656 | |||
| 5657 | DEFVAR_PER_BUFFER ("bidi-paragraph-separate-re", | ||
| 5658 | &BVAR (current_buffer, bidi_paragraph_separate_re), Qnil, | ||
| 5659 | doc: /* If non-nil, a regexp matching a line that separates paragraphs. | ||
| 5660 | |||
| 5661 | The value of nil means to use empty lines as paragraph separators. | ||
| 5662 | |||
| 5663 | When Emacs displays bidirectional text, it by default computes | ||
| 5664 | the base paragraph direction separately for each paragraph. | ||
| 5665 | Setting this variable changes the places where paragraph base | ||
| 5666 | direction is recomputed. | ||
| 5667 | |||
| 5668 | The regexp is always matched after a newline, so it is best to | ||
| 5669 | anchor it by beginning it with a "^". | ||
| 5670 | |||
| 5671 | If you change the value of this variable, be sure to change | ||
| 5672 | the value of `bidi-paragraph-start-re' accordingly. For | ||
| 5673 | example, to have a single newline behave as a paragraph separator, | ||
| 5674 | set both these variables to "^". | ||
| 5675 | |||
| 5676 | See also `bidi-paragraph-direction'. */); | ||
| 5677 | |||
| 5619 | DEFVAR_PER_BUFFER ("bidi-paragraph-direction", | 5678 | DEFVAR_PER_BUFFER ("bidi-paragraph-direction", |
| 5620 | &BVAR (current_buffer, bidi_paragraph_direction), Qnil, | 5679 | &BVAR (current_buffer, bidi_paragraph_direction), Qnil, |
| 5621 | doc: /* If non-nil, forces directionality of text paragraphs in the buffer. | 5680 | doc: /* If non-nil, forces directionality of text paragraphs in the buffer. |