unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Prettify keywords
@ 2021-02-03 13:19 pietru
  2021-02-03 16:23 ` Stefan Monnier
  0 siblings, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 13:19 UTC (permalink / raw)
  To: Help Gnu Emacs

I would like to change prog-mode.el from a major mode to a minor mode
for texinfo.  What do I need to do?

I am looking at the functionality for prettify, to change certain
keywords to a specific glyph.  This is done in tex-mode.el and
in dafny-mode.el in boogie-friends.  Are they using the same technique,
or are the two strategies different?






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

* Re: Prettify keywords
  2021-02-03 13:19 Prettify keywords pietru
@ 2021-02-03 16:23 ` Stefan Monnier
  2021-02-03 17:07   ` pietru
  0 siblings, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 16:23 UTC (permalink / raw)
  To: help-gnu-emacs

> I would like to change prog-mode.el from a major mode to a minor mode
> for texinfo.  What do I need to do?

I think you need to think again.  Wanting to change `prog-mode` to
a minor mode seems to me like a very clear sign that you're confused
either about what are major and minor modes, or about what is
`prog-mode` or about what it is you want to do.


        Stefan




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

* Re: Prettify keywords
  2021-02-03 16:23 ` Stefan Monnier
@ 2021-02-03 17:07   ` pietru
  2021-02-03 17:40     ` Stefan Monnier
  0 siblings, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 17:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs


I want to prettify tex commands, so that things like \alpha is shown
with the greek letter.  The calls are however in texinfo files.  If
I call tex-mode, the texinfo highlighting from texinfo-mode gets
disabled.



> Sent: Thursday, February 04, 2021 at 4:23 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> > I would like to change prog-mode.el from a major mode to a minor mode
> > for texinfo.  What do I need to do?
>
> I think you need to think again.  Wanting to change `prog-mode` to
> a minor mode seems to me like a very clear sign that you're confused
> either about what are major and minor modes, or about what is
> `prog-mode` or about what it is you want to do.
>
>
>         Stefan
>
>
>



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

* Re: Prettify keywords
  2021-02-03 17:07   ` pietru
@ 2021-02-03 17:40     ` Stefan Monnier
  2021-02-03 17:45       ` pietru
  0 siblings, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 17:40 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs

> I want to prettify tex commands, so that things like \alpha is shown
> with the greek letter.  The calls are however in texinfo files.  If
> I call tex-mode, the texinfo highlighting from texinfo-mode gets
> disabled.

I have no idea how you go from the above to wanting `prog-mode` to be
a minor mode.

But AFAICT you do know that one obvious answer to your need is to set
`prettify-symbols-alist` and enable `prettify-symbols-mode`.


        Stefan




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

* Re: Prettify keywords
  2021-02-03 17:40     ` Stefan Monnier
@ 2021-02-03 17:45       ` pietru
  2021-02-03 19:57         ` Stefan Monnier
  0 siblings, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 17:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs


> Sent: Thursday, February 04, 2021 at 5:40 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> > I want to prettify tex commands, so that things like \alpha is shown
> > with the greek letter.  The calls are however in texinfo files.  If
> > I call tex-mode, the texinfo highlighting from texinfo-mode gets
> > disabled.
>
> I have no idea how you go from the above to wanting `prog-mode` to be
> a minor mode.
>
> But AFAICT you do know that one obvious answer to your need is to set
> `prettify-symbols-alist` and enable `prettify-symbols-mode`.

But that does not work in texinfo-mode.

>
>         Stefan
>
>



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

* Re: Prettify keywords
  2021-02-03 17:45       ` pietru
@ 2021-02-03 19:57         ` Stefan Monnier
  2021-02-03 19:58           ` pietru
  0 siblings, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 19:57 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs

>> But AFAICT you do know that one obvious answer to your need is to set
>> `prettify-symbols-alist` and enable `prettify-symbols-mode`.
> But that does not work in texinfo-mode.

Worked in my tests.


        Stefan




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

* Re: Prettify keywords
  2021-02-03 19:57         ` Stefan Monnier
@ 2021-02-03 19:58           ` pietru
  2021-02-03 20:27             ` Stefan Monnier
  0 siblings, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 19:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

How do you do it?

> Sent: Thursday, February 04, 2021 at 7:57 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> >> But AFAICT you do know that one obvious answer to your need is to set
> >> `prettify-symbols-alist` and enable `prettify-symbols-mode`.
> > But that does not work in texinfo-mode.
>
> Worked in my tests.
>
>
>         Stefan
>
>



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

