[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was
From: |
Vitalie Spinu |
Subject: |
[Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]] |
Date: |
Mon, 21 Mar 2016 06:08:59 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (gnu/linux) |
>> On Mon, Mar 21 2016 02:05, Vitalie Spinu wrote:
>> Are you interested in working on a patch? Also Cc'ing Stefan.
> My knowledge of emacs C internals is close to 0. Elisp side (and probably C
> side) of this is trivial. I will look into it but I don't think I am the best
> person for that.
The widen part turned to be easy. Will look at parse-partial-sexp tomorrow.
Vitalie
>From eafcff9e72499e3bb6dc462d406dd33a885e3d49 Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <address@hidden>
Date: Mon, 21 Mar 2016 05:41:55 +0100
Subject: [PATCH] Implement hard-narrowing
`widen` now respects restrictions imposed by new variable `hard-widen-limits`
---
src/buffer.c | 5 +++++
src/editfns.c | 14 +++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/buffer.c b/src/buffer.c
index f06d7e0..5232c49 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -6219,6 +6219,11 @@ and disregard a `read-only' text property if the
property value
is a member of the list. */);
Vinhibit_read_only = Qnil;
+ DEFVAR_LISP ("hard-widen-limits", Vhard_widen_limits,
+ doc: /* When non-nil `widen` will widen to these limits.
+Must be a cons of the form (MIN . MAX) where MIN and MAX are integers or
markers. */);
+ Vhard_widen_limits = Qnil;
+
DEFVAR_PER_BUFFER ("cursor-type", &BVAR (current_buffer, cursor_type), Qnil,
doc: /* Cursor to use when this buffer is in the selected
window.
Values are interpreted as follows:
diff --git a/src/editfns.c b/src/editfns.c
index 2ac0537..fb1f652 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3480,12 +3480,24 @@ DEFUN ("delete-and-extract-region",
Fdelete_and_extract_region,
return empty_unibyte_string;
return del_range_1 (XINT (start), XINT (end), 1, 1);
}
+
DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
doc: /* Remove restrictions (narrowing) from current buffer.
-This allows the buffer's full text to be seen and edited. */)
+This allows the buffer's full text to be seen and edited.
+If `hard-widen-limits` is non-nil, widen only to those limits. */)
(void)
{
+
+ if (! NILP (Vhard_widen_limits))
+ {
+ CHECK_CONS(Vhard_widen_limits);
+ Lisp_Object hbeg = XCAR(Vhard_widen_limits);
+ Lisp_Object hend = XCDR(Vhard_widen_limits);
+ Fnarrow_to_region(hbeg, hend);
+ return Qnil;
+ }
+
if (BEG != BEGV || Z != ZV)
current_buffer->clip_changed = 1;
BEGV = BEG;
--
2.5.0
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], (continued)
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Vitalie Spinu, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Andreas Röhler, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Stefan Monnier, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Vitalie Spinu, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Stefan Monnier, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Vitalie Spinu, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Stefan Monnier, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Vitalie Spinu, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Vitalie Spinu, 2016/03/21
- Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.], Dmitry Gutov, 2016/03/21
- [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]],
Vitalie Spinu <=
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Stefan Monnier, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Vitalie Spinu, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Stefan Monnier, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Vitalie Spinu, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Stefan Monnier, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Vitalie Spinu, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Stefan Monnier, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Vitalie Spinu, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Stefan Monnier, 2016/03/21
- Re: [Patch] hard-widen-limits [was Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]], Vitalie Spinu, 2016/03/21