From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#4030: forward-sexp parses character literal ?; as comment Date: Tue, 11 Aug 2009 11:17:42 +0200 Message-ID: <4A813736.8030403@gmx.at> 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> Reply-To: martin rudalics , 4030@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020208070503030001080608" X-Trace: ger.gmane.org 1249982982 24581 80.91.229.12 (11 Aug 2009 09:29:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2009 09:29:42 +0000 (UTC) Cc: era+emacsbugs@iki.fi, 4030@emacsbugs.donarmstrong.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 11 11:29:34 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Manfh-0007G9-SV for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Aug 2009 11:29:34 +0200 Original-Received: from localhost ([127.0.0.1]:58628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Manfg-0003et-Dd for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Aug 2009 05:29:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MandC-0002hP-4Q for bug-gnu-emacs@gnu.org; Tue, 11 Aug 2009 05:26:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mand6-0002en-B4 for bug-gnu-emacs@gnu.org; Tue, 11 Aug 2009 05:26:56 -0400 Original-Received: from [199.232.76.173] (port=42228 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mand6-0002eZ-3u for bug-gnu-emacs@gnu.org; Tue, 11 Aug 2009 05:26:52 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:50983) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mand5-0005x1-HX for bug-gnu-emacs@gnu.org; Tue, 11 Aug 2009 05:26:51 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7B9QmgO011740; Tue, 11 Aug 2009 02:26:48 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n7B9P44a011441; Tue, 11 Aug 2009 02:25:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 11 Aug 2009 09:25:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4030 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4030-submit@emacsbugs.donarmstrong.com id=B4030.124998239610905 (code B ref 4030); Tue, 11 Aug 2009 09:25:04 +0000 Original-Received: (at 4030) by emacsbugs.donarmstrong.com; 11 Aug 2009 09:19:56 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with SMTP id n7B9JrAP010897 for <4030@emacsbugs.donarmstrong.com>; Tue, 11 Aug 2009 02:19:55 -0700 Original-Received: (qmail invoked by alias); 11 Aug 2009 09:19:47 -0000 Original-Received: from 62-47-35-215.adsl.highway.telekom.at (EHLO [62.47.35.215]) [62.47.35.215] by mail.gmx.net (mp032) with SMTP; 11 Aug 2009 11:19:47 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+uj/52bv2u6/zxIb2VSCuh7id0mCKgQN02K6BkbX nSuYmA3MRWoOPW User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: X-Y-GMX-Trusted: 0 X-FuHaFi: 0.67,0.5600000000000001 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Tue, 11 Aug 2009 05:26:56 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:30093 Archived-At: This is a multi-part message in MIME format. --------------020208070503030001080608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > 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 --------------020208070503030001080608 Content-Type: text/plain; name="cus-edit.el.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cus-edit.el.diff" *** 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'." --------------020208070503030001080608--