all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Handling non-interactive use with faces
@ 2022-08-10 17:23 carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-10 17:36 ` Eli Zaretskii
       [not found] ` <N97m-43--3-2@tutanota.com-N97nByi--3-2>
  0 siblings, 2 replies; 14+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-10 17:23 UTC (permalink / raw)
  To: Help Gnu Emacs

How can this function be made to handle the case of non-interactive use to pass a face for displaying its properties?


(defun laxy-descface (facenm)
  "Describe the typeface properties of face name FACENM."

  (interactive
   (list
    (let* ( (cseq '("default" "mode-line" "mode-line-inactive"
    "list" "text-property")) )
      (completing-read "Face_property: " cseq nil t "text-property"))))

  (pcase facenm
    ("text-property"
        (describe-face (get-text-property (point) 'face)))
    ("default"
        (describe-face (intern facenm)))
    ("mode-line"
        (describe-face (intern facenm)))
    ("mode-line-inactive"
        (describe-face (intern facenm)))
    ("list"
        (list-faces-display))) )




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

* Re: Handling non-interactive use with faces
  2022-08-10 17:23 Handling non-interactive use with faces carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-10 17:36 ` Eli Zaretskii
       [not found] ` <N97m-43--3-2@tutanota.com-N97nByi--3-2>
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2022-08-10 17:36 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 10 Aug 2022 19:23:05 +0200 (CEST)
> From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> 
> How can this function be made to handle the case of non-interactive use to pass a face for displaying its properties?
> 
> 
> (defun laxy-descface (facenm)
>   "Describe the typeface properties of face name FACENM."

You need to add a pcase alternative for a face or face name, and then
you call your function with that face as a single argument.



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

* Re: Handling non-interactive use with faces
       [not found] ` <N97m-43--3-2@tutanota.com-N97nByi--3-2>
@ 2022-08-11 15:56   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-11 16:08     ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-11 15:56 UTC (permalink / raw)
  To: carlmarcos; +Cc: Help Gnu Emacs


Aug 10, 2022, 17:23 by help-gnu-emacs@gnu.org:

> How can this function be made to handle the case of non-interactive use to pass a face for displaying its properties?
>
>
> (defun laxy-descface (facenm)
>   "Describe the typeface properties of face name FACENM."
>
>   (interactive
>    (list
>     (let* ( (cseq '("default" "mode-line" "mode-line-inactive"
>     "list" "text-property")) )
>       (completing-read "Face_property: " cseq nil t "text-property"))))
>
>   (pcase facenm
>     ("text-property"
>         (describe-face (get-text-property (point) 'face)))
>     ("default"
>         (describe-face (intern facenm)))
>     ("mode-line"
>         (describe-face (intern facenm)))
>     ("mode-line-inactive"
>         (describe-face (intern facenm)))
>     ("list"
>         (list-faces-display))) )
>
------- Original Message -------
On Wednesday, August 10th, 2022 at 5:36 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> You need to add a pcase alternative for a face or face name, and then
> you call your function with that face as a single argument.

I am struggling to figure out what kind of `pcase' I should use for the scheme you suggest.




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

* Re: Handling non-interactive use with faces
  2022-08-11 15:56   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-11 16:08     ` Eli Zaretskii
  2022-08-11 18:32       ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-08-11 16:08 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 11 Aug 2022 17:56:23 +0200 (CEST)
> Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
> From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> 
> > You need to add a pcase alternative for a face or face name, and then
> > you call your function with that face as a single argument.
> 
> I am struggling to figure out what kind of `pcase' I should use for the scheme you suggest.

I guess use stringp for face names and facep for faces?



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

* Re: Handling non-interactive use with faces
  2022-08-11 16:08     ` Eli Zaretskii
@ 2022-08-11 18:32       ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-11 18:42         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-11 18:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Aug 11, 2022, 16:08 by eliz@gnu.org:

>> Date: Thu, 11 Aug 2022 17:56:23 +0200 (CEST)
>> Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
>> From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
>>
>> > You need to add a pcase alternative for a face or face name, and then
>> > you call your function with that face as a single argument.
>>
>> I am struggling to figure out what kind of `pcase' I should use for the scheme you suggest.
>>
>
> I guess use stringp for face names and facep for faces?
>
That would require two pcase statements, first to handle face names with stringp, then for faces with facep. 



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

* Re: Handling non-interactive use with faces
  2022-08-11 18:32       ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-11 18:42         ` Eli Zaretskii
  2022-08-11 19:47           ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-08-11 18:42 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 11 Aug 2022 20:32:10 +0200 (CEST)
> From: carlmarcos@tutanota.com
> Cc: help-gnu-emacs@gnu.org
> 
> Aug 11, 2022, 16:08 by eliz@gnu.org:
> 
> >> Date: Thu, 11 Aug 2022 17:56:23 +0200 (CEST)
> >> Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
> >> From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> >>
> >> > You need to add a pcase alternative for a face or face name, and then
> >> > you call your function with that face as a single argument.
> >>
> >> I am struggling to figure out what kind of `pcase' I should use for the scheme you suggest.
> >>
> >
> > I guess use stringp for face names and facep for faces?
> >
> That would require two pcase statements, first to handle face names with stringp, then for faces with facep. 

Yes, and?...

(And why are you using pcase here to begin with?)



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

* Re: Handling non-interactive use with faces
  2022-08-11 18:42         ` Eli Zaretskii
@ 2022-08-11 19:47           ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-12  4:29             ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-11 19:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs



-- 
 Sent with Tutanota, enjoy secure & ad-free emails. 



Aug 11, 2022, 18:42 by eliz@gnu.org:

>> Date: Thu, 11 Aug 2022 20:32:10 +0200 (CEST)
>> From: carlmarcos@tutanota.com
>> Cc: help-gnu-emacs@gnu.org
>>
>> Aug 11, 2022, 16:08 by eliz@gnu.org:
>>
>> >> Date: Thu, 11 Aug 2022 17:56:23 +0200 (CEST)
>> >> Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
>> >> From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
>> >>
>> >> > You need to add a pcase alternative for a face or face name, and then
>> >> > you call your function with that face as a single argument.
>> >>
>> >> I am struggling to figure out what kind of `pcase' I should use for the scheme you suggest.
>> >>
>> >
>> > I guess use stringp for face names and facep for faces?
>> >
>> That would require two pcase statements, first to handle face names with stringp, then for faces with facep.
>>
>
> Yes, and?...
>
> (And why are you using pcase here to begin with?)
>

Have done as follows.  Would you do it differently?

(defun laxy-descface (facenm)
  "Describe the typeface properties of face name FACENM."

  (interactive
   (list
    (let* ( (cseq '("default" "mode-line" "mode-line-inactive"
    "list" "text-property")) )
      (completing-read "Face_property: " cseq nil t "text-property"))))

  (cond
   ((stringp facenm)

    (pcase facenm
      ("text-property"
       (describe-face (get-text-property (point) 'face)))
      ("default"
       (describe-face (intern facenm)))
      ("mode-line"
       (describe-face (intern facenm)))
      ("mode-line-inactive"
       (describe-face (intern facenm)))
      ("list"
       (list-faces-display))) )

   ((facep facenm)
    (describe-face facenm))))



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

* Re: Handling non-interactive use with faces
  2022-08-11 19:47           ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-12  4:29             ` Michael Heerdegen
  2022-08-12  4:34               ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2022-08-12  4:29 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos,

no need to combine pcase and cond.  Either can do the job.  Pick one.
cond is much easier to learn.

Michael.




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

* Re: Handling non-interactive use with faces
  2022-08-12  4:29             ` Michael Heerdegen
@ 2022-08-12  4:34               ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-12 21:43                 ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-12  4:34 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs


Aug 12, 2022, 04:29 by michael_heerdegen@web.de:

> carlmarcos,
>
> no need to combine pcase and cond.  Either can do the job.  Pick one.
> cond is much easier to learn.
>
> Michael.
>
What would you suggest?  How can it be done with just a `cond'?



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

* Re: Handling non-interactive use with faces
  2022-08-12  4:34               ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-12 21:43                 ` Michael Heerdegen
  2022-08-12 21:47                   ` uzibalqa
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2022-08-12 21:43 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Aug 12, 2022, 04:29 by michael_heerdegen@web.de:
>
> > carlmarcos,
> >
> > no need to combine pcase and cond.  Either can do the job.  Pick one.
> > cond is much easier to learn.
> >
> > Michael.
> >
> What would you suggest?  How can it be done with just a `cond'?

Do you have concrete questions about `cond'?  If not, the answer and my
suggestion is: learn a little bit more Elisp.

Michael.




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

* Re: Handling non-interactive use with faces
  2022-08-12 21:43                 ` Michael Heerdegen
@ 2022-08-12 21:47                   ` uzibalqa
  2022-08-12 23:17                     ` Michael Heerdegen
  2022-08-13  5:00                     ` tomas
  0 siblings, 2 replies; 14+ messages in thread
From: uzibalqa @ 2022-08-12 21:47 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

------- Original Message -------
On Friday, August 12th, 2022 at 9:43 PM, Michael Heerdegen <michael_heerdegen@web.de> wrote:


> carlmarcos--- via Users list for the GNU Emacs text editor
> help-gnu-emacs@gnu.org writes:
>
> > Aug 12, 2022, 04:29 by michael_heerdegen@web.de:
> >
> > > carlmarcos,
> > >
> > > no need to combine pcase and cond. Either can do the job. Pick one.
> > > cond is much easier to learn.
> > >
> > > Michael.
> >
> > What would you suggest? How can it be done with just a `cond'?
>
>
> Do you have concrete questions about `cond'? If not, the answer and my
> suggestion is: learn a little bit more Elisp.
>
> Michael.


It was your suggestion that there is no need to combine pcase and cond.  I cannot read your mind and sending me to read a manual until I figure it out is not tho way to follow your idea so I can scrutinise it.



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

* Re: Handling non-interactive use with faces
  2022-08-12 21:47                   ` uzibalqa
@ 2022-08-12 23:17                     ` Michael Heerdegen
  2022-08-12 23:57                       ` uzibalqa
  2022-08-13  5:00                     ` tomas
  1 sibling, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2022-08-12 23:17 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa <uzibalqa@proton.me> writes:

> > carlmarcos--- via Users list for the GNU Emacs text editor

Are you identical with carlmarcos?

> > Do you have concrete questions about `cond'? If not, the answer and my
> > suggestion is: learn a little bit more Elisp.

> It was your suggestion that there is no need to combine pcase and
> cond.  I cannot read your mind and sending me to read a manual until I
> figure it out is not tho way to follow your idea so I can scrutinise
> it.

No need to read my mind, using "cond" is absolutely trivial in this
case, unless you have some kind of misunderstanding (thus my question
about concrete questions) or you still need to learn a basic level
Elisp.

Since you expect people spending their free time to answer questions,
they can expect that you spend at least a minimum of time to understand
how to code Elisp.

And I think our time is spent more effectively if you "read the manual
and figure it out" than when I write it for you.

Feel free to ignore my advice and wait for other answers - just my
personal opinion (and I'm also lazy).

Michael.




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

* Re: Handling non-interactive use with faces
  2022-08-12 23:17                     ` Michael Heerdegen
@ 2022-08-12 23:57                       ` uzibalqa
  0 siblings, 0 replies; 14+ messages in thread
From: uzibalqa @ 2022-08-12 23:57 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs


------- Original Message -------
On Friday, August 12th, 2022 at 11:17 PM, Michael Heerdegen <michael_heerdegen@web.de> wrote:


> uzibalqa uzibalqa@proton.me writes:
>
> > > carlmarcos--- via Users list for the GNU Emacs text editor
>
>
> Are you identical with carlmarcos?
>
> > > Do you have concrete questions about `cond'? If not, the answer and my
> > > suggestion is: learn a little bit more Elisp.
>
> > It was your suggestion that there is no need to combine pcase and
> > cond. I cannot read your mind and sending me to read a manual until I
> > figure it out is not tho way to follow your idea so I can scrutinise
> > it.
>
>
> No need to read my mind, using "cond" is absolutely trivial in this
> case, unless you have some kind of misunderstanding (thus my question
> about concrete questions) or you still need to learn a basic level
> Elisp.

Trivial is a point of view considering I am not capturing your solution.  I know lisp to write a minor-mode.

> Since you expect people spending their free time to answer questions,
> they can expect that you spend at least a minimum of time to understand
> how to code Elisp.

Yes, but not to figure a scheme that you already call trivial.

> And I think our time is spent more effectively if you "read the manual
> and figure it out" than when I write it for you.

The function works well, so I do not think spending super time figuring it out by myself is really vital.

> Feel free to ignore my advice and wait for other answers - just my
> personal opinion (and I'm also lazy).
>
> Michael.





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

* Re: Handling non-interactive use with faces
  2022-08-12 21:47                   ` uzibalqa
  2022-08-12 23:17                     ` Michael Heerdegen
@ 2022-08-13  5:00                     ` tomas
  1 sibling, 0 replies; 14+ messages in thread
From: tomas @ 2022-08-13  5:00 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

On Fri, Aug 12, 2022 at 09:47:52PM +0000, uzibalqa wrote:

[...]

> It was your suggestion that there is no need to combine pcase and cond.  I cannot read your mind and sending me to read a manual until I figure it out is not tho way to follow your idea so I can scrutinise it.

Elisp isn't documented in Michael's mind, it's documented
in the manual (and pretty well so ;-)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2022-08-13  5:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10 17:23 Handling non-interactive use with faces carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-10 17:36 ` Eli Zaretskii
     [not found] ` <N97m-43--3-2@tutanota.com-N97nByi--3-2>
2022-08-11 15:56   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-11 16:08     ` Eli Zaretskii
2022-08-11 18:32       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-11 18:42         ` Eli Zaretskii
2022-08-11 19:47           ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-12  4:29             ` Michael Heerdegen
2022-08-12  4:34               ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-12 21:43                 ` Michael Heerdegen
2022-08-12 21:47                   ` uzibalqa
2022-08-12 23:17                     ` Michael Heerdegen
2022-08-12 23:57                       ` uzibalqa
2022-08-13  5:00                     ` tomas

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.