From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastien Vauban Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Custom option to turn Flyspell mode on in prog modes Date: Thu, 14 Aug 2014 14:46:51 +0200 Organization: Sebastien Vauban Message-ID: <86fvgz8chw.fsf@somewhere.org> References: <87ppp6vpjv.fsf@gmail.com> <2643591.vy3k34KHB8@descartes> <87fvpzuge2.fsf@gmail.com> <6936196.xMpHYqAt7Y@descartes> <877g2ijxrw.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1408020498 13676 80.91.229.3 (14 Aug 2014 12:48:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Aug 2014 12:48:18 +0000 (UTC) To: emacs-devel-mXXj517/zsQ@public.gmane.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org-mXXj517/zsQ@public.gmane.org Thu Aug 14 14:48:10 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XHuRs-0002R7-OO for ged-emacs-devel@m.gmane.org; Thu, 14 Aug 2014 14:48:08 +0200 Original-Received: from localhost ([::1]:53871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHuRs-00089O-5G for ged-emacs-devel@m.gmane.org; Thu, 14 Aug 2014 08:48:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHuRh-000891-Vt for emacs-devel-mXXj517/zsQ@public.gmane.org; Thu, 14 Aug 2014 08:48:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHuRa-0003lY-FA for emacs-devel-mXXj517/zsQ@public.gmane.org; Thu, 14 Aug 2014 08:47:57 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHuRa-0003lU-8J for emacs-devel-mXXj517/zsQ@public.gmane.org; Thu, 14 Aug 2014 08:47:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XHuRY-0002K2-J3 for emacs-devel-mXXj517/zsQ@public.gmane.org; Thu, 14 Aug 2014 14:47:48 +0200 Original-Received: from dd5e0353a.access.telenet.be ([213.224.53.58]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 14:47:48 +0200 Original-Received: from sva-news by dd5e0353a.access.telenet.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 14:47:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 59 Original-X-Complaints-To: usenet-dbVV3NMTNubNLxjTenLetw@public.gmane.org X-Gmane-NNTP-Posting-Host: dd5e0353a.access.telenet.be X-Url: Under construction... X-Archive: encrypt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (windows-nt) Cancel-Lock: sha1:+1D6wSpyjtF8PV45u+Dtmo89pg8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.devel:173660 Archived-At: Juri Linkov wrote: >>> > Looks good. But I don't think `turn-on-flyspell-prog' is needed >>> > because `flyspell-prog-mode' already turns the mode on >>> > unconditionally. (Although maybe the latter should be >>> > reconsidered.) >>> >>> You are right. The following works well. >> >> Sorry for the long delay. I have applied the patch (r117667) and also added >> `prettify-symbols-mode' to the list. > > BTW, could someone suggest how to turn Flyspell mode only on typing > new text, but not on moving point over the existing text? Would it be > good to have a new custom option as well? I've tried such ugly hacks, > but they don't work well: > > ;; Flyspell only on typing, not on moving point > (add-hook 'flyspell-mode-hook > (lambda () > (remove-hook 'post-command-hook (function flyspell-post-command-hook) t) > (add-hook 'after-change-functions > (lambda (start stop len) > (flyspell-post-command-hook)) t t))) > > ;; Alternative solution for Flyspell only on typing, not on moving point > (add-hook 'flyspell-mode-hook > (lambda () > (advice-add 'flyspell-check-pre-word-p :override (lambda () nil)) > ;; After evaluating the next, flyspell doesn't check the last word > ;; in `auto-fill-mode' when typing SPC moves to the next line, > ;; because the order of calls in `internal_self_insert' is: > ;; 1. insert_and_inherit (); > ;; 2. Frun_hook_with_args (Qafter_change_functions); > ;; 3. auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function)); > ;; 4. Frun_hooks (1, &Qpost_self_insert_hook); > (advice-add 'flyspell-check-word-p :override (lambda () nil)))) Why don't they work well? Note that an approach that seduced me was to only check the buffer once it gets modified. --8<---------------cut here---------------start------------->8--- (add-hook 'first-change-hook #'(lambda () (when (and (memq major-mode my-flyspell-major-mode-list) (not flyspell-mode)) (my-turn-on-flyspell-french)))) --8<---------------cut here---------------end--------------->8--- However, I have dropped that because it had problems as well -- though, I don't remember which ones exactly (done during Org mode exports or so?). Best regards, Seb -- Sebastien Vauban