From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#21343: 24.5; parse-partial-sexp mistakes string for a comment Date: Sat, 02 Jul 2016 22:40:56 -0400 Message-ID: <87lh1jfnpj.fsf@users.sourceforge.net> References: <87lhczjyx5.fsf@gmail.com> <55DCA9C7.7070609@easy-emacs.de> <87pp2awaqp.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1467513689 28891 80.91.229.3 (3 Jul 2016 02:41:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jul 2016 02:41:29 +0000 (UTC) Cc: 21343@debbugs.gnu.org To: Oleh Krehel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 03 04:41:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bJXLR-0007kP-7X for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Jul 2016 04:41:17 +0200 Original-Received: from localhost ([::1]:40852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJXLQ-0002QN-6t for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Jul 2016 22:41:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJXLJ-0002PC-Qe for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2016 22:41:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJXLF-000864-Kp for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2016 22:41:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50916) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJXLF-00085v-Gp for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2016 22:41:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bJXLC-0002XM-5J for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2016 22:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jul 2016 02:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21343-submit@debbugs.gnu.org id=B21343.14675136549732 (code B ref 21343); Sun, 03 Jul 2016 02:41:02 +0000 Original-Received: (at 21343) by debbugs.gnu.org; 3 Jul 2016 02:40:54 +0000 Original-Received: from localhost ([127.0.0.1]:35020 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJXL4-0002Wp-Fn for submit@debbugs.gnu.org; Sat, 02 Jul 2016 22:40:54 -0400 Original-Received: from mail-it0-f50.google.com ([209.85.214.50]:37497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJXL2-0002WX-NC; Sat, 02 Jul 2016 22:40:53 -0400 Original-Received: by mail-it0-f50.google.com with SMTP id f6so42789992ith.0; Sat, 02 Jul 2016 19:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=dDgurTR72xQAwm2uW0rTCed9zkh000noBvl7lc1v3Mo=; b=XMYLPs5GNydrXRY29Mxp4Wtjm4VM0T5OPw0NTCU9LU4wLpnEM3Rl1PANO4dOe+CrXd toXWddpLzbzaUS7CRUMStAYyX7llySUNoxy+ScLs0QA0z6hU6JN9FpagQ7TRgKZNEPFN 2Kkvc+ArKC7UUJ2T3NOxvSOMH/W98S+jctVC9bC08lviz98FYAYDQoNKxTyISN1icuIM jIllfJZe93DhNvepAGqmdCiW+GkO/Lx702MYaJgNJyVoGPOaJ0GLYo3p7izf0EgMG0Us RAaNIyOljCHEXNj/FSxb4SXEZ9aNCO1u+KES6/zOglttcpfYQvBxsfdRg9WPI7q//Z8P yQIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=dDgurTR72xQAwm2uW0rTCed9zkh000noBvl7lc1v3Mo=; b=V1W7GRm9tchu2BzGBzLyjEDtoxTFJRe7ndQTR7MKXxyLlLT+XhFslwguZVZMmZGrr7 +XSUuJbB4G8hxeauN09tXQN6YImAJn/m6jIGZkOWE21ofPUy3b9dv6eym1kcGp9YMRnU M5IKzaau4KSS0YHjeaL4Vj/RLYqho6jKjVv8NxpbDFw2fozuqLXDa/ue4CWYOgGHJGsN P3B1oaC4u8WCF3twvr6XwBX/l+zaxHh4mDrdMRpy/ALMwTya7jmL/80hCudc1L3LPD5g zSRlcU0D5n3f3NSdSvuktVWrJ0swsnShp/WCQn2wWTH2mDI22jGL/M70FLwQXWNUgNwS MCNg== X-Gm-Message-State: ALyK8tJJ+F89ljmaPvoPA6BU28yj09ntcpBIvHQ6s1KsyoRsq8h34F2wpnH3GQ/ODBriNA== X-Received: by 10.36.147.198 with SMTP id y189mr2623290itd.83.1467513646907; Sat, 02 Jul 2016 19:40:46 -0700 (PDT) Original-Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id n63sm6833126ion.5.2016.07.02.19.40.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jul 2016 19:40:46 -0700 (PDT) In-Reply-To: <87pp2awaqp.fsf@gmail.com> (Oleh Krehel's message of "Wed, 26 Aug 2015 13:27:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120313 Archived-At: tags 21343 confirmed quit Oleh Krehel writes: >> Am 25.08.2015 um 15:11 schrieb Oleh Krehel: >>> To reproduce, paste this code into *scratch*, "|" is the point: >>> >>> ("|foo" >>> ";; (bar)") >>> >>> M-x indent-sexp will result in " ;" being inserted after the sexp. > > `parse-partial-sexp' will detect comment on line 2 only when called in a > sequence that `indent-sexp' calls it, i.e. with the previous pps data > passed to the second pps call. In fact, the problem already occurs on the 1st line: calling `parse-partial-sexp' from within a string gives wrong results, since it doesn't look at the starting quote. You can reproduce the bug with just "|;" A solution could be to use syntax-ppss to go to start of string before parsing (though I wonder if syntax-ppss should be used more for the parsing itself in that case, it seems like there's a lot of work going that probably duplicates what's already being done): diff --git c/lisp/emacs-lisp/lisp-mode.el i/lisp/emacs-lisp/lisp-mode.el index a277d7a..8b5efa3 100644 --- c/lisp/emacs-lisp/lisp-mode.el +++ i/lisp/emacs-lisp/lisp-mode.el @@ -1070,6 +1070,10 @@ indent-sexp ;; Get error now if we don't have a complete sexp after point. (save-excursion (forward-sexp 1))) (save-excursion + (let ((syn-start (nth 8 (syntax-ppss)))) + (when syn-start + (unless endpos (setq starting-point syn-start)) + (goto-char syn-start))) (setq outer-loop-done nil) (while (if endpos (< (point) endpos) (not outer-loop-done))