unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Hyatt <ahyatt@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 4030@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	era+emacsbugs@iki.fi
Subject: bug#4030: forward-sexp parses character literal ?; as comment
Date: Fri, 17 Jun 2016 23:47:07 -0400	[thread overview]
Message-ID: <m21t3vb1l0.fsf@Andrews-MacBook-Pro.local> (raw)
In-Reply-To: <4A813736.8030403@gmx.at> (martin rudalics's message of "Tue, 11 Aug 2009 11:17:42 +0200")


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 <rudalics@gmx.at> 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'."





  reply	other threads:[~2016-06-18  3:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 12:07 bug#4030: forward-sexp parses character literal ?; as comment era+emacsbugs
2009-08-04 12:43 ` martin rudalics
2009-08-05  8:17   ` era+emacsbugs
2009-08-05 14:29     ` martin rudalics
2009-08-06  8:55       ` era+emacsbugs
2009-08-06 18:51       ` Stefan Monnier
2009-08-07 13:01         ` martin rudalics
2009-08-10 19:59           ` Stefan Monnier
2009-08-11  9:17             ` martin rudalics
2016-06-18  3:47               ` Andrew Hyatt [this message]
2016-06-18  4:31                 ` Stefan Monnier
2017-05-13  2:55                   ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21t3vb1l0.fsf@Andrews-MacBook-Pro.local \
    --to=ahyatt@gmail.com \
    --cc=4030@debbugs.gnu.org \
    --cc=era+emacsbugs@iki.fi \
    --cc=monnier@iro.umontreal.ca \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).