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.

Filter by
Sorted by
Tagged with
28 votes
2 answers
4k 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 “...
Sébastien Le Callonnec's user avatar
28 votes
1 answer
6k 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 ...
kjo's user avatar
  • 3,247
13 votes
2 answers
935 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 ...
Clément's user avatar
  • 3,985
12 votes
5 answers
606 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'...
Joseph Garvin's user avatar
11 votes
2 answers
969 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 ...
PythonNut's user avatar
  • 10.4k
10 votes
1 answer
334 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 ...
Andrii Tykhonov's user avatar
9 votes
2 answers
945 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 ...
Dan's user avatar
  • 33k
9 votes
1 answer
847 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 ...
mbork's user avatar
  • 1,667
7 votes
1 answer
286 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 ...
Malabarba's user avatar
  • 23.2k
6 votes
2 answers
644 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-...
Evan Aad's user avatar
  • 1,541
6 votes
3 answers
320 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 ...
Dave Braze's user avatar
6 votes
1 answer
502 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 ...
lawlist's user avatar
  • 19.1k
5 votes
3 answers
161 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 ...
user avatar
5 votes
2 answers
1k 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 ...
JeanMichel's user avatar
5 votes
1 answer
327 views

Why does mousing over one button also highlight adjacent buttons?

I'm using some buttons, and want to arrange them in a row. That is, some will be directly next to each other. I don't want whitespace between them. This is easy enough to do: However, when I do this, ...
zck's user avatar
  • 9,092
5 votes
1 answer
135 views

Why does `insert` not insert colorized text?

For instance, why does (insert #("abc" 0 3 (face (:foreground "red")))) not insert red text?
extremeaxe5's user avatar
5 votes
1 answer
1k 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 ...
lawlist's user avatar
  • 19.1k
5 votes
3 answers
362 views

Removing unwanted colors (and other decorations) from yanked text

I have a Java properties file that, when opened with Emacs, shows up in a color coded form, as below: I also have a simple text file. When I yank something from the properties file into the text file,...
Chrisuu's user avatar
  • 179
4 votes
3 answers
498 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) ...
Håkon Hægland's user avatar
4 votes
2 answers
840 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 ...
Łukasz Gruner's user avatar
4 votes
2 answers
359 views

re-search-forward through visible text only

I have one big org file. Sometimes I only want to search for a regular expression through the visible text, not the text that is folded; otherwise my search will take much longer. How can I search ...
Aquaactress's user avatar
  • 1,453
4 votes
2 answers
2k 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 ...
DataHungry's user avatar
4 votes
1 answer
133 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)...
cYrus's user avatar
  • 222
4 votes
1 answer
769 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 "." '...
Amos's user avatar
  • 466
4 votes
1 answer
1k 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-...
Kossak's user avatar
  • 1,159
4 votes
0 answers
80 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 ...
nispio's user avatar
  • 8,225
3 votes
3 answers
861 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" ...
Smashgen's user avatar
  • 131
3 votes
2 answers
594 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{...
Gabriele's user avatar
  • 1,554
3 votes
2 answers
538 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: (...
Gracjan Polak's user avatar
3 votes
1 answer
115 views

Can Emacs enriched-text be displayed by other applications, browsers?

Emacs enriched-text stores test properties like font and colours that can be quite useful (colours in build logs, RTF-like documents, etc...) Is there any other applications capable of rendering Emacs ...
PRouleau's user avatar
  • 796
3 votes
1 answer
297 views

Org-mode question: Evaluating lisp in property

Is there a way to evaluate (during an export) lisp code inside a property? If yes, what’s the syntax? For instance, like in this dummy example: * Header :PROPERTIES: :EXPORT_FILE_NAME: (print “...
Laurent Jacques's user avatar
3 votes
2 answers
155 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 ...
HappyFace's user avatar
  • 830
3 votes
1 answer
281 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 ...
Shmozart's user avatar
3 votes
1 answer
48 views

Strange behaviour involving `display` property

I noticed a rather peculiar behavior when using the display property (using emacs 28.2). I tried to boil things down to a minimal example: The code (defun finsert () (insert (propertize ".&...
dmw64's user avatar
  • 177
3 votes
1 answer
381 views

Why does font-lock-mode work with various programming languages but it does not in text-mode?

The objective is to do text highlighting when TODO and NOTE tokens are found somewhere in a txt file. This is what I have in the .emacs.el file: (add-hook 'text-mode-hook 'font-lock-mode) (setq fixme-...
Thomas Reller's user avatar
3 votes
2 answers
144 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 .....
Gabriele's user avatar
  • 1,554
3 votes
2 answers
307 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 ...
clemera's user avatar
  • 3,461
3 votes
1 answer
60 views

How to reset the colors at the end of the Eshell prompt?

I have the following prompt customization for Eshell: (setq eshell-prompt-function (lambda () (let ((c "#fdd")) (let ((bc (lambda (str) (...
ceving's user avatar
  • 1,358
3 votes
1 answer
292 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 ...
gajogacchati's user avatar
3 votes
1 answer
94 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 ...
Dan's user avatar
  • 33k
3 votes
1 answer
246 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*") (...
Wilfred Hughes's user avatar
3 votes
1 answer
192 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 ...
lawlist's user avatar
  • 19.1k
3 votes
1 answer
466 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-...
abo-abo's user avatar
  • 14.1k
3 votes
1 answer
107 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 ...
Gabriele's user avatar
  • 1,554
3 votes
0 answers
136 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, ...
Basil's user avatar
  • 12.4k
3 votes
0 answers
127 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 ...
wasamasa's user avatar
  • 22.2k
2 votes
2 answers
794 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-...
Malabarba's user avatar
  • 23.2k
2 votes
2 answers
196 views

Why adding the display property does not work on some part of a file, while it works on other parts?

Let's say I have an org file with this content (this is the Org Manual): *** System-wide header arguments #+vindex: org-babel-default-header-args The file is opened normally, highlighted and ...
Tom's user avatar
  • 1,260
2 votes
2 answers
469 views

Org-mode add a property (e.g. effort) on the same row as my task (similar to priority and tags)

I'd like to show an additional property (e.g. EFFORT) on the same line as my tasks, so that it is always visible in both org-mode and agenda view. An example is below. Current display: TODO [#A] ...
Nidstang's user avatar
2 votes
1 answer
668 views

Add text property, when global-font-lock mode is on

I am trying to set the foreground color for first line in my buffer which has global-font-lock ON. Buffer contents - (ignore) (add-text-properties 1 8 '(:...
Saravana's user avatar
  • 2,071