* How can I remove effects of text properties in 'before-string
@ 2017-10-22 7:25 Amos Bird
2017-10-22 7:43 ` Amos Bird
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Amos Bird @ 2017-10-22 7:25 UTC (permalink / raw)
To: help-gnu-emacs
Hi there,
emacs -Q
(set-window-margins (get-buffer-window) 20 0)
(overlay-put (make-overlay (point) (point)) 'before-string
(propertize "." 'display `((margin left-margin) ,"Hi there!")))
(hl-line-mode)
The string "Hi there!" is also highlighted. How can I disable
that?
regards,
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 7:25 How can I remove effects of text properties in 'before-string Amos Bird
@ 2017-10-22 7:43 ` Amos Bird
2017-10-22 16:00 ` Emanuel Berg
2017-10-22 16:02 ` Eli Zaretskii
2 siblings, 0 replies; 16+ messages in thread
From: Amos Bird @ 2017-10-22 7:43 UTC (permalink / raw)
To: help-gnu-emacs
I've also post a question at
https://emacs.stackexchange.com/questions/36328/how-can-i-eliminate-the-side-effect-of-left-margin
with some images for better description.
Amos Bird <amosbird@gmail.com> writes:
> Hi there,
>
> emacs -Q
>
> (set-window-margins (get-buffer-window) 20 0)
> (overlay-put (make-overlay (point) (point)) 'before-string
> (propertize "."
> 'display `((margin left-margin) ,"Hi there!")))
> (hl-line-mode)
>
> The string "Hi there!" is also highlighted. How can I disable
> that?
>
> regards,
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 7:25 How can I remove effects of text properties in 'before-string Amos Bird
2017-10-22 7:43 ` Amos Bird
@ 2017-10-22 16:00 ` Emanuel Berg
2017-10-22 17:07 ` Amos Bird
2017-10-22 16:02 ` Eli Zaretskii
2 siblings, 1 reply; 16+ messages in thread
From: Emanuel Berg @ 2017-10-22 16:00 UTC (permalink / raw)
To: help-gnu-emacs
> emacs -Q
>
> (set-window-margins (get-buffer-window) 20 0)
> (overlay-put (make-overlay (point) (point))
> 'before-string (propertize "." 'display
> `((margin left-margin) ,"Hi there!")))
> (hl-line-mode)
I don't know what you're up to but in general
you can use `buffer-substring-no-properties'.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 16:00 ` Emanuel Berg
@ 2017-10-22 17:07 ` Amos Bird
0 siblings, 0 replies; 16+ messages in thread
From: Amos Bird @ 2017-10-22 17:07 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
Hi, how can I use that to set margin text?
Emanuel Berg <moasen@zoho.com> writes:
>> emacs -Q
>>
>> (set-window-margins (get-buffer-window) 20 0)
>> (overlay-put (make-overlay (point) (point))
>> 'before-string (propertize "." 'display
>> `((margin left-margin) ,"Hi there!")))
>> (hl-line-mode)
>
> I don't know what you're up to but in general
> you can use `buffer-substring-no-properties'.
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 7:25 How can I remove effects of text properties in 'before-string Amos Bird
2017-10-22 7:43 ` Amos Bird
2017-10-22 16:00 ` Emanuel Berg
@ 2017-10-22 16:02 ` Eli Zaretskii
2017-10-22 17:07 ` Amos Bird
2 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2017-10-22 16:02 UTC (permalink / raw)
To: help-gnu-emacs
> From: Amos Bird <amosbird@gmail.com>
> Date: Sun, 22 Oct 2017 15:25:31 +0800
>
> (set-window-margins (get-buffer-window) 20 0)
> (overlay-put (make-overlay (point) (point)) 'before-string
> (propertize "." 'display `((margin left-margin) ,"Hi there!")))
> (hl-line-mode)
>
> The string "Hi there!" is also highlighted. How can I disable
> that?
Give the string a distinct face.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 16:02 ` Eli Zaretskii
@ 2017-10-22 17:07 ` Amos Bird
2017-10-22 17:15 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Amos Bird @ 2017-10-22 17:07 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Hi, could you show the elisp code that resolves this? I don't
quite understand how to give a distinct face.
regards,
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Amos Bird <amosbird@gmail.com>
>> Date: Sun, 22 Oct 2017 15:25:31 +0800
>>
>> (set-window-margins (get-buffer-window) 20 0)
>> (overlay-put (make-overlay (point) (point)) 'before-string
>> (propertize "." 'display `((margin left-margin) ,"Hi there!")))
>> (hl-line-mode)
>>
>> The string "Hi there!" is also highlighted. How can I disable
>> that?
>
> Give the string a distinct face.
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 17:07 ` Amos Bird
@ 2017-10-22 17:15 ` Eli Zaretskii
2017-10-22 18:08 ` Amos Bird
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2017-10-22 17:15 UTC (permalink / raw)
To: help-gnu-emacs
> From: Amos Bird <amosbird@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Mon, 23 Oct 2017 01:07:04 +0800
>
> Hi, could you show the elisp code that resolves this? I don't
> quite understand how to give a distinct face.
Here, this simple variation of your original recipe will display the
string in the margin using the 'default' face:
(set-window-margins (get-buffer-window) 20 0)
(setq ovstring (propertize "Hi, there!" 'face 'default)) <<<<<<<<<<<<<<<
(overlay-put (make-overlay (point) (point)) 'before-string
(propertize "."
'display
`((margin left-margin) ,ovstring)))
(hl-line-mode)
The line marked with "<<<<<" is the main part of the solution.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 17:15 ` Eli Zaretskii
@ 2017-10-22 18:08 ` Amos Bird
2017-10-22 18:24 ` Eli Zaretskii
2017-10-23 12:57 ` Stefan Monnier
0 siblings, 2 replies; 16+ messages in thread
From: Amos Bird @ 2017-10-22 18:08 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Hi, thanks for the code. It works! However, I tried to explicited
set face to
'((t (:foreground "magenta" :weight bold :inherit default))
which doesn't. Why?
regards,
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Amos Bird <amosbird@gmail.com>
>> Cc: help-gnu-emacs@gnu.org
>> Date: Mon, 23 Oct 2017 01:07:04 +0800
>>
>> Hi, could you show the elisp code that resolves this? I don't
>> quite understand how to give a distinct face.
>
> Here, this simple variation of your original recipe will display
> the
> string in the margin using the 'default' face:
>
> (set-window-margins (get-buffer-window) 20 0)
> (setq ovstring (propertize "Hi, there!" 'face 'default))
> <<<<<<<<<<<<<<<
> (overlay-put (make-overlay (point) (point)) 'before-string
> (propertize "."
> 'display
> `((margin left-margin) ,ovstring)))
> (hl-line-mode)
>
> The line marked with "<<<<<" is the main part of the solution.
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 18:08 ` Amos Bird
@ 2017-10-22 18:24 ` Eli Zaretskii
2017-10-22 19:12 ` Amos Bird
2017-10-23 12:57 ` Stefan Monnier
1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2017-10-22 18:24 UTC (permalink / raw)
To: help-gnu-emacs
> From: Amos Bird <amosbird@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Mon, 23 Oct 2017 02:08:40 +0800
>
> Hi, thanks for the code. It works! However, I tried to explicited
> set face to
> '((t (:foreground "magenta" :weight bold :inherit default))
>
> which doesn't. Why?
Please show the entire recipe, I don't think I understand well enough
what exactly you did.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 18:24 ` Eli Zaretskii
@ 2017-10-22 19:12 ` Amos Bird
2017-10-22 19:34 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Amos Bird @ 2017-10-22 19:12 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Hi,
(set-window-margins (get-buffer-window) 20 0)
(setq ovstring (propertize "Hi, there!" 'face '((t (:foreground
"magenta" :weight bold :inherit default)))))
(overlay-put (make-overlay (point) (point)) 'before-string
(propertize "." 'display `((margin left-margin) ,ovstring)))
(hl-line-mode)
The margin text doesn't appear to have the "magenta" color.
regards,
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Amos Bird <amosbird@gmail.com>
>> Cc: help-gnu-emacs@gnu.org
>> Date: Mon, 23 Oct 2017 02:08:40 +0800
>>
>> Hi, thanks for the code. It works! However, I tried to
>> explicited
>> set face to
>> '((t (:foreground "magenta" :weight bold :inherit default))
>>
>> which doesn't. Why?
>
> Please show the entire recipe, I don't think I understand well
> enough
> what exactly you did.
--
Amos Bird
amosbird@gmail.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 19:12 ` Amos Bird
@ 2017-10-22 19:34 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2017-10-22 19:34 UTC (permalink / raw)
To: help-gnu-emacs
> From: Amos Bird <amosbird@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Mon, 23 Oct 2017 03:12:55 +0800
>
> (set-window-margins (get-buffer-window) 20 0)
> (setq ovstring (propertize "Hi, there!" 'face '((t (:foreground
> "magenta" :weight bold :inherit default)))))
> (overlay-put (make-overlay (point) (point)) 'before-string
> (propertize "." 'display `((margin left-margin) ,ovstring)))
> (hl-line-mode)
>
> The margin text doesn't appear to have the "magenta" color.
":inherit default" should appear before the other attributes.
Think about it: you are telling Emacs how to merge the default face
with other attributes, so it should start with the default face,
right?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: How can I remove effects of text properties in 'before-string
2017-10-22 18:08 ` Amos Bird
2017-10-22 18:24 ` Eli Zaretskii
@ 2017-10-23 12:57 ` Stefan Monnier
1 sibling, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2017-10-23 12:57 UTC (permalink / raw)
To: help-gnu-emacs
> Hi, thanks for the code. It works! However, I tried to explicited set face
> to '((t (:foreground "magenta" :weight bold :inherit default))
That's not a face. You're confusing the face-spec passed to `defface`
with an actual face.
You can use
(setq ovstring
(propertize "Hi, there!" 'face
'((:foreground "magenta" :weight bold) default)))
tho I'd recommend you use one of
(defface foo-bar
'((t (:foreground "magenta" :weight bold :inherit default))))
[...]
(setq ovstring (propertize "Hi, there!" 'face 'foo-bar))
or
(defface foo-bar
'((t (:foreground "magenta" :weight bold))))
[...]
(setq ovstring (propertize "Hi, there!" 'face '(foo-bar default)))
-- Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <<87tvyrabkk.fsf@gmail.com>]
[parent not found: <<<87tvyrabkk.fsf@gmail.com>]
end of thread, other threads:[~2017-10-27 14:44 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-22 7:25 How can I remove effects of text properties in 'before-string Amos Bird
2017-10-22 7:43 ` Amos Bird
2017-10-22 16:00 ` Emanuel Berg
2017-10-22 17:07 ` Amos Bird
2017-10-22 16:02 ` Eli Zaretskii
2017-10-22 17:07 ` Amos Bird
2017-10-22 17:15 ` Eli Zaretskii
2017-10-22 18:08 ` Amos Bird
2017-10-22 18:24 ` Eli Zaretskii
2017-10-22 19:12 ` Amos Bird
2017-10-22 19:34 ` Eli Zaretskii
2017-10-23 12:57 ` Stefan Monnier
[not found] <<87tvyrabkk.fsf@gmail.com>
[not found] ` <<838tg3b27v.fsf@gnu.org>
2017-10-22 16:33 ` Drew Adams
2017-10-22 16:50 ` Eli Zaretskii
[not found] ` <<837evnazze.fsf@gnu.org>
2017-10-22 17:32 ` Drew Adams
2017-10-27 14:44 ` Eli Zaretskii
[not found] <<<87tvyrabkk.fsf@gmail.com>
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.