all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Changing completion-style using the minibuffer
@ 2021-06-11 20:02 arvid-harnack
  2021-06-12  2:49 ` Jean Louis
  0 siblings, 1 reply; 3+ messages in thread
From: arvid-harnack @ 2021-06-11 20:02 UTC (permalink / raw)
  To: help-gnu-emacs

I have the following code to change completion-styles by calling "M-x minibufrp-complt-style".



But would like to change it so that I can go through the four selections using the minibuffer.

What would I need to add exactly to be able to do so ?



(defvar k 1)

(defun minibufrp-complt-style ()
  
  (interactive)
  (pcase k
    (1
       (setq completion-styles '(basic substring))
       (setq k 2))
    (2
       (setq completion-styles '(partial-completion))
       (setq k 3))
    (3
       (setq completion-styles '(initials))
       (setq k 4))
    (4
       (setq completion-styles '(orderless))
       (setq k 1)) ))



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

* Re: Changing completion-style using the minibuffer
  2021-06-11 20:02 Changing completion-style using the minibuffer arvid-harnack
@ 2021-06-12  2:49 ` Jean Louis
  2021-06-12 14:27   ` arvid-harnack
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Louis @ 2021-06-12  2:49 UTC (permalink / raw)
  To: arvid-harnack; +Cc: help-gnu-emacs

* arvid-harnack@lavache.com <arvid-harnack@lavache.com> [2021-06-11 23:03]:
> I have the following code to change completion-styles by calling "M-x minibufrp-complt-style".
> 
> 
> 
> But would like to change it so that I can go through the four selections using the minibuffer.
> 
> What would I need to add exactly to be able to do so ?


(defvar k 1)

In itself the below function is just looking to variable `k' and
makes changes based on its value. If you wish to change the
variable `completion-styles' you need not have any other
variable.
 
(defun minibufrp-complt-style ()
  (interactive)
  (pcase k
    (1
     (setq completion-styles '(basic substring))
     (setq k 2))
    (2
     (setq completion-styles '(partial-completion))
     (setq k 3))
    (3
     (setq completion-styles '(initials))
     (setq k 4))
    (4
     (setq completion-styles '(orderless))
     (setq k 1)) ))

Following could be solution for multiple choice:

(defun minibufrp-complt-style ()
  (interactive)
  (let* ((collection '((?b '(basic substring) "Basic Substring")
		       (?p '(partial-completion) "Partial Completion")
		       (?i '(initials) "Initials")
		       (?o '(orderless) "Orderless")))
	 (style (read-multiple-choice "Style: " collection)))
    (setq completion-styles (nth 1 style))))

Overall that does not nicely solve the problem as you may wish to
have multiple completion styles in the variable
`completion-styles' and you may get in trouble doing it that way.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Changing completion-style using the minibuffer
  2021-06-12  2:49 ` Jean Louis
@ 2021-06-12 14:27   ` arvid-harnack
  0 siblings, 0 replies; 3+ messages in thread
From: arvid-harnack @ 2021-06-12 14:27 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

Is there an alternative to your attempt, so I could use the arrow
keys to move from one option to the other?

And an option at the and that allows me to manually write down
the completion-styles string in the minibuffer.

That way I can either use the predefined settings in collections
or input my own multiple completion style string in the variable
`completion-styles'.



Many Thanks




From: Jean Louis <bugs@gnu.support>
To: arvid-harnack@lavache.com
Subject: Re: Changing completion-style using the minibuffer
Date: 12/06/2021 04:49:38 Europe/Paris
Cc: help-gnu-emacs@gnu.org

* arvid-harnack@lavache.com <arvid-harnack@lavache.com> [2021-06-11 23:03]:
> I have the following code to change completion-styles by calling "M-x minibufrp-complt-style".
> 
> 
> 
> But would like to change it so that I can go through the four selections using the minibuffer.
> 
> What would I need to add exactly to be able to do so ?


(defvar k 1)

In itself the below function is just looking to variable `k' and
makes changes based on its value. If you wish to change the
variable `completion-styles' you need not have any other
variable.

(defun minibufrp-complt-style ()
(interactive)
(pcase k
(1
(setq completion-styles '(basic substring))
(setq k 2))
(2
(setq completion-styles '(partial-completion))
(setq k 3))
(3
(setq completion-styles '(initials))
(setq k 4))
(4
(setq completion-styles '(orderless))
(setq k 1)) ))

Following could be solution for multiple choice:

(defun minibufrp-complt-style ()
(interactive)
(let* ((collection '((?b '(basic substring) "Basic Substring")
(?p '(partial-completion) "Partial Completion")
(?i '(initials) "Initials")
(?o '(orderless) "Orderless")))
(style (read-multiple-choice "Style: " collection)))
(setq completion-styles (nth 1 style))))

Overall that does not nicely solve the problem as you may wish to
have multiple completion styles in the variable
`completion-styles' and you may get in trouble doing it that way.


-- 
Jean




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

end of thread, other threads:[~2021-06-12 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-11 20:02 Changing completion-style using the minibuffer arvid-harnack
2021-06-12  2:49 ` Jean Louis
2021-06-12 14:27   ` arvid-harnack

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.