unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Passing user selection to a command
@ 2024-03-19 10:01 Heime
  2024-03-19 11:01 ` Bruno Barbier
  0 siblings, 1 reply; 8+ messages in thread
From: Heime @ 2024-03-19 10:01 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

How can I pass the user selection to 'activate-input-method' ?


(defun glossus ()

  (interactive
   (list
    (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
                     "italian-postfix")) )
      (completing-read
        " Glossus: " cseq nil t "italian-postfix"))))

  (setq ispell-local-dictionary "it_IT")
  (activate-input-method "italian-postfix") )




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 10:01 Passing user selection to a command Heime
@ 2024-03-19 11:01 ` Bruno Barbier
  2024-03-19 12:21   ` Heime
  0 siblings, 1 reply; 8+ messages in thread
From: Bruno Barbier @ 2024-03-19 11:01 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor


Hi,

Heime <heimeborgia@protonmail.com> writes:

> How can I pass the user selection to 'activate-input-method' ?
>
>
> (defun glossus ()
>
>   (interactive
>    (list
>     (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
>                      "italian-postfix")) )
>       (completing-read
>         " Glossus: " cseq nil t "italian-postfix"))))
>
>   (setq ispell-local-dictionary "it_IT")
>   (activate-input-method "italian-postfix") )

IIUC, you could do this:

    (defun my-glossus (user-sel)  ;; <==== var name here
      (interactive 
       (list
        (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
                       "italian-postfix")) )
          (completing-read
           " Glossus: " cseq nil t "italian-postfix"))))

      (setq ispell-local-dictionary "it_IT")
      (activate-input-method user-sel))
      

Bruno



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 11:01 ` Bruno Barbier
@ 2024-03-19 12:21   ` Heime
  2024-03-19 12:32     ` Bruno Barbier
  0 siblings, 1 reply; 8+ messages in thread
From: Heime @ 2024-03-19 12:21 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Tuesday, March 19th, 2024 at 11:01 PM, Bruno Barbier <brubar.cs@gmail.com> wrote:

> Hi,
> 
> Heime heimeborgia@protonmail.com writes:
> 
> > How can I pass the user selection to 'activate-input-method' ?
> > 
> > (defun glossus ()
> > 
> > (interactive
> > (list
> > (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
> > "italian-postfix")) )
> > (completing-read
> > " Glossus: " cseq nil t "italian-postfix"))))
> > 
> > (setq ispell-local-dictionary "it_IT")
> > (activate-input-method "italian-postfix") )
> 
> 
> IIUC, you could do this:
> 
> (defun my-glossus (user-sel) ;; <==== var name here
> (interactive
> (list
> (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
> "italian-postfix")) )
> (completing-read
> " Glossus: " cseq nil t "italian-postfix"))))
> 
> (setq ispell-local-dictionary "it_IT")
> (activate-input-method user-sel))
> 
> Bruno

The documentation states that if some other input method is already active,
it is to be turned off first.  How can I make the function do this ?






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 12:21   ` Heime
@ 2024-03-19 12:32     ` Bruno Barbier
  2024-03-19 14:19       ` Heime
  0 siblings, 1 reply; 8+ messages in thread
From: Bruno Barbier @ 2024-03-19 12:32 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> Sent with Proton Mail secure email.
>
> On Tuesday, March 19th, 2024 at 11:01 PM, Bruno Barbier <brubar.cs@gmail.com> wrote:
>
>> Hi,
>> 
>> Heime heimeborgia@protonmail.com writes:
>> 
>> > How can I pass the user selection to 'activate-input-method' ?
>> > 
>> > (defun glossus ()
>> > 
>> > (interactive
>> > (list
>> > (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
>> > "italian-postfix")) )
>> > (completing-read
>> > " Glossus: " cseq nil t "italian-postfix"))))
>> > 
>> > (setq ispell-local-dictionary "it_IT")
>> > (activate-input-method "italian-postfix") )
>> 
>> 
>> IIUC, you could do this:
>> 
>> (defun my-glossus (user-sel) ;; <==== var name here
>> (interactive
>> (list
>> (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
>> "italian-postfix")) )
>> (completing-read
>> " Glossus: " cseq nil t "italian-postfix"))))
>> 
>> (setq ispell-local-dictionary "it_IT")
>> (activate-input-method user-sel))
>> 
>> Bruno
>
> The documentation states that if some other input method is already active,
> it is to be turned off first.  How can I make the function do this ?

The documentation of `activate-input-method' ?
  | If INPUT-METHOD is nil, deactivate any current input method.

IIUB (if I understand better ;-) ), as I'm reading it, it says that
`activate-input-method' will take care to turn previous methods OFF.
You don't have to do anything.

Bruno






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 12:32     ` Bruno Barbier
@ 2024-03-19 14:19       ` Heime
  2024-03-19 15:56         ` Bruno Barbier
  2024-03-19 16:11         ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 8+ messages in thread
