emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Custom option to turn Flyspell mode on in prog modes


From: Sebastien Vauban
Subject: Re: [PATCH] Custom option to turn Flyspell mode on in prog modes
Date: Thu, 14 Aug 2014 14:46:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (windows-nt)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]