unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Smie-auto-fill doesn’t respect comment-auto-fill-only-comments
Date: Tue, 02 May 2017 12:57:26 -0600	[thread overview]
Message-ID: <87mvavw0h5.fsf@pokyo> (raw)
In-Reply-To: <jwv8tmhokas.fsf-monnier+gmane.emacs.devel@gnu.org> (Stefan Monnier's message of "Sun, 30 Apr 2017 13:52:44 -0400")

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> This won't fix the SMIE issue though.  That would require a similar fix
>>> in smie-auto-fill.
>> We should try and find a solution which doesn't require changing every
>> normal-auto-fill-function.

Stefan> I think the patch below "does the trick" but it's rather ugly.

I think the idea of changing auto-fill-mode to handle this case is
better than what I was doing.

However, I also agree that the advice is ugly...

Stefan> +                   (setq auto-fill-function normal-auto-fill-function)
Stefan> +                   (add-function :around normal-auto-fill-function
Stefan> +                                 (lambda (orig-fun &rest args)
Stefan> +                                   (if (and comment-start
Stefan> +		                            comment-auto-fill-only-comments
Stefan> +                                            (not (nth 4 (syntax-ppss))))
Stefan> +                                       ;; Comments exist and we only want to
Stefan> +                                       ;; auto-fill them but we're not in one!
Stefan> +                                       nil
Stefan> +                                     (apply orig-fun args))))))))

Could this just setq auto-fill-function to a function that wraps (the
captured value of) normal-auto-fill-function?  That would avoid using advice.

Tom



  reply	other threads:[~2017-05-02 18:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 12:04 Smie-auto-fill doesn’t respect comment-auto-fill-only-comments Nikolai Weibull
2017-04-23 19:31 ` Nikolai Weibull
2017-04-25  0:18   ` Ian Dunn
2017-04-30 16:52 ` Tom Tromey
2017-04-30 17:08   ` Stefan Monnier
2017-04-30 17:52     ` Stefan Monnier
2017-05-02 18:57       ` Tom Tromey [this message]
2017-05-02 19:18         ` Stefan Monnier
2017-05-03  1:14           ` Ian Dunn
2017-05-21 16:43           ` Tom Tromey
2017-05-21 21:03             ` Stefan Monnier
2017-05-22  6:24               ` Tom Tromey
2017-05-22 19:12                 ` Stefan Monnier
2017-05-29 21:20                   ` Tom Tromey
2017-05-30  3:25                     ` Stefan Monnier
2017-08-05 20:39                       ` Tom Tromey
2017-08-05 20:50                         ` 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

  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=87mvavw0h5.fsf@pokyo \
    --to=tom@tromey.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).