GNU bug report logs - #13713
24.3.50; C indent produces error when narrowing is active

Previous Next

Packages: cc-mode, emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Thu, 14 Feb 2013 08:59:02 UTC

Severity: normal

Tags: fixed

Found in versions 25.3, 24.3.50

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13713 in the body.
You can then email your comments to 13713 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13713; Package emacs. (Thu, 14 Feb 2013 08:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 14 Feb 2013 08:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; C indent produces error when narrowing is active
Date: Thu, 14 Feb 2013 00:57:11 -0800
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-back 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-limit (- 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




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#13713; Package emacs,cc-mode. (Sun, 17 Feb 2013 08:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 13713 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: 13713 <at> debbugs.gnu.org
Subject: Root cause
Date: Sun, 17 Feb 2013 00:06:49 -0800
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




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#13713; Package emacs,cc-mode. (Fri, 01 Dec 2017 10:05:02 GMT) Full text and rfc822 format available.

Message #11 received at 13713 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 13713 <at> debbugs.gnu.org
Subject: Re: bug#13713: 24.3.50;
 C indent produces error when narrowing is active
Date: Fri, 01 Dec 2017 05:04:50 -0500
found 13713 25.3
tags 13713 fixed
close 13713 26.1
quit

Dima Kogan <dima <at> 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.




bug Marked as found in versions 25.3. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 01 Dec 2017 10:05:02 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 01 Dec 2017 10:05:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 13713 <at> debbugs.gnu.org and Dima Kogan <dima <at> secretsauce.net> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 01 Dec 2017 10:05:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 29 Dec 2017 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.