* tutorial on faces ? @ 2019-02-06 13:38 Jean-Christophe Helary 2019-02-06 15:22 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Jean-Christophe Helary @ 2019-02-06 13:38 UTC (permalink / raw) To: help-gnu-emacs Is there a tutorial somewhere on how to use faces ? Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: tutorial on faces ? 2019-02-06 13:38 tutorial on faces ? Jean-Christophe Helary @ 2019-02-06 15:22 ` Drew Adams 2019-02-06 15:32 ` Jean-Christophe Helary 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2019-02-06 15:22 UTC (permalink / raw) To: Jean-Christophe Helary, help-gnu-emacs > Is there a tutorial somewhere on how to use faces ? What do you mean by "use faces"? There are lots of possible uses of faces, and lots of ways implement such use cases to apply, search for, change,... whatever faces. It might help (you and others) if you elaborated a bit, making your question more specific. Unless you're just asking for info about any tutorials that involve using faces in some way. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: tutorial on faces ? 2019-02-06 15:22 ` Drew Adams @ 2019-02-06 15:32 ` Jean-Christophe Helary 2019-02-06 16:45 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Jean-Christophe Helary @ 2019-02-06 15:32 UTC (permalink / raw) To: help-gnu-emacs > On Feb 7, 2019, at 0:22, Drew Adams <drew.adams@oracle.com> wrote: > >> Is there a tutorial somewhere on how to use faces ? > > What do you mean by "use faces"? There are lots of > possible uses of faces, and lots of ways implement > such use cases to apply, search for, change,... > whatever faces. > > It might help (you and others) if you elaborated a > bit, making your question more specific. Unless > you're just asking for info about any tutorials > that involve using faces in some way. :) Thank you Drew. Well, I'm tweaking poker.el at the moment and I'm looking for ways to apply style to some parts of the messages. Honestly, the elisp manual gives me no idea how to do that... Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: tutorial on faces ? 2019-02-06 15:32 ` Jean-Christophe Helary @ 2019-02-06 16:45 ` Drew Adams 2019-02-07 5:47 ` Jean-Christophe Helary 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2019-02-06 16:45 UTC (permalink / raw) To: Jean-Christophe Helary, help-gnu-emacs > Well, I'm tweaking poker.el at the moment and I'm looking for ways to > apply style to some parts of the messages. > > Honestly, the elisp manual gives me no idea how to do that... OK, good. But what do you mean by "style"? Do you mean that you want to apply a face to some parts of some messages? If so: 1. Do you want to apply the face to the buffer _positions_ of those msg parts, as an _overlay_ property, or do you want to apply it to the _characters_ of those msg parts, as a _text_ property? 2. Are those message parts recognizable/definable in a regular way, i.e., as something that you can define using one or more regexps? And do you want the face highlighting to be automatically reapplied to those parts when the same text is visited anew (in the same mode), e.g. in a new Emacs session or after reverting the buffer? If the answer is yes then look at using `font-lock-mode' to define and highlight those parts. If the answer is no then maybe look at using ad hoc highlighting, such as you get with library `highlight.el': https://www.emacswiki.org/emacs/HighlightLibrary Knowing the answers to these, and perhaps other, questions might help you direct your search for tutorials (e.g. whether to look for tutorials that involve font-lock highlighting). The more you can specify about what you're interested in, the more helpful people and search can be. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: tutorial on faces ? 2019-02-06 16:45 ` Drew Adams @ 2019-02-07 5:47 ` Jean-Christophe Helary 2019-02-07 15:04 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Jean-Christophe Helary @ 2019-02-07 5:47 UTC (permalink / raw) To: help-gnu-emacs > On Feb 7, 2019, at 1:45, Drew Adams <drew.adams@oracle.com> wrote: > >> Well, I'm tweaking poker.el at the moment and I'm looking for ways to >> apply style to some parts of the messages. >> >> Honestly, the elisp manual gives me no idea how to do that... > > OK, good. But what do you mean by "style"? > Do you mean that you want to apply a face to some > parts of some messages? That's correct. Coming from a HTML+CSS background, I thought that I could find a way to: 1) define some styles (for ex. "poker-action" as an already defined emacs standard style) 2) select the strings that need style (for ex "folds|calls|checks|raises") 3) apply the "poker-action" style to the defined selected strings I was thus looking for a way to define styles, a way to select strings (or positions) and a way to apply the style to the selected strings. > If so: > > 1. Do you want to apply the face to the buffer > _positions_ of those msg parts, as an _overlay_ > property, or do you want to apply it to the > _characters_ of those msg parts, as a _text_ > property? I don't know which is more appropriate to what I have. > 2. Are those message parts recognizable/definable > in a regular way, i.e., as something that you > can define using one or more regexps? Yes. > And do > you want the face highlighting to be > automatically reapplied to those parts when > the same text is visited anew (in the same > mode), e.g. in a new Emacs session or after > reverting the buffer? I'm not sure I understand the question. The way I've tweaked poker.el makes it (insert) strings that indicate player actions and results into a dedicated buffer. I'd like the buffer to always display the same style while the buffer exists. There are some echo line (message) strings but I'm fine without having them styled. > If the answer is yes then look at using > `font-lock-mode' to define and highlight those > parts. If the answer is no then maybe look > at using ad hoc highlighting, such as you get > with library `highlight.el': > > https://www.emacswiki.org/emacs/HighlightLibrary So I guess the answer is Yes. > Knowing the answers to these, and perhaps other, > questions might help you direct your search for > tutorials (e.g. whether to look for tutorials > that involve font-lock highlighting). > > The more you can specify about what you're > interested in, the more helpful people and search > can be. Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: tutorial on faces ? 2019-02-07 5:47 ` Jean-Christophe Helary @ 2019-02-07 15:04 ` Drew Adams 2019-02-07 15:15 ` Jean-Christophe Helary 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2019-02-07 15:04 UTC (permalink / raw) To: Jean-Christophe Helary, help-gnu-emacs > > And do you want the face highlighting to be > > automatically reapplied to those parts when > > the same text is visited anew (in the same > > mode), e.g. in a new Emacs session or after > > reverting the buffer? > > I'm not sure I understand the question. Do you want the highlighting to be inherently associated with particular patterns, so that whenever a buffer with those patterns is visited in a particular mode the patterns get highlighted. As opposed to just wanting to highlight something now, but not have the same highlighting done automatically just because you revisit the same text in the same mode later. > The way I've tweaked poker.el makes it (insert) strings that indicate > player actions and results into a dedicated buffer. I'd like the buffer > to always display the same style while the buffer exists. > > There are some echo line (message) strings but I'm fine without having > them styled. Messages in the echo area are a different story. Instead of using font lock there, you just use `propertize' to apply property `face' to the parts of the message you want to highlight, then call function `message'. > > If the answer is yes then look at using > > `font-lock-mode' to define and highlight those > > parts. > > So I guess the answer is Yes. It sounds like it (except for echo-area messaging). I'm guessing you can find tutorials or videos or blogs that introduce font-lock. If not (or even if so), consult the Elisp manual, starting with node Font Lock Mode (`C-h i g (elisp)font lock mode'). https://www.gnu.org/software/emacs/manual/html_node/elisp/Font-Lock-Mode.html Admittedly, that can be heavy going - font lock can be complicated. Start with an intro (e.g. blog), if you find a good one. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: tutorial on faces ? 2019-02-07 15:04 ` Drew Adams @ 2019-02-07 15:15 ` Jean-Christophe Helary 2019-02-07 15:44 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Jean-Christophe Helary @ 2019-02-07 15:15 UTC (permalink / raw) To: help-gnu-emacs > On Feb 8, 2019, at 0:04, Drew Adams <drew.adams@oracle.com> wrote: > >>> And do you want the face highlighting to be >>> automatically reapplied to those parts when >>> the same text is visited anew (in the same >>> mode), e.g. in a new Emacs session or after >>> reverting the buffer? >> >> I'm not sure I understand the question. > > Do you want the highlighting to be inherently > associated with particular patterns, so that > whenever a buffer with those patterns is visited > in a particular mode the patterns get highlighted. Yes. But I'm not sure I can call (my tweaked) poker.el a "mode". It is just a program that outputs strings based on inputs in a dedicated buffer. > I'm guessing you can find tutorials or videos or > blogs that introduce font-lock. If not (or even > if so), consult the Elisp manual, starting with > node Font Lock Mode (`C-h i g (elisp)font lock mode'). > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Font-Lock-Mode.html > > Admittedly, that can be heavy going - font lock can > be complicated. Start with an intro (e.g. blog), if > you find a good one. Thank you. Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: tutorial on faces ? 2019-02-07 15:15 ` Jean-Christophe Helary @ 2019-02-07 15:44 ` Drew Adams 2019-02-07 15:58 ` Jean-Christophe Helary 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2019-02-07 15:44 UTC (permalink / raw) To: Jean-Christophe Helary, help-gnu-emacs > >>> And do you want the face highlighting to be > >>> automatically reapplied to those parts when > >>> the same text is visited anew (in the same > >>> mode), e.g. in a new Emacs session or after > >>> reverting the buffer? > >> > >> I'm not sure I understand the question. > > > > Do you want the highlighting to be inherently > > associated with particular patterns, so that > > whenever a buffer with those patterns is visited > > in a particular mode the patterns get highlighted. > > Yes. But I'm not sure I can call (my tweaked) poker.el a "mode". It is > just a program that outputs strings based on inputs in a dedicated buffer. The buffer is in a (major) mode. You typically define font-lock patterns for a given mode. You can define your own major mode using `define-derived-mode'. I probably should have mentioned this: To highlight parts of a string is one thing - use `propertize' with property `face', for example. To highlight parts of a buffer is something else. You typically use font lock for this. Font lock periodically updates the highlighting, even as you change buffer contents. It applies a set of highlighting rules (regexp patterns, for example), in sequence. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: tutorial on faces ? 2019-02-07 15:44 ` Drew Adams @ 2019-02-07 15:58 ` Jean-Christophe Helary 2019-02-07 17:54 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Jean-Christophe Helary @ 2019-02-07 15:58 UTC (permalink / raw) To: help-gnu-emacs > On Feb 8, 2019, at 0:44, Drew Adams <drew.adams@oracle.com> wrote: > I probably should have mentioned this: To highlight > parts of a string is one thing - use `propertize' > with property `face', for example. > > To highlight parts of a buffer is something else. How is that something else ? > You typically use font lock for this. Font lock > periodically updates the highlighting, even as > you change buffer contents. It applies a set of > highlighting rules (regexp patterns, for example), > in sequence. Isn't it something you'd always want ? Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: tutorial on faces ? 2019-02-07 15:58 ` Jean-Christophe Helary @ 2019-02-07 17:54 ` Drew Adams 0 siblings, 0 replies; 10+ messages in thread From: Drew Adams @ 2019-02-07 17:54 UTC (permalink / raw) To: Jean-Christophe Helary, help-gnu-emacs > > I probably should have mentioned this: To highlight > > parts of a string is one thing - use `propertize' > > with property `face', for example. > > > > To highlight parts of a buffer is something else. > > How is that something else ? See my previous mails. Read about font lock. Look at some existing code that uses it. Buffers are not strings. They don't behave the same and they're not used the same. Buffers have a (major) mode. Buffers are displayed and redisplayed. A string is a string. A message displays a string, typically ephemerally. The echo area and minibuffer are not used like other buffers; in particular, you typically do not try to use font lock there. > > You typically use font lock for this. Font lock > > periodically updates the highlighting, even as > > you change buffer contents. It applies a set of > > highlighting rules (regexp patterns, for example), > > in sequence. > > Isn't it something you'd always want ? See above. Read more about font lock, and maybe read more about buffers and strings. And look at existing code that (1) uses font lock and (2) uses `message' with propertized strings. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-02-07 17:54 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-02-06 13:38 tutorial on faces ? Jean-Christophe Helary 2019-02-06 15:22 ` Drew Adams 2019-02-06 15:32 ` Jean-Christophe Helary 2019-02-06 16:45 ` Drew Adams 2019-02-07 5:47 ` Jean-Christophe Helary 2019-02-07 15:04 ` Drew Adams 2019-02-07 15:15 ` Jean-Christophe Helary 2019-02-07 15:44 ` Drew Adams 2019-02-07 15:58 ` Jean-Christophe Helary 2019-02-07 17:54 ` Drew Adams
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).