GNU bug report logs - #59828
Fundamental Mode buffers fail to keep text properties

Previous Next

Package: emacs;

Reported by: Heime <heimeborgia <at> protonmail.com>

Date: Mon, 5 Dec 2022 06:31:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59828 in the body.
You can then email your comments to 59828 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 06:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Heime <heimeborgia <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 05 Dec 2022 06:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 06:30:28 +0000
Have noticed that when I insert text with colour properties in a buffer
using fundamental-mode, the text properties (e.g. colours) get lost.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 06:34:02 GMT) Full text and rfc822 format available.

Message #8 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Sun, 4 Dec 2022 22:32:58 -0800

> On Dec 4, 2022, at 10:30 PM, Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs <at> gnu.org> wrote:
> 
> 
> Have noticed that when I insert text with colour properties in a buffer
> using fundamental-mode, the text properties (e.g. colours) get lost.

I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 08:32:01 GMT) Full text and rfc822 format available.

Message #11 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 08:30:51 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 6:32 AM, Yuan Fu <casouri <at> gmail.com> wrote:


> > On Dec 4, 2022, at 10:30 PM, Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors bug-gnu-emacs <at> gnu.org wrote:
> > 
> > Have noticed that when I insert text with colour properties in a buffer
> > using fundamental-mode, the text properties (e.g. colours) get lost.
> 
> 
> I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?
> 
> Yuan

I used 'font-lock-face and did not work.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 12:47:02 GMT) Full text and rfc822 format available.

Message #14 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Heime <heimeborgia <at> protonmail.com>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 14:46:13 +0200
> Cc: 59828 <at> debbugs.gnu.org
> Date: Mon, 05 Dec 2022 08:30:51 +0000
> From:  Heime via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> > > Have noticed that when I insert text with colour properties in a buffer
> > > using fundamental-mode, the text properties (e.g. colours) get lost.
> > 
> > 
> > I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?
> > 
> > Yuan
> 
> I used 'font-lock-face and did not work.

Please show the code you used.  It works here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 13:50:01 GMT) Full text and rfc822 format available.

Message #17 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 13:49:28 +0000

------- Original Message -------
On Monday, December 5th, 2022 at 12:46 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:


> > Cc: 59828 <at> debbugs.gnu.org
> > Date: Mon, 05 Dec 2022 08:30:51 +0000
> > From: Heime via "Bug reports for GNU Emacs,
> > the Swiss army knife of text editors" bug-gnu-emacs <at> gnu.org
> > 
> > > > Have noticed that when I insert text with colour properties in a buffer
> > > > using fundamental-mode, the text properties (e.g. colours) get lost.
> > > 
> > > I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?
> > > 
> > > Yuan
> > 
> > I used 'font-lock-face and did not work.
> 
> 
> Please show the code you used. It works here.


(with-current-buffer (get-buffer-create bufrn)
  (insert (propertize "G"
             'font-lock-face '(:background "green"
                               :foreground "black"))))









Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 14:43:02 GMT) Full text and rfc822 format available.

Message #20 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Heime <heimeborgia <at> protonmail.com>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 16:41:41 +0200
> Date: Mon, 05 Dec 2022 13:49:28 +0000
> From: Heime <heimeborgia <at> protonmail.com>
> Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> 
> > > > > Have noticed that when I insert text with colour properties in a buffer
> > > > > using fundamental-mode, the text properties (e.g. colours) get lost.
> > > > 
> > > > I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?
> > > > 
> > > > Yuan
> > > 
> > > I used 'font-lock-face and did not work.
> > 
> > 
> > Please show the code you used. It works here.
> 
> 
> (with-current-buffer (get-buffer-create bufrn)
>   (insert (propertize "G"
>              'font-lock-face '(:background "green"
>                                :foreground "black"))))

From the ELisp manual:

  ‘font-lock-face’
       This property specifies a value for the ‘face’ property that Font
       Lock mode should apply to the underlying text.  It is one of the
       fontification methods used by Font Lock mode, and is useful for
       special modes that implement their own highlighting.  *Note
       Precalculated Fontification::.  When Font Lock mode is disabled,
       ‘font-lock-face’ has no effect.

Note the last sentence.

Conclusion: you need to turn on font-lock in that buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 14:56:02 GMT) Full text and rfc822 format available.

Message #23 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 14:54:47 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 2:41 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:


