all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Interactive option for command application
@ 2024-06-24 20:52 Heime
  2024-06-24 21:36 ` [External] : " Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-06-24 20:52 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

What would be a convenient way for the user to select whether a change is to be made to
a buffer or to a frame?  Currently the user has to enter "yes" or "no' to the question
to set the boolean flag.  Generally, users would perform the change only upon the buffer,
and only occasionally upon the frame.

(defun monfont (face-family face-height okvir)

  (interactive

    (list

      (let ( (cseq '("Wargames" "URW Chancery L" "Century Schoolbook L")) )

        (completing-read " Family Name: " cseq nil t "Century Schoolbook L"))


      (let ( (hseq '("260" "220" "180")) )

        (completing-read " Face Height: " hseq nil t "180")) 


      (yes-or-no-p "Apply to Frame ? ") )) 

  (if okvir
      (do-this)
    (do-that)) )





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

* RE: [External] : Interactive option for command application
  2024-06-24 20:52 Interactive option for command application Heime
@ 2024-06-24 21:36 ` Drew Adams
  2024-06-24 21:51   ` Heime
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2024-06-24 21:36 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor

> What would be a convenient way for the user to select whether a change is
> to be made to
> a buffer or to a frame?  Currently the user has to enter "yes" or "no' to
> the question
> to set the boolean flag.  Generally, users would perform the change only
> upon the buffer,
> and only occasionally upon the frame.

Have a prefix arg use the frame. No prefix arg means use the buffer.

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

* RE: [External] : Interactive option for command application
  2024-06-24 21:36 ` [External] : " Drew Adams
@ 2024-06-24 21:51   ` Heime
  2024-06-24 23:53     ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-06-24 21:51 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor


On Monday, June 24th, 2024 at 9:36 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > What would be a convenient way for the user to select whether a change is
> > to be made to
> > a buffer or to a frame? Currently the user has to enter "yes" or "no' to
> > the question
> > to set the boolean flag. Generally, users would perform the change only
> > upon the buffer,
> > and only occasionally upon the frame.
> 
> 
> Have a prefix arg use the frame. No prefix arg means use the buffer.

How would I handle the prefix arg to do as you suggest ?




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

* RE: [External] : Interactive option for command application
  2024-06-24 21:51   ` Heime
@ 2024-06-24 23:53     ` Drew Adams
  2024-06-25  0:11       ` Heime
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2024-06-24 23:53 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

> > Have a prefix arg use the frame. No prefix arg means use the buffer.
> 
> How would I handle the prefix arg to do as you suggest ?

Consult the manual - look for `interactive'.  Look for `current-prefix-arg' if you use a Lisp sexp as arg to `interactive'.


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

* RE: [External] : Interactive option for command application
  2024-06-24 23:53     ` Drew Adams
@ 2024-06-25  0:11       ` Heime
  2024-06-25  0:22         ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-06-25  0:11 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor


On Monday, June 24th, 2024 at 11:53 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > > Have a prefix arg use the frame. No prefix arg means use the buffer.
> > 
> > How would I handle the prefix arg to do as you suggest ?
> 
> 
> Consult the manual - look for `interactive'. Look for` current-prefix-arg' if you use a Lisp sexp as arg to `interactive'.

Would I have to figure out whether I have '(4) or not, or just an if upon current-prefix-arg ?



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

* RE: [External] : Interactive option for command application
  2024-06-25  0:11       ` Heime
@ 2024-06-25  0:22         ` Drew Adams
  2024-06-25 10:11           ` Heime
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2024-06-25  0:22 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

> > > > Have a prefix arg use the frame. No prefix arg means use the buffer.
> > >
> > > How would I handle the prefix arg to do as you suggest ?
> >
> >
> > Consult the manual - look for `interactive'. Look for` current-prefix-
> arg' if you use a Lisp sexp as arg to `interactive'.
> 
> Would I have to figure out whether I have '(4) or not, or just an if upon
> current-prefix-arg ?

_Consult the doc_.  There are even examples there, IIRC.

`interactive' just passes some args to the body of your command code.  It's the logic of that body code that decides what to do with those args.

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

* RE: [External] : Interactive option for command application
  2024-06-25  0:22         ` Drew Adams
@ 2024-06-25 10:11           ` Heime
  0 siblings, 0 replies; 7+ messages in thread
From: Heime @ 2024-06-25 10:11 UTC (permalink / raw)
  To: Drew Adams; +Cc: Heime via Users list for the GNU Emacs text editor


On Tuesday, June 25th, 2024 at 12:22 AM, Drew Adams <drew.adams@oracle.com> wrote:

> > > > > Have a prefix arg use the frame. No prefix arg means use the buffer.
> > > > 
> > > > How would I handle the prefix arg to do as you suggest ?
> > > 
> > > Consult the manual - look for `interactive'. Look for` current-prefix-
> > > arg' if you use a Lisp sexp as arg to `interactive'.
> > 
> > Would I have to figure out whether I have '(4) or not, or just an if upon
> > current-prefix-arg ?
> 
> 
> Consult the doc. There are even examples there, IIRC.
> 
> `interactive' just passes some args to the body of your command code. 
> It's the logic of that body code that decides what to do with those args.

I have done like this, with a boolean monfont-prefix, I can change whether
I use the prefix or not.  When using the prefix, I set the "Frame" option,
otherwise I use the "Buffer" option.

If not using the prefix argument (monfont-prefix is nil) I ask the user
via completing-read. 

Would this be correct usage with current-prefix-arg ?

(defvar monfont-prefix t

  "Boolean variable determining if monfont uses the prefix argument.")


(defun monfont (face-family face-height okvir)

  (interactive

    (list

      (let ( (cseq '("Wargames" "URW Chancery L" "Century Schoolbook L")) )

        (completing-read " Family Name: " cseq nil t "Bold Oblique"))

      (let ( (hseq '("340" "300" "260" "230" "180")) )

        (completing-read " Face Height: " hseq nil nil "230"))

      (if monfont-prefix

          (if current-prefix-arg "Frame" "Buffer")

        (let ( (hseq '("Frame" "Buffer")) )

          (completing-read " Operation: " hseq nil t "Buffer"))) ))




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

end of thread, other threads:[~2024-06-25 10:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-24 20:52 Interactive option for command application Heime
2024-06-24 21:36 ` [External] : " Drew Adams
2024-06-24 21:51   ` Heime
2024-06-24 23:53     ` Drew Adams
2024-06-25  0:11       ` Heime
2024-06-25  0:22         ` Drew Adams
2024-06-25 10:11           ` Heime

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.