* Re: Prettify keywords
  2021-02-03 19:58           ` pietru
@ 2021-02-03 20:27             ` Stefan Monnier
  2021-02-03 20:36               ` pietru
  0 siblings, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 20:27 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs

> How do you do it?

I tested it "in the obvious way".  I think someone sent a sample code
in this thread which did pretty much the same as I had done.

What do *you* do that doesn't seem to work?


        Stefan




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

* Re: Prettify keywords
  2021-02-03 20:27             ` Stefan Monnier
@ 2021-02-03 20:36               ` pietru
  2021-02-03 20:39                 ` Gregory Heytings
  2021-02-03 22:11                 ` Stefan Monnier
  0 siblings, 2 replies; 28+ messages in thread
From: pietru @ 2021-02-03 20:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

You don't want to give me any information at all?

I try with "M-x texinfo-mode", followed by "M-x prettify-mode".

> Sent: Thursday, February 04, 2021 at 8:27 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> > How do you do it?
>
> I tested it "in the obvious way".  I think someone sent a sample code
> in this thread which did pretty much the same as I had done.
>
> What do *you* do that doesn't seem to work?
>
>
>         Stefan
>
>
>



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

* Re: Prettify keywords
  2021-02-03 20:36               ` pietru
@ 2021-02-03 20:39                 ` Gregory Heytings
  2021-02-03 20:56                   ` pietru
  2021-02-03 22:11                 ` Stefan Monnier
  1 sibling, 1 reply; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 20:39 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs, Stefan Monnier


>
> You don't want to give me any information at all?
>
> I try with "M-x texinfo-mode", followed by "M-x prettify-mode".
>

Here's a copy of the message I sent you three days ago:

Follow Stefan's advice:

(add-hook 'texinfo-mode-hook
           (lambda ()
             (push '("\\alpha" . ?α) prettify-symbols-alist)
             (push '("\\beta" . ?β) prettify-symbols-alist)))

This only affects the way "\alpha" and "\beta" are displayed, and you can 
turn it on or off with M-x prettify-symbols-mode .  If you want to turn it 
on by default, do:

(add-hook 'texinfo-mode-hook
           (lambda ()
             (push '("\\alpha" . ?α) prettify-symbols-alist)
             (push '("\\beta" . ?β) prettify-symbols-alist)
             (prettify-symbols-mode)))


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

* Re: Prettify keywords
  2021-02-03 20:39                 ` Gregory Heytings
@ 2021-02-03 20:56                   ` pietru
  2021-02-03 21:13                     ` Gregory Heytings
  0 siblings, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 20:56 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs, Stefan Monnier

Thank you.  Where can I find the code for it?  Does it use prog-mode
functionality?