> > Date: Mon, 05 Dec 2022 13:49:28 +0000
> > From: Heime heimeborgia <at> protonmail.com
> > Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> > 
> > > > > > Have noticed that when I insert text with colour properties in a buffer
> > > > > > using fundamental-mode, the text properties (e.g. colours) get lost.
> > > > > 
> > > > > I assume you used the ‘face property, right? If you replace ‘face with 'font-lock-face, does it work?
> > > > > 
> > > > > Yuan
> > > > 
> > > > I used 'font-lock-face and did not work.
> > > 
> > > Please show the code you used. It works here.
> > 
> > (with-current-buffer (get-buffer-create bufrn)
> > (insert (propertize "G"
> > 'font-lock-face '(:background "green"
> > :foreground "black"))))
> 
> 
> From the ELisp manual:
> 
> ‘font-lock-face’
> This property specifies a value for the ‘face’ property that Font
> Lock mode should apply to the underlying text. It is one of the
> fontification methods used by Font Lock mode, and is useful for
> special modes that implement their own highlighting. *Note
> Precalculated Fontification::. When Font Lock mode is disabled,
> ‘font-lock-face’ has no effect.
> 
> Note the last sentence.
> 
> Conclusion: you need to turn on font-lock in that buffer.
> 

When I use (text-mode) or (org-mode), I do not get the problem.

(with-current-buffer (get-buffer-create bufrn)
 (text-mode)
 (insert (propertize "G"
 'font-lock-face '(:background "green"
 :foreground "black"))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 15:02:02 GMT) Full text and rfc822 format available.

Message #26 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Heime <heimeborgia <at> protonmail.com>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 17:00:57 +0200
> Date: Mon, 05 Dec 2022 14:54:47 +0000
> From: Heime <heimeborgia <at> protonmail.com>
> Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> 
> > Conclusion: you need to turn on font-lock in that buffer.
> > 
> 
> When I use (text-mode) or (org-mode), I do not get the problem.
> 
> (with-current-buffer (get-buffer-create bufrn)
>  (text-mode)
>  (insert (propertize "G"
>  'font-lock-face '(:background "green"
>  :foreground "black"))))

Because those turn on font-lock by default.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 15:07:02 GMT) Full text and rfc822 format available.

Message #29 received at 59828 <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 15:06:09 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 3:00 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:


> > Date: Mon, 05 Dec 2022 14:54:47 +0000
> > From: Heime heimeborgia <at> protonmail.com
> > Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> > 
> > > Conclusion: you need to turn on font-lock in that buffer.
> > 
> > When I use (text-mode) or (org-mode), I do not get the problem.
> > 
> > (with-current-buffer (get-buffer-create bufrn)
> > (text-mode)
> > (insert (propertize "G"
> > 'font-lock-face '(:background "green"
> > :foreground "black"))))
> 
> 
> Because those turn on font-lock by default.

What do you think about having fundamental-mode also turn font-lock on ?




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Mon, 05 Dec 2022 15:42:02 GMT) Full text and rfc822 format available.

Notification sent to Heime <heimeborgia <at> protonmail.com>:
bug acknowledged by developer. (Mon, 05 Dec 2022 15:42:02 GMT) Full text and rfc822 format available.

Message #34 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Heime <heimeborgia <at> protonmail.com>
Cc: casouri <at> gmail.com, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 17:40:51 +0200
> Date: Mon, 05 Dec 2022 15:06:09 +0000
> From: Heime <heimeborgia <at> protonmail.com>
> Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> 
> > > > Conclusion: you need to turn on font-lock in that buffer.
> > > 
> > > When I use (text-mode) or (org-mode), I do not get the problem.
> > > 
> > > (with-current-buffer (get-buffer-create bufrn)
> > > (text-mode)
> > > (insert (propertize "G"
> > > 'font-lock-face '(:background "green"
> > > :foreground "black"))))
> > 
> > 
> > Because those turn on font-lock by default.
> 
> What do you think about having fundamental-mode also turn font-lock on ?

What it does now is the result of what we think.  That's why it is called
Fundamental.

Anyway, there's no bug here, so I'm closing this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 19:24:01 GMT) Full text and rfc822 format available.

Message #37 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 19:23:02 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 3:40 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:


> > Date: Mon, 05 Dec 2022 15:06:09 +0000
> > From: Heime heimeborgia <at> protonmail.com
> > Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> > 
> > > > > Conclusion: you need to turn on font-lock in that buffer.
> > > > 
> > > > When I use (text-mode) or (org-mode), I do not get the problem.
> > > > 
> > > > (with-current-buffer (get-buffer-create bufrn)
> > > > (text-mode)
> > > > (insert (propertize "G"
> > > > 'font-lock-face '(:background "green"
> > > > :foreground "black"))))
> > > 
> > > Because those turn on font-lock by default.
> > 
> > What do you think about having fundamental-mode also turn font-lock on ?
> 
> 
> What it does now is the result of what we think. That's why it is called
> Fundamental.
> 
> Anyway, there's no bug here, so I'm closing this.

