From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.bugs Subject: bug#4030: forward-sexp parses character literal ?; as comment Date: Fri, 17 Jun 2016 23:47:07 -0400 Message-ID: References: <1249387642.18128.1328220453@webmail.messagingengine.com> <4A782D00.4040808@gmx.at> <1249460270.18460.1328376993@webmail.messagingengine.com> <4A799766.9050304@gmx.at> <4A7C25A7.6000900@gmx.at> <4A813736.8030403@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466221706 31482 80.91.229.3 (18 Jun 2016 03:48:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jun 2016 03:48:26 +0000 (UTC) Cc: 4030@debbugs.gnu.org, Stefan Monnier , era+emacsbugs@iki.fi To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 18 05:48:14 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 1bE7Ez-0000x0-PS for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Jun 2016 05:48:14 +0200 Original-Received: from localhost ([::1]:32928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE7Ey-0006hH-Hv for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Jun 2016 23:48:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE7Es-0006gK-Gm for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 23:48:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bE7Eo-00023t-CD for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 23:48:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bE7Eo-00023T-7E for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 23:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bE7En-00025B-Tw for bug-gnu-emacs@gnu.org; Fri, 17 Jun 2016 23:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Hyatt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jun 2016 03:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4030 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 4030-submit@debbugs.gnu.org id=B4030.14662216387954 (code B ref 4030); Sat, 18 Jun 2016 03:48:01 +0000 Original-Received: (at 4030) by debbugs.gnu.org; 18 Jun 2016 03:47:18 +0000 Original-Received: from localhost ([127.0.0.1]:44660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bE7E6-00024E-66 for submit@debbugs.gnu.org; Fri, 17 Jun 2016 23:47:18 -0400 Original-Received: from mail-qk0-f174.google.com ([209.85.220.174]:34542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bE7E4-000242-My for 4030@debbugs.gnu.org; Fri, 17 Jun 2016 23:47:17 -0400 Original-Received: by mail-qk0-f174.google.com with SMTP id s186so105491635qkc.1 for <4030@debbugs.gnu.org>; Fri, 17 Jun 2016 20:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=V5y0fs8CZQXRNcVXNGajFAWk4VHzW6WXs9vPwnwB5ts=; b=kI75pwry9/KdS5fdfk9FuAyXf7oEI5sLZSEp0HMX65zkXmRnPX6Kfi5YEsDNM6Szvv uU1M2iZQVKXkXqXMvDNFhqh7FoR95hSm+V2RH1QlGaQAdF1XKDKOirivoMqKWxMK+F/z Ad4ScDNrNLSQSiHpa/pLLqgWBKedhLOZ3+5Y7U8YOaAftgdTXabhFfMsLP0zQJLOA7UK OBHs+5fOigfO7tp6JjtucJnBwB2/gHX10C/EmW5aftRK6YmgoVSBt7EAjq/0wteFqY3c I9sa2fsfnvwDx6F3ObA0ir7uamJwogG1/JkyQljleo0EWk3p0nmig1C453+7tsOWuwtX EeGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=V5y0fs8CZQXRNcVXNGajFAWk4VHzW6WXs9vPwnwB5ts=; b=LijM0xo50lKM3ung7I24PF1GWMjTF2FOajD/ISc8nrOFCEw0pdIzicYHOOTC+t8AzJ mZpl0GUkOopLght0ZBFsbiv6hbquRaC3NpDUMBuQfFRXXfHu2lV/j5Iy9BEDpiL0GUi/ eYtUULqcfmZHUY/Qu8Ty4a96FvDxsCsIg9TymkIxDDayJJYCvLbER3bCxOC7j7QG8wsU IXllp8/IKi4n6vu/Shr32washAUZuTmn6TDqnYzsqQBGt0MgUSPBUsmbAWPW1HY3FOZW AVUZ8jPrHu7nawSkzfpZWSVKR9NZ1NhFP3jgf8n7gcvEKFzb7i2662VmZn0rxw79cuZ0 p8Uw== X-Gm-Message-State: ALyK8tKxD+oUjnH+XlS2fEG14+8h7TQ+rEeU4ccwjM3S4kIRJETMNdSyddqoYWjDLNy7WQ== X-Received: by 10.55.119.66 with SMTP id s63mr4851699qkc.63.1466221630215; Fri, 17 Jun 2016 20:47:10 -0700 (PDT) Original-Received: from Andrews-MacBook-Pro.local (cpe-74-73-128-199.nyc.res.rr.com. [74.73.128.199]) by smtp.gmail.com with ESMTPSA id p39sm11748918qtp.14.2016.06.17.20.47.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 20:47:08 -0700 (PDT) In-Reply-To: <4A813736.8030403@gmx.at> (martin rudalics's message of "Tue, 11 Aug 2009 11:17:42 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (darwin) 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:119710 Archived-At: This problem still exists in Emacs 25, and this was the last message in the thread. When I try this, though, I do at least see the issue pretty clearly due to font-locking. Does anyone have any further thoughts? It wasn't clear to me from this discussion whether there was any consensus that this was actually a bug or not. martin rudalics writes: >> Yes, but we need to do that even on chunks of code that have not yet >> been (and may never be) displayed and in buffers where font-lock >> is disabled. IOW I'm not talking about fontification but about parsing. > > Sure. But I was only talking about the possibility to highlight such > instances just like we do with column 0 parens in strings already. > >> Pretty much, yes, tho the error message should give more info (the OP >> complained about lack of info in the error message). > > That's what the ellipsis stands for. But what info? Guessing a good > buffer position seems next to impossible. Where else can `forward-sexp' > go astray when called from a top-level position? > >>> But do we really have to scan the buffer in the first place? >> >> Don't know. Maybe not, indeed. Maybe it's just to detect the "too many >> closing parens" case as well (i.e. rather than silently ignore trailing >> code). > > We could simply search for (concat "^(" (symbol-name symbol))) and do a > `forward-sexp' over the form starting there as in the attached patch. I > see no reason why we should try to handle an .emacs broken before or > after that form. > > martin > > *** cus-edit.el.~1.364.~ 2009-07-27 08:09:05.997162900 +0200 > --- cus-edit.el 2009-08-11 10:51:21.812500000 +0200 > *************** > *** 4338,4374 **** > > This function does not save the buffer." > (goto-char (point-min)) > ! ;; Skip all whitespace and comments. > ! (while (forward-comment 1)) > ! (or (eobp) > ! (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors. > ! (let (first) > ! (catch 'found > ! (while t ;; We exit this loop only via throw. > ! ;; Skip all whitespace and comments. > ! (while (forward-comment 1)) > ! (let ((start (point)) > ! (sexp (condition-case nil > ! (read (current-buffer)) > ! (end-of-file (throw 'found nil))))) > ! (when (and (listp sexp) > ! (eq (car sexp) symbol)) > ! (delete-region start (point)) > ! (unless first > ! (setq first (point))))))) > ! (if first > ! (goto-char first) > ! ;; Move in front of local variables, otherwise long Custom > ! ;; entries would make them ineffective. > ! (let ((pos (point-max)) > ! (case-fold-search t)) > ! (save-excursion > ! (goto-char (point-max)) > ! (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) > ! 'move) > ! (when (search-forward "Local Variables:" nil t) > ! (setq pos (line-beginning-position)))) > ! (goto-char pos))))) > > (defun custom-save-variables () > "Save all customized variables in `custom-file'." > --- 4338,4364 ---- > > This function does not save the buffer." > (goto-char (point-min)) > ! (if (re-search-forward (concat "^(" (symbol-name symbol))) > ! (let ((from (goto-char (match-beginning 0))) > ! (to (condition-case nil > ! (progn > ! (forward-sexp) > ! (point)) > ! (error nil)))) > ! (if to > ! (delete-region from to) > ! (error "Malformed %s expression" symbol))) > ! ;; Move in front of local variables, otherwise long Custom > ! ;; entries would make them ineffective. > ! (let ((pos (point-max)) > ! (case-fold-search t)) > ! (save-excursion > ! (goto-char (point-max)) > ! (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) > ! 'move) > ! (when (search-forward "Local Variables:" nil t) > ! (setq pos (line-beginning-position)))) > ! (goto-char pos)))) > > (defun custom-save-variables () > "Save all customized variables in `custom-file'."