From: Heime @ 2024-03-19 14:19 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Wednesday, March 20th, 2024 at 12:32 AM, Bruno Barbier <brubar.cs@gmail.com> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > Sent with Proton Mail secure email.
> > 
> > On Tuesday, March 19th, 2024 at 11:01 PM, Bruno Barbier brubar.cs@gmail.com wrote:
> > 
> > > Hi,
> > > 
> > > Heime heimeborgia@protonmail.com writes:
> > > 
> > > > How can I pass the user selection to 'activate-input-method' ?
> > > > 
> > > > (defun glossus ()
> > > > 
> > > > (interactive
> > > > (list
> > > > (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
> > > > "italian-postfix")) )
> > > > (completing-read
> > > > " Glossus: " cseq nil t "italian-postfix"))))
> > > > 
> > > > (setq ispell-local-dictionary "it_IT")
> > > > (activate-input-method "italian-postfix") )
> > > 
> > > IIUC, you could do this:
> > > 
> > > (defun my-glossus (user-sel) ;; <==== var name here
> > > (interactive
> > > (list
> > > (let ( (cseq '("italian-alt-postfix" "italian-keyboard"
> > > "italian-postfix")) )
> > > (completing-read
> > > " Glossus: " cseq nil t "italian-postfix"))))
> > > 
> > > (setq ispell-local-dictionary "it_IT")
> > > (activate-input-method user-sel))
> > > 
> > > Bruno
> > 
> > The documentation states that if some other input method is already active,
> > it is to be turned off first. How can I make the function do this ?
> 
> 
> The documentation of `activate-input-method' ? | If INPUT-METHOD is nil, deactivate any current input method. IIUB (if I understand better ;-) ), as I'm reading it, it says that` activate-input-method' will take care to turn previous methods OFF.
> You don't have to do anything.
> 
> Bruno

The documentation for activate-input-method says

"If some other input method is already active, turn it off first."

It is not very clear whether the user should turn it off, or whether the
activate-input-method function will turn INPUT-METHOD off automatically.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 14:19       ` Heime
@ 2024-03-19 15:56         ` Bruno Barbier
  2024-03-19 16:26           ` Heime
  2024-03-19 16:11         ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 8+ messages in thread
From: Bruno Barbier @ 2024-03-19 15:56 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

>
> The documentation for activate-input-method says
>
> "If some other input method is already active, turn it off first."
>
> It is not very clear whether the user should turn it off, or whether the
> activate-input-method function will turn INPUT-METHOD off automatically.

I'm not a native speaker; I agree it could be both.  I've even checked
the source code before answering to be sure ;-)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 14:19       ` Heime
  2024-03-19 15:56         ` Bruno Barbier
@ 2024-03-19 16:11         ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-03-19 16:11 UTC (permalink / raw)
  To: help-gnu-emacs

> The documentation for activate-input-method says
>
> "If some other input method is already active, turn it off first."
>
> It is not very clear whether the user should turn it off, or whether the
> activate-input-method function will turn INPUT-METHOD off automatically.

It becomes more clear once you're familiar with the way docstrings are
written: they usually describe what the function does rather than what
the caller should do.  So when they say something about what the caller
should do, they usually do so explicitly.

IOW, if the user needs to turn it off first, the docstring would say
something like "some other IM should not be already active" or "if some
other IM is already active, do nothing".


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Passing user selection to a command
  2024-03-19 15:56         ` Bruno Barbier
@ 2024-03-19 16:26           ` Heime
  0 siblings, 0 replies; 8+ messages in thread
From: Heime @ 2024-03-19 16:26 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: Heime via Users list for the GNU Emacs text editor


On Wednesday, March 20th, 2024 at 3:56 AM, Bruno Barbier <brubar.cs@gmail.com> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > The documentation for activate-input-method says
> > 
> > "If some other input method is already active, turn it off first."
> > 
> > It is not very clear whether the user should turn it off, or whether the
> > activate-input-method function will turn INPUT-METHOD off automatically.
> 
> 
> I'm not a native speaker; I agree it could be both. I've even checked
> the source code before answering to be sure ;-)

Changing the documentation to clarify the behavior of activate-input-method 
would indeed be beneficial for users.   If the documentation clearly explains
whether activate-input-method turns off the current input method automatically
before activating the new one, or if users need to explicitly deactivate it 
with set-input-method, they can make informed decisions.

Correct Usage: Clear documentation hel



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-19 16:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 10:01 Passing user selection to a command Heime
2024-03-19 11:01 ` Bruno Barbier
2024-03-19 12:21   ` Heime
2024-03-19 12:32     ` Bruno Barbier
2024-03-19 14:19       ` Heime
2024-03-19 15:56         ` Bruno Barbier
2024-03-19 16:26           ` Heime
2024-03-19 16:11         ` Stefan Monnier via Users list for the GNU Emacs text editor

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).