Is fundamental mode not usually used when working on new buffers?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 20:06:01 GMT) Full text and rfc822 format available.

Message #40 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Heime <heimeborgia <at> protonmail.com>
Cc: casouri <at> gmail.com, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 22:04:54 +0200
> Date: Mon, 05 Dec 2022 19:23:02 +0000
> From: Heime <heimeborgia <at> protonmail.com>
> Cc: casouri <at> gmail.com, 59828-done <at> debbugs.gnu.org
> 
> > > What do you think about having fundamental-mode also turn font-lock on ?
> > 
> > 
> > What it does now is the result of what we think. That's why it is called
> > Fundamental.
> > 
> > Anyway, there's no bug here, so I'm closing this.
> 
> Is fundamental mode not usually used when working on new buffers?

Not necessarily, it depends on what the Lisp program needs to do.

And turning on font-lock is just one line of Lisp away.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 20:09:01 GMT) Full text and rfc822 format available.

Message #43 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 5 Dec 2022 12:07:52 -0800

> On Dec 5, 2022, at 11:23 AM, Heime <heimeborgia <at> protonmail.com> wrote:
> 
> ------- Original Message -------
> On Monday, December 5th, 2022 at 3:40 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> 
>>> Date: Mon, 05 Dec 2022 15:06:09 +0000
>>> From: Heime heimeborgia <at> protonmail.com
>>> Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
>>> 
>>>>>> Conclusion: you need to turn on font-lock in that buffer.
>>>>> 
>>>>> When I use (text-mode) or (org-mode), I do not get the problem.
>>>>> 
>>>>> (with-current-buffer (get-buffer-create bufrn)
>>>>> (text-mode)
>>>>> (insert (propertize "G"
>>>>> 'font-lock-face '(:background "green"
>>>>> :foreground "black"))))
>>>> 
>>>> Because those turn on font-lock by default.
>>> 
>>> What do you think about having fundamental-mode also turn font-lock on ?
>> 
>> 
>> What it does now is the result of what we think. That's why it is called
>> Fundamental.
>> 
>> Anyway, there's no bug here, so I'm closing this.
> 
> Is fundamental mode not usually used when working on new buffers?
> 

Just to clarify:

1. If font-lock-mode is off, you should use (propertize … ‘face …)
2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)

If you create a buffer interactively, font-lock-mode is on (at least in the latest version of Emacs, not sure which version of Emacs are you on). But if you create a buffer programmatically (as you did in the code snippet), font-lock-mode is off.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 20:14:01 GMT) Full text and rfc822 format available.

Message #46 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 20:13:13 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 8:07 PM, Yuan Fu <casouri <at> gmail.com> wrote:


> > On Dec 5, 2022, at 11:23 AM, Heime heimeborgia <at> protonmail.com wrote:
> > 
> > ------- Original Message -------
> > On Monday, December 5th, 2022 at 3:40 PM, Eli Zaretskii eliz <at> gnu.org wrote:
> > 
> > > > Date: Mon, 05 Dec 2022 15:06:09 +0000
> > > > From: Heime heimeborgia <at> protonmail.com
> > > > Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> > > > 
> > > > > > > Conclusion: you need to turn on font-lock in that buffer.
> > > > > > 
> > > > > > When I use (text-mode) or (org-mode), I do not get the problem.
> > > > > > 
> > > > > > (with-current-buffer (get-buffer-create bufrn)
> > > > > > (text-mode)
> > > > > > (insert (propertize "G"
> > > > > > 'font-lock-face '(:background "green"
> > > > > > :foreground "black"))))
> > > > > 
> > > > > Because those turn on font-lock by default.
> > > > 
> > > > What do you think about having fundamental-mode also turn font-lock on ?
> > > 
> > > What it does now is the result of what we think. That's why it is called
> > > Fundamental.
> > > 
> > > Anyway, there's no bug here, so I'm closing this.
> > 
> > Is fundamental mode not usually used when working on new buffers?
> 
> 
> Just to clarify:
> 
> 1. If font-lock-mode is off, you should use (propertize … ‘face …)
> 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)

Very clear explanation.
 
