* bug#13713: 24.3.50; C indent produces error when narrowing is active
@ 2013-02-14 8:57 Dima Kogan
2013-02-17 8:06 ` bug#13713: Root cause Dima Kogan
2017-12-01 10:04 ` bug#13713: 24.3.50; C indent produces error when narrowing is active Noam Postavsky
0 siblings, 2 replies; 3+ messages in thread
From: Dima Kogan @ 2013-02-14 8:57 UTC (permalink / raw)
To: 13713
Hi.
I'm observing an issue with emacs indentation in C mode when narrowing
is enabled. To reproduce, create a tst.c buffer with the following 3
lines:
// 123
// 456
// 789
I select the last 2 lines (456, 789), and narrow-to-region. Then I place
the point at the start of the 789 line, and press 'tab'. I get this:
Debugger entered--Lisp error: (args-out-of-range 1 8)
parse-partial-sexp(1 8)
c-determine-limit-get-base(15 1000)
(let* ((start (or start (point))) (try-size (or try-size (* 2 how-far-back))) (base (c-determine-limit-get-base start try-size)) (pos base) (s (parse-partial-sexp pos pos)) stack elt size (count 0)) (while (< pos start) (setq s (parse-partial-sexp pos start nil nil s (quote syntax-table))) (setq size (- (if (or (nth 4 s) (nth 3 s)) (nth 8 s) (point)) pos)) (if (> size 0) (setq stack (cons (cons pos size) stack))) (if (or (nth 4 s) (nth 3 s)) (setq s (parse-partial-sexp (point) start nil nil s (quote syntax-table)))) (setq pos (point))) (while (and (< count how-far-back) stack) (setq elt (car stack) stack (cdr stack)) (setq count (+ count (cdr elt)))) (cond ((>= count how-far-back) (+ (car elt) (- count how-far-back))) ((eq base (point-min)) (point-min)) (t (c-determine-limit (- how-far-b
ack count) base try-size))))
(save-excursion (let* ((start (or start (point))) (try-size (or try-size (* 2 how-far-back))) (base (c-determine-limit-get-base start try-size)) (pos base) (s (parse-partial-sexp pos pos)) stack elt size (count 0)) (while (< pos start) (setq s (parse-partial-sexp pos start nil nil s (quote syntax-table))) (setq size (- (if (or (nth 4 s) (nth 3 s)) (nth 8 s) (point)) pos)) (if (> size 0) (setq stack (cons (cons pos size) stack))) (if (or (nth 4 s) (nth 3 s)) (setq s (parse-partial-sexp (point) start nil nil s (quote syntax-table)))) (setq pos (point))) (while (and (< count how-far-back) stack) (setq elt (car stack) stack (cdr stack)) (setq count (+ count (cdr elt)))) (cond ((>= count how-far-back) (+ (car elt) (- count how-far-back))) ((eq base (point-min)) (point-min)) (t (c-determine-li
mit (- how-far-back count) base try-size)))))
c-determine-limit(500)
c-guess-basic-syntax()
c-indent-line()
c-indent-command(nil)
c-indent-line-or-region(nil nil)
call-interactively(c-indent-line-or-region nil nil)
As shown above, the failure is in (parse-partial-sexp 1 8). Evaluating
this same for succeeds if the buffer is re-widened.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#13713: Root cause
2013-02-14 8:57 bug#13713: 24.3.50; C indent produces error when narrowing is active Dima Kogan
@ 2013-02-17 8:06 ` Dima Kogan
2017-12-01 10:04 ` bug#13713: 24.3.50; C indent produces error when narrowing is active Noam Postavsky
1 sibling, 0 replies; 3+ messages in thread
From: Dima Kogan @ 2013-02-17 8:06 UTC (permalink / raw)
To: 13713
I looked at it some more, and it's pretty clear what's happening. The
indentation command calls (c-determine-limit), which in turn calls
(parse-partial-sexp) in many places. (parse-partial-sexp) fails if asked to look
at the buffer outside of the narrowed region. Thus one way to fix this is to
wrap the definition of c-determine-limit in (save-restriction (widen) ... ).
This is a construct that already appears in many places in cc-engine.el, so
maybe it's appropriate here. This advice makes it work:
(defadvice c-determine-limit (around c-determine-limit-works-with-narrowing
(how-far-back &optional start try-size)
activate)
"I lift the restriction around this function to get around emacs bug 13713"
(save-restriction (widen) ad-do-it))
I don't know enough about the internal design of cc-engine.el to know if this is
an appropriate place to lift the restriction, or if lifting it is the way to go
at all.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#13713: 24.3.50; C indent produces error when narrowing is active
2013-02-14 8:57 bug#13713: 24.3.50; C indent produces error when narrowing is active Dima Kogan
2013-02-17 8:06 ` bug#13713: Root cause Dima Kogan
@ 2017-12-01 10:04 ` Noam Postavsky
1 sibling, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2017-12-01 10:04 UTC (permalink / raw)
To: Dima Kogan; +Cc: 13713
found 13713 25.3
tags 13713 fixed
close 13713 26.1
quit
Dima Kogan <dima@secretsauce.net> writes:
> Hi.
>
> I'm observing an issue with emacs indentation in C mode when narrowing
> is enabled. To reproduce, create a tst.c buffer with the following 3
> lines:
>
> // 123
> // 456
> // 789
>
> I select the last 2 lines (456, 789), and narrow-to-region. Then I place
> the point at the start of the 789 line, and press 'tab'. I get this:
>
> Debugger entered--Lisp error: (args-out-of-range 1 8)
Seems to be fixed in emac-26.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-01 10:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14 8:57 bug#13713: 24.3.50; C indent produces error when narrowing is active Dima Kogan
2013-02-17 8:06 ` bug#13713: Root cause Dima Kogan
2017-12-01 10:04 ` bug#13713: 24.3.50; C indent produces error when narrowing is active Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.