> Sent: Thursday, February 04, 2021 at 8:39 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org, "Stefan Monnier" <monnier@iro.umontreal.ca>
> Subject: Re: Prettify keywords
>
> 
> >
> > You don't want to give me any information at all?
> >
> > I try with "M-x texinfo-mode", followed by "M-x prettify-mode".
> >
> 
> Here's a copy of the message I sent you three days ago:
> 
> Follow Stefan's advice:
> 
> (add-hook 'texinfo-mode-hook
>            (lambda ()
>              (push '("\\alpha" . ?α) prettify-symbols-alist)
>              (push '("\\beta" . ?β) prettify-symbols-alist)))
> 
> This only affects the way "\alpha" and "\beta" are displayed, and you can 
> turn it on or off with M-x prettify-symbols-mode .  If you want to turn it 
> on by default, do:
> 
> (add-hook 'texinfo-mode-hook
>            (lambda ()
>              (push '("\\alpha" . ?α) prettify-symbols-alist)
>              (push '("\\beta" . ?β) prettify-symbols-alist)
>              (prettify-symbols-mode)))
>



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

* Re: Prettify keywords
  2021-02-03 20:56                   ` pietru
@ 2021-02-03 21:13                     ` Gregory Heytings
  2021-02-03 21:21                       ` pietru
  2021-02-03 21:26                       ` pietru
  0 siblings, 2 replies; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 21:13 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs


>
> Thank you.  Where can I find the code for it?  Does it use prog-mode 
> functionality?
>

I don't understand your questions, nor how they are related to your 
original question, but here's an attempt to answer them anyway:

"Where can I find the code for it?"  The "foo-mode-hook" variables are 
evaluated when a buffer with a mode "foo" is entered.  If you want to see 
this for Texinfo, type C-h v texinfo-mode-hook RET, which will open a 
window with a link to "texinfo.el", which you can follow: it will open the 
"texinfo.el" file at the point where "texinfo-mode-hook" is defined.

"Does it use prog-mode functionality?"  No, "texinfo-mode" is a major mode 
for Texinfo files, and it has no relation to "prog-mode", which is a major 
mode for source code files (Python, Java, C, ...).



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

* Re: Prettify keywords
  2021-02-03 21:13                     ` Gregory Heytings
@ 2021-02-03 21:21                       ` pietru
  2021-02-03 21:27                         ` Gregory Heytings
  2021-02-03 21:26                       ` pietru
  1 sibling, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 21:21 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

I am asking where does texinfo-mode call prettify.  And which prettify code
is it using.

> Sent: Thursday, February 04, 2021 at 9:13 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
>
> >
> > Thank you.  Where can I find the code for it?  Does it use prog-mode
> > functionality?
> >
>
> I don't understand your questions, nor how they are related to your
> original question, but here's an attempt to answer them anyway:
>
> "Where can I find the code for it?"  The "foo-mode-hook" variables are
> evaluated when a buffer with a mode "foo" is entered.  If you want to see
> this for Texinfo, type C-h v texinfo-mode-hook RET, which will open a
> window with a link to "texinfo.el", which you can follow: it will open the
> "texinfo.el" file at the point where "texinfo-mode-hook" is defined.
>
> "Does it use prog-mode functionality?"  No, "texinfo-mode" is a major mode
> for Texinfo files, and it has no relation to "prog-mode", which is a major
> mode for source code files (Python, Java, C, ...).
>



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

* Re: Prettify keywords
  2021-02-03 21:13                     ` Gregory Heytings
  2021-02-03 21:21                       ` pietru
@ 2021-02-03 21:26                       ` pietru
  1 sibling, 0 replies; 28+ messages in thread
From: pietru @ 2021-02-03 21:26 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

I am also trying to perform prettif when I have \alpha-\beta
\alpha_n and ethor characters such as ^ :

Have tried using

"\\\\\\<alpha+\\>\\([\s+\,:;._^-]\\\\\\<[a-z]+\\>\\)?"
But the prettify is not being executed.

> Sent: Thursday, February 04, 2021 at 9:13 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
>
> >
> > Thank you.  Where can I find the code for it?  Does it use prog-mode
> > functionality?
> >
>
> I don't understand your questions, nor how they are related to your
> original question, but here's an attempt to answer them anyway:
>
> "Where can I find the code for it?"  The "foo-mode-hook" variables are
> evaluated when a buffer with a mode "foo" is entered.  If you want to see
> this for Texinfo, type C-h v texinfo-mode-hook RET, which will open a
> window with a link to "texinfo.el", which you can follow: it will open the
> "texinfo.el" file at the point where "texinfo-mode-hook" is defined.
>
> "Does it use prog-mode functionality?"  No, "texinfo-mode" is a major mode
> for Texinfo files, and it has no relation to "prog-mode", which is a major
> mode for source code files (Python, Java, C, ...).
>



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

* Re: Prettify keywords
  2021-02-03 21:21                       ` pietru
@ 2021-02-03 21:27                         ` Gregory Heytings
  2021-02-03 21:31                           ` pietru
  2021-02-03 21:37                           ` pietru
  0 siblings, 2 replies; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 21:27 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs


>
> I am asking where does texinfo-mode call prettify.  And which prettify 
> code is it using.
>

Texinfo-mode does not call prettify-symbols-mode (I believe no mode does 
that by default), which is why I wrote:

If you want to turn [prettify-symbols-mode] on by default, do:

(add-hook 'texinfo-mode-hook
           (lambda ()
             (push '("\\alpha" . ?α) prettify-symbols-alist)
             (push '("\\beta" . ?β) prettify-symbols-alist)
             (prettify-symbols-mode)))

In the last line, "(prettify-symbols-mode)" calls prettify-symbols-mode. 
If you want to see the code of "prettify-symbols-mode", type C-h f 
prettify-symbols-mode RET TAB RET.


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

* Re: Prettify keywords
  2021-02-03 21:27                         ` Gregory Heytings
@ 2021-02-03 21:31                           ` pietru
  2021-02-03 21:37                             ` Gregory Heytings
  2021-02-03 21:37                           ` pietru
  1 sibling, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 21:31 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

I can see a bit what you mean.  prettify-symbols-mode is then a minor mode
that I can use with the texinfo major mode.  Correct me if I am wrong please.

> Sent: Thursday, February 04, 2021 at 9:27 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> 
> >
> > I am asking where does texinfo-mode call prettify.  And which prettify 
> > code is it using.
> >
> 
> Texinfo-mode does not call prettify-symbols-mode (I believe no mode does 
> that by default), which is why I wrote:
> 
> If you want to turn [prettify-symbols-mode] on by default, do:
> 
> (add-hook 'texinfo-mode-hook
>            (lambda ()
>              (push '("\\alpha" . ?α) prettify-symbols-alist)
>              (push '("\\beta" . ?β) prettify-symbols-alist)
>              (prettify-symbols-mode)))
> 
> In the last line, "(prettify-symbols-mode)" calls prettify-symbols-mode. 
> If you want to see the code of "prettify-symbols-mode", type C-h f 
> prettify-symbols-mode RET TAB RET.
>



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

* Re: Prettify keywords
  2021-02-03 21:27                         ` Gregory Heytings
  2021-02-03 21:31                           ` pietru
@ 2021-02-03 21:37                           ` pietru
  2021-02-03 21:41                             ` Gregory Heytings
  1 sibling, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 21:37 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

Have looked at prettify-symbols-mode and it is defined in prog-mode.el.
This gets me quite confused as I thought that I can only activate a single
major mode at a time on a particular buffer.

Thank you for helping me make some progress on this as I thought that the
prettify functionality would be hard to implement on tex commands whilst I
am in texinfo-mode.

> Sent: Thursday, February 04, 2021 at 9:27 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> 
> >
> > I am asking where does texinfo-mode call prettify.  And which prettify 
> > code is it using.
> >
> 
> Texinfo-mode does not call prettify-symbols-mode (I believe no mode does 
> that by default), which is why I wrote:
> 
> If you want to turn [prettify-symbols-mode] on by default, do:
> 
> (add-hook 'texinfo-mode-hook
>            (lambda ()
>              (push '("\\alpha" . ?α) prettify-symbols-alist)
>              (push '("\\beta" . ?β) prettify-symbols-alist)
>              (prettify-symbols-mode)))
> 
> In the last line, "(prettify-symbols-mode)" calls prettify-symbols-mode. 
> If you want to see the code of "prettify-symbols-mode", type C-h f 
> prettify-symbols-mode RET TAB RET.
>



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

* Re: Prettify keywords
  2021-02-03 21:31                           ` pietru
@ 2021-02-03 21:37                             ` Gregory Heytings
  2021-02-03 21:42                               ` pietru
  2021-02-03 22:16                               ` Stefan Monnier
  0 siblings, 2 replies; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 21:37 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs


>
> I can see a bit what you mean.  prettify-symbols-mode is then a minor 
> mode that I can use with the texinfo major mode.  Correct me if I am 
> wrong please.
>

Yes, that's correct.  As you see in the code: "(define-minor-mode 
prettify-symbols-mode ...".  It is a minor mode which, as any other minor 
mode, you can use with any major mode.



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

* Re: Prettify keywords
  2021-02-03 21:37                           ` pietru
@ 2021-02-03 21:41                             ` Gregory Heytings
  2021-02-03 21:48                               ` pietru
  2021-02-03 22:26                               ` pietru
  0 siblings, 2 replies; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 21:41 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs


>
> Have looked at prettify-symbols-mode and it is defined in prog-mode.el. 
> This gets me quite confused
>

I understand, but it shouldn't confuse you.  It happens to be defined in 
the file prog-mode.el, but it is nonetheless independent from prog-mode.

>
> as I thought that I can only activate a single major mode at a time on a 
> particular buffer.
>

That's correct indeed.



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

* Re: Prettify keywords
  2021-02-03 21:37                             ` Gregory Heytings
@ 2021-02-03 21:42                               ` pietru
  2021-02-03 22:05                                 ` Gregory Heytings
  2021-02-03 22:16                               ` Stefan Monnier
  1 sibling, 1 reply; 28+ messages in thread
From: pietru @ 2021-02-03 21:42 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

Equipped with this information my task would not be too difficult to
implement.  I thought of giving up on it.

Would it be possible to include the code in a minor mode that I am writing
for texinfo?  The minor mode is called crucible.  So I can have 

(defun pretty ()
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (prettify-symbols-mode))

(add-hook 'texinfo-mode-hook #'pretty)




> Sent: Thursday, February 04, 2021 at 9:37 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> 
> >
> > I can see a bit what you mean.  prettify-symbols-mode is then a minor 
> > mode that I can use with the texinfo major mode.  Correct me if I am 
> > wrong please.
> >
> 
> Yes, that's correct.  As you see in the code: "(define-minor-mode 
> prettify-symbols-mode ...".  It is a minor mode which, as any other minor 
> mode, you can use with any major mode.
>



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

* Re: Prettify keywords
  2021-02-03 21:41                             ` Gregory Heytings
@ 2021-02-03 21:48                               ` pietru
  2021-02-03 22:26                               ` pietru
  1 sibling, 0 replies; 28+ messages in thread
From: pietru @ 2021-02-03 21:48 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs



> Sent: Thursday, February 04, 2021 at 9:41 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
>
> >
> > Have looked at prettify-symbols-mode and it is defined in prog-mode.el.
> > This gets me quite confused
> >
>
> I understand, but it shouldn't confuse you.  It happens to be defined in
> the file prog-mode.el, but it is nonetheless independent from prog-mode.
>
> >
> > as I thought that I can only activate a single major mode at a time on a
> > particular buffer.
> >
>
> That's correct indeed.

But as you have said, one can define an independent minor mode that can
still be defined within an elisp file implementing a minor mode.

My original problem started when I decided to integrate the functionalities
in plain-tex-mode (in tex-mode.el) within texinfo-mode.  Did not realise
the minor mode prettify-mode existed, that is separate from tex-mode.el.




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

* Re: Prettify keywords
  2021-02-03 21:42                               ` pietru
@ 2021-02-03 22:05                                 ` Gregory Heytings
  2021-02-03 22:12                                   ` pietru
  0 siblings, 1 reply; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 22:05 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs


>
> Would it be possible to include the code in a minor mode that I am 
> writing for texinfo? The minor mode is called crucible.
>

I don't understand why you want to create another minor mode, but in 
principle yes, you can include such code in a minor mode.  As you see in 
the documentation of "define-minor-mode", the last argument "BODY" is 
executed each time the mode is enabled or disabled.  And as you see in the 
"prettify-symbols-mode" minor mode example, you should embed the code in a 
conditional to turn it on and off alternately.



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

* Re: Prettify keywords
  2021-02-03 20:36               ` pietru
  2021-02-03 20:39                 ` Gregory Heytings
@ 2021-02-03 22:11                 ` Stefan Monnier
  2021-02-03 22:17                   ` pietru
  1 sibling, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 22:11 UTC (permalink / raw)
  To: pietru; +Cc: help-gnu-emacs

> You don't want to give me any information at all?

I think people have been feeding you a lot of info in this
thread already.

The problem seems to be on your end now, where you're having trouble to
understand/use this info.  It's OK, it's no fault of yours, but you need
to help us understand what it is you don't understand, otherwise we'll
just keep sending info which you fail to be able to use.

> Where can I find the code for it?

Try `M-.` when you have point on top of the name of a function (in
a buffer using emacs-lisp-mode).


        Stefan




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

* Re: Prettify keywords
  2021-02-03 22:05                                 ` Gregory Heytings
@ 2021-02-03 22:12                                   ` pietru
  0 siblings, 0 replies; 28+ messages in thread
From: pietru @ 2021-02-03 22:12 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs



> Sent: Thursday, February 04, 2021 at 10:05 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
>
> >
> > Would it be possible to include the code in a minor mode that I am
> > writing for texinfo? The minor mode is called crucible.
> >
>
> I don't understand why you want to create another minor mode

I still have to include the tex symbols to the list.  But I also have
a minor mode for tex commands that prettifies mathematical expressions
that use superscripts and subscripts.  I might include the prettify
keywords for tex in the minor mode itself rather than having the code
separate.

, but in
> principle yes, you can include such code in a minor mode.  As you see in
> the documentation of "define-minor-mode", the last argument "BODY" is
> executed each time the mode is enabled or disabled.  And as you see in the
> "prettify-symbols-mode" minor mode example, you should embed the code in a
> conditional to turn it on and off alternately.
>



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

* Re: Prettify keywords
  2021-02-03 21:37                             ` Gregory Heytings
  2021-02-03 21:42                               ` pietru
@ 2021-02-03 22:16                               ` Stefan Monnier
  2021-02-03 22:33                                 ` Gregory Heytings
  1 sibling, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2021-02-03 22:16 UTC (permalink / raw)
  To: help-gnu-emacs

> prettify-symbols-mode ...".  It is a minor mode which, as any other minor
> mode, you can use with any major mode.

FWIW, this is not quite true: there are some minor modes which only work
with some particular major mode(s).


        Stefan




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

* Re: Prettify keywords
  2021-02-03 22:11                 ` Stefan Monnier
@ 2021-02-03 22:17                   ` pietru
  0 siblings, 0 replies; 28+ messages in thread
From: pietru @ 2021-02-03 22:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs



> Sent: Thursday, February 04, 2021 at 10:11 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> > You don't want to give me any information at all?
>
> I think people have been feeding you a lot of info in this
> thread already.

Yes, but net enough to get me unstuck from the mess of having tex commands
when I am in texinfo mode.

> The problem seems to be on your end now, where you're having trouble to
> understand/use this info.  It's OK, it's no fault of yours, but you need
> to help us understand what it is you don't understand, otherwise we'll
> just keep sending info which you fail to be able to use.

Now I understand.  Thank you.

> > Where can I find the code for it?
>
> Try `M-.` when you have point on top of the name of a function (in
> a buffer using emacs-lisp-mode).
>
>
>         Stefan
>
>
>



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

* Re: Prettify keywords
  2021-02-03 21:41                             ` Gregory Heytings
  2021-02-03 21:48                               ` pietru
@ 2021-02-03 22:26                               ` pietru
  1 sibling, 0 replies; 28+ messages in thread
From: pietru @ 2021-02-03 22:26 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

Currently I can use the following code, which will take care of
"\alpha" and "\alpha\beta".  But not "\alpha-\beta" or 
"\alpha+\beta" which are completely appropriate in mathematical
expressions.  Can this be achieved such that  "\alpha-\beta"
gives α-β.

(defun pretty ()
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (prettify-symbols-mode))



> Sent: Thursday, February 04, 2021 at 9:41 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Prettify keywords
>
> 
> >
> > Have looked at prettify-symbols-mode and it is defined in prog-mode.el. 
> > This gets me quite confused
> >
> 
> I understand, but it shouldn't confuse you.  It happens to be defined in 
> the file prog-mode.el, but it is nonetheless independent from prog-mode.
> 
> >
> > as I thought that I can only activate a single major mode at a time on a 
> > particular buffer.
> >
> 
> That's correct indeed.
>



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

* Re: Prettify keywords
  2021-02-03 22:16                               ` Stefan Monnier
@ 2021-02-03 22:33                                 ` Gregory Heytings
  0 siblings, 0 replies; 28+ messages in thread
From: Gregory Heytings @ 2021-02-03 22:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs


>> prettify-symbols-mode ...".  It is a minor mode which, as any other 
>> minor mode, you can use with any major mode.
>
> FWIW, this is not quite true: there are some minor modes which only work 
> with some particular major mode(s).
>

Yes, of course, but I was trying to provide him with simple, unambiguous 
information ;-)



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

end of thread, other threads:[~2021-02-03 22:33 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-03 13:19 Prettify keywords pietru
2021-02-03 16:23 ` Stefan Monnier
2021-02-03 17:07   ` pietru
2021-02-03 17:40     ` Stefan Monnier
2021-02-03 17:45       ` pietru
2021-02-03 19:57         ` Stefan Monnier
2021-02-03 19:58           ` pietru
2021-02-03 20:27             ` Stefan Monnier
2021-02-03 20:36               ` pietru
2021-02-03 20:39                 ` Gregory Heytings
2021-02-03 20:56                   ` pietru
2021-02-03 21:13                     ` Gregory Heytings
2021-02-03 21:21                       ` pietru
2021-02-03 21:27                         ` Gregory Heytings
2021-02-03 21:31                           ` pietru
2021-02-03 21:37                             ` Gregory Heytings
2021-02-03 21:42                               ` pietru
2021-02-03 22:05                                 ` Gregory Heytings
2021-02-03 22:12                                   ` pietru
2021-02-03 22:16                               ` Stefan Monnier
2021-02-03 22:33                                 ` Gregory Heytings
2021-02-03 21:37                           ` pietru
2021-02-03 21:41                             ` Gregory Heytings
2021-02-03 21:48                               ` pietru
2021-02-03 22:26                               ` pietru
2021-02-03 21:26                       ` pietru
2021-02-03 22:11                 ` Stefan Monnier
2021-02-03 22:17                   ` pietru

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