> If you create a buffer interactively, font-lock-mode is on (at least in the latest version of Emacs, not sure which version of Emacs are you on). But if you create a buffer programmatically (as you did in the code snippet), font-lock-mode is off.
 
Even if you make a buffer interactively in fundamental-mode?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 20:27:02 GMT) Full text and rfc822 format available.

Message #49 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 5 Dec 2022 12:25:55 -0800

> On Dec 5, 2022, at 12:13 PM, Heime <heimeborgia <at> protonmail.com> wrote:
> 
> ------- Original Message -------
> On Monday, December 5th, 2022 at 8:07 PM, Yuan Fu <casouri <at> gmail.com> wrote:
> 
> 
>>> On Dec 5, 2022, at 11:23 AM, Heime heimeborgia <at> protonmail.com wrote:
>>> 
>>> ------- Original Message -------
>>> On Monday, December 5th, 2022 at 3:40 PM, Eli Zaretskii eliz <at> gnu.org wrote:
>>> 
>>>>> Date: Mon, 05 Dec 2022 15:06:09 +0000
>>>>> From: Heime heimeborgia <at> protonmail.com
>>>>> Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
>>>>> 
>>>>>>>> Conclusion: you need to turn on font-lock in that buffer.
>>>>>>> 
>>>>>>> When I use (text-mode) or (org-mode), I do not get the problem.
>>>>>>> 
>>>>>>> (with-current-buffer (get-buffer-create bufrn)
>>>>>>> (text-mode)
>>>>>>> (insert (propertize "G"
>>>>>>> 'font-lock-face '(:background "green"
>>>>>>> :foreground "black"))))
>>>>>> 
>>>>>> Because those turn on font-lock by default.
>>>>> 
>>>>> What do you think about having fundamental-mode also turn font-lock on ?
>>>> 
>>>> What it does now is the result of what we think. That's why it is called
>>>> Fundamental.
>>>> 
>>>> Anyway, there's no bug here, so I'm closing this.
>>> 
>>> Is fundamental mode not usually used when working on new buffers?
>> 
>> 
>> Just to clarify:
>> 
>> 1. If font-lock-mode is off, you should use (propertize … ‘face …)
>> 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)
> 
> Very clear explanation.
> 
>> If you create a buffer interactively, font-lock-mode is on (at least in the latest version of Emacs, not sure which version of Emacs are you on). But if you create a buffer programmatically (as you did in the code snippet), font-lock-mode is off.
> 
> Even if you make a buffer interactively in fundamental-mode?

By “interactively” I mean typing M-x switch-to-buffer <buffer name> RET. This gives you a new buffer in fundamental-mode.

If you create a buffer this way, and type M-x eval-expression font-lock-mode RET, you should get t, meaning font-lock-mode is on. Whereas 

(with-current-buffer (get-buffer-create "xxx")
  font-lock-mode)

returns nil.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Mon, 05 Dec 2022 20:28:02 GMT) Full text and rfc822 format available.

Message #52 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 05 Dec 2022 20:27:09 +0000
------- Original Message -------
On Monday, December 5th, 2022 at 8:13 PM, Heime via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> wrote:


> ------- Original Message -------
> On Monday, December 5th, 2022 at 8:07 PM, Yuan Fu casouri <at> gmail.com wrote:
> 
> 
> 
> > > On Dec 5, 2022, at 11:23 AM, Heime heimeborgia <at> protonmail.com wrote:
> > > 
> > > ------- Original Message -------
> > > On Monday, December 5th, 2022 at 3:40 PM, Eli Zaretskii eliz <at> gnu.org wrote:
> > > 
> > > > > Date: Mon, 05 Dec 2022 15:06:09 +0000
> > > > > From: Heime heimeborgia <at> protonmail.com
> > > > > Cc: casouri <at> gmail.com, 59828 <at> debbugs.gnu.org
> > > > > 
> > > > > > > > Conclusion: you need to turn on font-lock in that buffer.
> > > > > > > 
> > > > > > > When I use (text-mode) or (org-mode), I do not get the problem.
> > > > > > > 
> > > > > > > (with-current-buffer (get-buffer-create bufrn)
> > > > > > > (text-mode)
> > > > > > > (insert (propertize "G"
> > > > > > > 'font-lock-face '(:background "green"
> > > > > > > :foreground "black"))))
> > > > > > 
> > > > > > Because those turn on font-lock by default.
> > > > > 
> > > > > What do you think about having fundamental-mode also turn font-lock on ?
> > > > 
> > > > What it does now is the result of what we think. That's why it is called
> > > > Fundamental.
> > > > 
> > > > Anyway, there's no bug here, so I'm closing this.
> > > 
> > > Is fundamental mode not usually used when working on new buffers?
> > 
> > Just to clarify:
> > 
> > 1. If font-lock-mode is off, you should use (propertize … ‘face …)
> > 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)

