bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#70321: Can not turn completion-at-point on a per-mode basis on modes


From: Eshel Yaron
Subject: bug#70321: Can not turn completion-at-point on a per-mode basis on modes derived from text-mode
Date: Thu, 11 Apr 2024 07:52:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Eli, Pedro,

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
>> Date: Wed, 10 Apr 2024 09:08:08 +0200
>>
>> Place the following file as init.el in a directory (e.g. ~/.demacs.d)
>>
>> ---cut here---
>> (setq inhibit-startup-screen t)
>>
>> (defun auto-complete-text-off ()
>>   (message "Trying to turn off ispell completion...")
>>   (setopt text-mode-ispell-word-completion nil))
>>
>> (add-hook 'org-mode-hook #'auto-complete-text-off)
>> (add-hook 'org-mode-hook #'(lambda()
>>                              (ispell-change-dictionary "en_GB")
>>                              (flyspell-mode t)))
>> ---cut here---
>>
>> Open a text file and C-h C-v completion-at-point-functions. You should see
>> ispell-completion-at-point in the list of completion functions
>>
>> Open a .org file and C-h C-v completion-at-point-functions. You see
>> ispell-completion-at-point in the list of completion functions, when the 
>> expected behaviour
>> is that ispell-completion-at-point is *not* in the list.
>
> You cannot set this option in a mode hook, that's not how it is
> supposed to be used.  If you customize the option to nil, any buffer
> under Text mode or its derivative created afterwards will have the
> completion turned off, that's the intended use of the option.
>
> If you want to disable the completion selectively in a mode hook of
> some descendant of Text mode, you need to remove
> ispell-completion-at-point from the appropriate hook explicitly:
>
>   (defun auto-complete-text-off ()
>     (message "Trying to turn off ispell completion...")
>     (remove-hook 'completion-at-point-functions #'ispell-completion-at-point 
> t))
>
> I see no bug here, just a misunderstanding.
>
> Eshel, am I missing something here?

I don't think you're missing anything here.  ispell-completion-at-point
is just a function that can either be in completion-at-point-functions
or not.  The option text-mode-ispell-word-completion controls whether
text-mode adds ispell-completion-at-point to c-a-p-f initially, but
users can also always rely on add/remove-hook to manage it directly.


Best,

Eshel





reply via email to

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