Questions tagged [text-properties]
is for any text property, such as `face`, that Emacs can associate with text. Emacs moves, copies, or displays the text using the text properties, which are specified as name-value pairs along with the text in a special Lisp structure. Emacs uses a special read and print syntax for text properties.
93
questions
23
votes
2answers
2k views
What are overlays for, and how do they differ from text properties?
The manual states:
You can use overlays to alter the appearance of a buffer's text on the
screen, for the sake of presentation features.
From its name, it suggests it can be used to create “...
17
votes
1answer
2k views
How to strip decorations (text properties) from a string?
By a "decorated string" I mean something like
#("foo" 0 4 (fontified t face font-lock-function-name-face))
...as opposed to the "plain string"
"foo"
(If Elisp code reads a string directly from a ...
12
votes
2answers
542 views
Can I use an image in my modeline lighter?
My modeline is cluttered. Can I make it display pictures instead of mode names?
I could use unicode Emoji (such as 🐍 for Python or 🐓 for Coq), but some machines on which I use my Emacs config do ...
12
votes
5answers
418 views
Ways to unobtrusively vary text rendering?
I'm writing an emacs extension for use with speech recognition, and I'm looking for help with a particular feature. Some words the speech recognizer (Dragon) recognizes consistently poorly -- it doesn'...
10
votes
1answer
482 views
Are there any libraries for input fields in Emacs?
Quite a few Emacs modes use (something like) forms: the customization interface is one of them, the Message mode (read: its header part) is another one; there are more of them, unfortunately not ...
9
votes
2answers
626 views
Temporary text in window location with no text to propertize/overlay?
Q: how do I temporarily show text in a window at screen locations with no text to propertize/overlay?
I'm familiar with the basic idea behind text properties and overlays (see also this thread), have ...
8
votes
1answer
252 views
Prevent inserting text at the beginning of a buffer that starts with read-only text
I'm extending an existing Emacs package and I want to make a part of the buffer not editable (read only). In fact, I want to make only one line in the middle of the buffer editable and I use the ...
7
votes
2answers
353 views
Strip text properties in savehist
I save the kill-ring using the savehist package. savehist saves the kill ring with text-properties intact.
Unfortunately, this is a problem.
I have a rather large emacs config, and I use a lot of ...
7
votes
1answer
181 views
How does AucTeX display superscripts?
latex-mode is has a nice display of superscripts and subscripts. Not
only are they reduced in size, but they are respectively raised and
lowered a bit relative to the current line.
Q: How can I make ...
6
votes
2answers
305 views
How to set the glyph of a unicode character?
I would like to set the glyph of a certain unicode character. Specifically, I would like the glyph § (SECTION SIGN) to represent the unicode character U+202A (LEFT-TO-RIGHT EMBEDDING), a normally non-...
6
votes
3answers
154 views
masking text in an org-mode buffer
Sometimes I want parts of the text within an org buffer to be 'masked' by default. The reason is that I may want to look at that file with someone looking over my shoulder, where they should be able ...
6
votes
1answer
317 views
undo-tree — history file without text-properties
Q: How can I modify undo-tree-save-history to remove the text-properties from all entries that make their way into the saved history file?
In a related thread, @PythonNut was on a very similar quest ...
5
votes
3answers
123 views
elisp: retaining data structure after inserting string representation to buffer?
I'm currently writing a major mode (for interacting with a remote Grid Engine) which involves fetching data, parsing it into an alist, formating the alist into a string and then inserting the ...
5
votes
2answers
781 views
How to apply overlay or text properties to text matching a regexp?
I want to transform a text file with many lines :
| refXXXXX | here useful text, first sentence, last word. |
| refYYYYY | First word, second sentence. |
into :
here useful ...
4
votes
3answers
314 views
How to modify a string without altering its text properties
If I propertize a string and save it to a variable, how can I change the string within that variable without altering its text properties? For example:
(setq myvar (propertize "testing"
...
4
votes
3answers
288 views
Prevent Emacs from asking “kill anyway” when only text properties have changed
I have a read-only file that I open in Emacs. I have created a keyboard shortcut to hide some regions of the file. For example:
(defun hide-beginning ()
(interactive)
(setq buffer-read-only nil)
...
4
votes
2answers
491 views
How to make mode-line text look like a link/button on hover
What face/text/other property should I use to have mode-line text look like a button/link/stuff to click on while I am hovering over it with the cursor?
Some examples:
different background,
3D-like ...
4
votes
1answer
105 views
Format fails to copy text properties from the format-string for adjacent %-sequences
Take a look at this example:
(format (concat "%s" (propertize "%s" 'face 'error)) "foo" "bar")
"foobar"
(format (concat "%s " (propertize "%s" 'face 'error)) "foo" "bar")
#("foo bar" 4 7 (face error)...
4
votes
1answer
765 views
Properties inheriting in org doesn't work
I have this sample org file:
#+COLUMNS: %25ITEM %TODO %5owner %3PRIORITY %TAGS
* test1
:PROPERTIES:
:owner: own1
:END:
** test2
** test3
I also have in my .emacs file:
(setq org-use-...
4
votes
0answers
70 views
Custom follow mode
I want to make a follow mode where placing the cursor within certain parts of the buffer will cause some action to happen in another window. For example, using helm-follow-mode with helm-occur will ...
3
votes
2answers
168 views
Text as text properties?
Is it possible to have a text string as a text property in emacs? Let me explain. I usually work with latex documents and I need to format their bibliographies that have, e.g., this structure:
\begin{...
3
votes
1answer
710 views
How to remove all text properties in a buffer
The function remove-text-properties requires a list for the third argument props -- e.g., (remove-text-properties start end '(face nil))
How can I remove all text properties in a buffer in one fell ...
3
votes
2answers
62 views
How can I search for bolded text?
My reasons for doing so are exactly like https://unix.stackexchange.com/questions/271550/how-can-i-search-for-bolded-or-underlined-text , but the accepted solution there is to use vim. I don't fancy ...
3
votes
2answers
95 views
Make region(s) invisible (not evaluated) to query-replacy and similar commands
Is there a way to make some regions of the buffer invisible (I mean not evaluated by) to query-replace and similar commands?
Let me better explain with an example. Let's take a piece of LaTeX code
.....
3
votes
1answer
119 views
New line in cursor-intangible area and line-beginning position
I want to make the beginning of a line uneditable, which I can achieve by applying the read-only and cursor-intangible properties. But I have the problem, that line-beginning-position moves point not ...
3
votes
2answers
105 views
Evaluate parts inside text-property string using read syntax?
I just discovered that it is possible to define strings with text properties using the special read syntax. Now I'm trying to evaluate a value of a property within the string definition so something ...
3
votes
1answer
22 views
How to use font-lock to set other text properties (particularly keymap)?
I'm trying to make a mode where certain strings in the buffer have a special keymap active when the point is inside them. The documentation for font-lock-extra-managed-props and the Elisp info manual ...
3
votes
1answer
59 views
How to display a marked-up string without the markup?
Q: how can I display a marked-up string without the markup?
I have a string with LaTeX markup, such as the following name with
an umlaut:
Tezc\"ur
I want to display the string in a buffer without ...
3
votes
1answer
203 views
How can I edit read-only text after pasting?
I want to create a buffer where some parts are editable, but others are not. I'm using the read-only string property to do this, e.g.:
(with-current-buffer (get-buffer-create "*scratch-demo*")
(...
3
votes
1answer
129 views
How to modify string height while keeping the face?
Here's a code that works for setting a string foreground:
(defface test-face
'((t (:height 1.2 :foreground "green")))
"doc.")
(setq asdf (propertize "asdf" 'face 'test-face))
(add-face-text-...
3
votes
1answer
73 views
Make region(s) invisible (not evaluated) to “string-match”, “occur” and similar commands
In a previous question, Make region(s) invisible (not evaluated) to query-replacy and similar commands, I learned about isearch-filter-predicate. Now, I wonder if is there a similar method to make ...
3
votes
1answer
311 views
How can I eliminate the side effect of left margin?
I've set a left margin like this:
(set-window-margins (get-buffer-window) 20 0)
(let ((gutter-sep (concat (make-string (- (car (window-margins (get-buffer-window))) 2) ? ) "+")))
(propertize "." '...
3
votes
0answers
104 views
How would one fake kerning adjustments in propertized text?
I've successfully managed adjusting the displayed size of spaces and raising/lowering propertized text by making use of the display property, however I cannot find anything that would allow me to fake ...
2
votes
2answers
327 views
compose-region and TABs
I'm trying to use compose-region with TABs but fail to see difference.
I'd like to get 'sqrt' composed to '√' but taking as much space as original text and aligned to the right.
I tried each of:
(...
2
votes
2answers
360 views
Get width of an image
How can I determine the width of an image of the imagemagick type?
I am inserting an image into a buffer, whose size is (initally)
completely unknown to me. I do it more or less like this:
(insert-...
2
votes
1answer
405 views
Make all text of a given face invisible
Is there a straightforward way to make all text with a given face invisible? I don't believe I can make invisibility be intrinsic to the face, but can I perhaps specify a minor mode that makes sure ...
2
votes
2answers
73 views
How do I get the closest property change before a given point?
How can I get the previous-or-equal single property change for a given property? For example, assume AAA, BBB, and CCC below have different faces.
AAABBBCCC
Here is the return value that I would ...
2
votes
1answer
561 views
How to use the highlight-chars.el package?
How can I use the highlight-chars.el package mentioned here (and here's its code) to highlight custom characters?
Specifically, I'd like to highlight the unicode directional formatting characters for ...
2
votes
1answer
158 views
Simplest way to add-text-properties without overriding existing ones
I need to add a text-property to the entire buffer. However, parts of
the buffer might already have that property with a different value.
Q: What's the easiest way to apply a text property only to ...
2
votes
1answer
93 views
text-properties bloat persistent undo files
I'm using undo-tree with AUCTeX, and I am persisting my undo files like so:
(setq undo-tree-auto-save-history t)
Unfortunately, this regularly results in large (~1MB) undo save files which cause my ...
2
votes
1answer
168 views
How to programmatically walk along string and add text properties
I have a function that gathers strings that looks like these:
Example #1: :event:lawlist:HIGH:misc:
Example #2: :LOW:
Example #3: :MEDIUM:task:george:
I created a monstrosity of a snippet that ...
2
votes
3answers
27 views
How to extract text properties into a string?
Is it possible to separate text properties and convert them into a string? For example, with a string with properties:
#("gfsd \"fsgfd\"
sdfdsgfs \"fsdfs\"s sfg fdg fdffffffffffffff" 0 5 (fontified ...
2
votes
1answer
32 views
The insert function seems to be inheriting the read-only property
I'trying to insert a row of characters into a buffer, where the first four characters should be read-only. Here's the relevant part of the code :
(insert (propertize "cn) " 'read-only t))
(insert (...
2
votes
2answers
371 views
How to remove certain text-properties from a list of properties
text-properties-at returns a list of various text properties.
I want to remove: display (image :type xpm :file /Users/HOME/.0.data/.0.emacs/.0.images/ezimage/box-plus.xpm :scale 1.1070588235294117 :...
2
votes
1answer
116 views
Debugging / understanding placement of keymap with text-properties
Q: Why does there appear to be a keymap on the hyphen of hello-world in the following example?
GOAL: Place text properties before the hyphen and after the hyphen -- without any keymap being placed ...
2
votes
0answers
28 views
isearch with invisible text properties, not overlays?
Q: how can I get isearch to understand invisible text
properties, not just overlays?
I'm writing a major mode that uses text properties rather than
overlays to toggle visibility. I'd like to use ...
2
votes
0answers
31 views
Why does setting the 'face property trigger fontification?
I'm trying to write a major mode for a programming language with JSX based syntax. Here's a minimal implementation.
(defun example-forward-parse-jsx (start-pos limit)
"Move point past the JSX ...
2
votes
0answers
58 views
Calculate current-column including display properties
I am trying to calculate the width of text within either a buffer or a string after it has been displayed, i.e. after taking into account the width of any display properties, such as embedded images, ...
2
votes
0answers
145 views
How can I make hl-line mode not override the color of rainbow-mode? [duplicate]
Is there an non-intrusive way to do this?
I've made a fork of rainbow-mode that uses overlay instead of text properties, which solves this :)
https://github.com/amosbird/rainbow-mode
1
vote
2answers
49 views
Make text clickable: add urls with a loop
In my LaTeX code I have functions that generate hyperlinks in the PDF file. I have, e.g.:
\newcommand{\arXivid}[1]{\href{https://arxiv.org/abs/#1}{\tt arXiv:#1}}
So, in my LaTeX code I have strings ...