|
From: | Tom Tromey |
Subject: | Re: Smie-auto-fill doesn’t respect comment-auto-fill-only-comments |
Date: | Tue, 02 May 2017 12:57:26 -0600 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
>>>>> "Stefan" == Stefan Monnier <address@hidden> 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
[Prev in Thread] | Current Thread | [Next in Thread] |