all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: 15251@debbugs.gnu.org
Subject: bug#15251: 24.3.50; do-auto-fill "continues" comment from inside a string
Date: Sun, 29 Sep 2013 15:12:57 +0200	[thread overview]
Message-ID: <52482759.1070804@easy-emacs.de> (raw)
In-Reply-To: <87y56gwa5m.fsf@yandex.ru>

Am 29.09.2013 05:59, schrieb Dmitry Gutov:
> Dmitry Gutov <dgutov@yandex.ru> writes:
>
>> In certain conditions, if I press SPC, and a string on the current line
>> contains text matching `comment-start-skip', the filling is performed,
>> and the newly created line starts with a comment.
>>
>> Examples (point is at |, fill-column is 70):
>>
>> ruby-mode:
>>
>> aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa#{}a" a|
>>
>> press SPC =>
>>
>> aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa#{}a"
>>                                  #a
>>
>> js-mode:
>>
>> aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//a" aa|
>>
>> press SPC =>
>>
>> aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//a"
>> //aa
>
> I've tracked this to misbehaving `comment-beginning'. Since we start
> outside of string, and the comment char(s) are inside the string on the
> same line, the check comparing the face at point to
> `font-lock-string-face' doesn't work.
>
> And in ruby-mode's case, since interpolations use a different face, even
> putting a similar guard to check at `cs' won't help.
>
> As I see it, we either have to use `syntax-ppss' here, or trust
> font-lock. The latter means not skipping other checks even if
> `comment-end-skip' is defined and doesn't match at point, and also
> only trusting "let's assume ... if we're on the same line" when
> font-lock-mode is disabled.
>
> How does this change look? Seems to work fine.
>
> (As an aside, I'm having hard time understanding which search is
> supposed to have set the match data used by `(match-end 0)' there. Is it
> `comment-search-backward'? Or `(looking-at comment-end-skip)'?)
>
> === modified file 'lisp/newcomment.el'
> --- lisp/newcomment.el	2013-06-18 17:57:56 +0000
> +++ lisp/newcomment.el	2013-09-29 03:41:18 +0000
> @@ -526,12 +526,13 @@
>   	      (and
>   	       ;; For modes where comment-start and comment-end are the same,
>   	       ;; the search above may have found a `ce' rather than a `cs'.
> -	       (or (if comment-end-skip (not (looking-at comment-end-skip)))
> -		   ;; Maybe font-lock knows that it's a `cs'?
> +               (if comment-end-skip (not (looking-at comment-end-skip)))
> +	       (or ;; Maybe font-lock knows that it's a `cs'?
>   		   (eq (get-text-property (match-end 0) 'face)
>   		       'font-lock-comment-face)
> -		   (unless (eq (get-text-property (point) 'face)
> -			       'font-lock-comment-face)
> +		   (unless (or (eq (get-text-property (point) 'face)
> +                                   'font-lock-comment-face)
> +                               font-lock-mode)
>   		     ;; Let's assume it's a `cs' if we're on the same line.
>   		     (>= (line-end-position) pt)))
>   	       ;; Make sure that PT is not past the end of the comment.
>
>
>
>
>

Reading the face for detecting basic things like comment is terrible.
What did the author smoke when writing this ;)

BTW from my experience jumping to (nth 8 (syntax-ppss)) works well.









  reply	other threads:[~2013-09-29 13:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03  1:26 bug#15251: 24.3.50; do-auto-fill "continues" comment from inside a string Dmitry Gutov
2013-09-29  3:59 ` Dmitry Gutov
2013-09-29 13:12   ` Andreas Röhler [this message]
2013-09-29 15:16     ` Dmitry Gutov
2013-09-30 18:27       ` Stefan Monnier
2013-10-01  1:18         ` Dmitry Gutov
2013-10-01 14:11           ` Stefan Monnier
2013-10-01 15:40             ` Dmitry Gutov
2013-10-02  0:32               ` Stefan Monnier
2013-10-02  0:50                 ` Dmitry Gutov
2013-10-02  7:22         ` Andreas Röhler
2013-10-02 11:19           ` Dmitry Gutov
2013-10-02 12:24             ` Andreas Röhler
2013-10-02 12:25               ` Dmitry Gutov
2013-10-02 14:08                 ` Andreas Röhler
2013-10-04  2:09                   ` Dmitry Gutov
2013-09-30 18:26   ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=52482759.1070804@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=15251@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.