If I have a function that does the inserts, should I include the two different conditions, 
whether "font-lock-mode" in "off" or "on" ?

Test whether font-lock-mode is off, then use (propertize … ‘face …)
Test whether font-lock-mode is on, then use (propertize … ‘font-lock-face …)
 
> Very clear explanation.
> 
> > If you create a buffer interactively, font-lock-mode is on (at least in the latest version of Emacs, not sure which version of Emacs are you on). But if you create a buffer programmatically (as you did in the code snippet), font-lock-mode is off.
> 
> 
> Even if you make a buffer interactively in fundamental-mode, would font-lock-mode be on ?
>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Tue, 06 Dec 2022 05:42:02 GMT) Full text and rfc822 format available.

Message #55 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Mon, 5 Dec 2022 21:41:23 -0800
>>> 
>>> Just to clarify:
>>> 
>>> 1. If font-lock-mode is off, you should use (propertize … ‘face …)
>>> 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)
> 
> If I have a function that does the inserts, should I include the two different conditions, 
> whether "font-lock-mode" in "off" or "on" ?
> 
> Test whether font-lock-mode is off, then use (propertize … ‘face …)
> Test whether font-lock-mode is on, then use (propertize … ‘font-lock-face …)

It depends on your use-case. If you want to be safe you can just apply both properties, then it will work no matter font-lock-mode is on or not.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Wed, 07 Dec 2022 00:54:02 GMT) Full text and rfc822 format available.

Message #58 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Wed, 07 Dec 2022 00:53:17 +0000
------- Original Message -------
On Tuesday, December 6th, 2022 at 5:41 AM, Yuan Fu <casouri <at> gmail.com> wrote:


> > > > Just to clarify:
> > > > 
> > > > 1. If font-lock-mode is off, you should use (propertize … ‘face …)
> > > > 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)
> > 
> > If I have a function that does the inserts, should I include the two different conditions,
> > whether "font-lock-mode" in "off" or "on" ?
> > 
> > Test whether font-lock-mode is off, then use (propertize … ‘face …)
> > Test whether font-lock-mode is on, then use (propertize … ‘font-lock-face …)
> 
> 
> It depends on your use-case. If you want to be safe you can just apply both properties, then it will work no matter font-lock-mode is on or not.
> 
> Yuan

I thought that the procedure is to enable "font-lock-mode", then use (propertize … ‘font-lock-face …).

You are saying to disregard "font-lock-mode" and use (propertize … ‘face …) when it is determined that "font-lock-mode" is off.

Can I have a deeper explanation on how to handle this good?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59828; Package emacs. (Thu, 08 Dec 2022 13:01:02 GMT) Full text and rfc822 format available.

Message #61 received at 59828-done <at> debbugs.gnu.org (full text, mbox):

From: Heime <heimeborgia <at> protonmail.com>
To: Heime <heimeborgia <at> protonmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 59828-done <at> debbugs.gnu.org
Subject: Re: bug#59828: Fundamental Mode buffers fail to keep text properties
Date: Thu, 08 Dec 2022 13:00:11 +0000
------- Original Message -------
On Wednesday, December 7th, 2022 at 12:53 AM, Heime via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> wrote:


> ------- Original Message -------
> On Tuesday, December 6th, 2022 at 5:41 AM, Yuan Fu casouri <at> gmail.com wrote:
> 
> 
> 
> > > > > Just to clarify:
> > > > > 
> > > > > 1. If font-lock-mode is off, you should use (propertize … ‘face …)
> > > > > 2. If font-lock-mode is on, you should use (propertize … ‘font-lock-face …)
> > > 
> > > If I have a function that does the inserts, should I include the two different conditions,
> > > whether "font-lock-mode" in "off" or "on" ?
> > > 
> > > Test whether font-lock-mode is off, then use (propertize … ‘face …)
> > > Test whether font-lock-mode is on, then use (propertize … ‘font-lock-face …)
> > 
> > It depends on your use-case. If you want to be safe you can just apply both properties, then it will work no matter font-lock-mode is on or not.
> > 
> > Yuan
 
I thought the procedure is to enable "font-lock-mode", followed by  
(propertize "G" 'font-lock-face '(:foreground "black")).  Finally disabling "font-lock-mode" in that buffer.






bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 06 Jan 2023 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 166 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.