25
votes
Accepted
How to strip decorations (text properties) from a string?
[Your propertized string looks wrong - perhaps you copied it wrong. foo has only 3 characters, so it is impossible for it to be fontified on chars 0 to 4 (i.e., chars 0, 1, 2, and 3 - that's 4 chars)....
12
votes
Accepted
Can I use an image in my modeline lighter?
The mode line is rendered from a list of segments, each of which come with their own special rules. See Mode Line Data for the details. The symbol section contains a crucial hint to make your code ...
7
votes
Accepted
Why does `insert` not insert colorized text?
You probably try that in the *scratch* buffer or any other buffer with active font-lock-mode.
In such a buffer the faces are immediately adapted to the rules prescribed by the variable font-lock-...
7
votes
Accepted
Why does mousing over one button also highlight adjacent buttons?
Buttons are based on text properties. Each character in a buffer has its own properties. Emacs doesn't record start and end positions for properties: properties are not intervals. When it needs to ...
5
votes
Can I use an image in my modeline lighter?
Good question.
You might try using something like this as the lighter: (concat " " (propertize " " 'display (create-image img-file))), where img-file is the name of your image file. (The first space ...
5
votes
Accepted
Make parts of a working buffer read-only
(defface my-read-only '((default . (:background "beige")))
"Face for `my-read-only-region'")
(defun my-read-only-region (begin end)
"Make the marked region read-only. See also `my-writeable-...
4
votes
Accepted
Add clickable text in read only buffer?
The reason for the error is that you did not use the correct format to add a text property.
quote from manual:
Function: add-text-properties start end props &optional object
The argument props ...
4
votes
Accepted
Add text property, when global-font-lock mode is on
When font-lock-mode is in use, you can use the font-lock-face property instead of face.
(add-text-properties 1 8 '(font-lock-face (:foreground "red")))
4
votes
Accepted
How to get an insert-text-button 'action property accessing a dynamically-bound buffer-local variable
You can add not only action but any other attributes to a text-button, that can be referred later with button-get function. So saving the (reference to the) current buffer, together with action, seems ...
4
votes
New line in cursor-intangible area and line-beginning position
Applying field property to intangible area solves the problem.
Adding of field t to the properties of INTANGIBLE makes move-beginning-of-line putting point between INTANGIBLE and fooooo, like ...
4
votes
Accepted
Text as text properties?
You can put any Lisp object (thingie) on a character as a text property or on in an overlay as an overlay property or on a symbol as a symbol property.
You speak of "strings" but in your examples I ...
4
votes
Org-mode question: Evaluating lisp in property
Here is a way to do what you want. I took the liberty of expanding the export_file_name to resemble what I think you implied in the comments above. I don't think this is the best way to do what you ...
4
votes
Can Emacs enriched-text be displayed by other applications, browsers?
The etc/enriched.txt file points out that the basic file format is the text/enriched MIME format described by RFC1896:
https://www.ietf.org/rfc/rfc1896.txt
Enriched-mode documents are saved in an ...
4
votes
How to return "string" after changing it's text properties?
This is an extremely basic question about Emacs Lisp, and it has nothing to do with strings or add-face-text-property specifically. You really should read through the Emacs Lisp Intro, which is a ...
3
votes
Accepted
Evaluate parts inside text-property string using read syntax?
I think it's sort of possible in some cases, but not out of the box.
Spoiler alert : I did not write any code, sorry!
Roughly, when you're going to evaluate some lisp (e.g. from a buffer), three ...
3
votes
Text as text properties?
Ok, I accepted the Drew's answer but I want also to share the complete solution I finally adopted.
This is the code:
(defun BibitemNumbering ()
(interactive)
(save-excursion
(let ((counter ...
3
votes
masking text in an org-mode buffer
Another quick workaround might be to use highlight-regexp with a face that masks the text.
For example, define a new face that is just black on black:
(defface mask '((t (:background "black" :...
3
votes
How do I get the closest property change before a given point?
Something like this should work:
(defun last-prop-change (prop &optional limit)
(let ((pos+1 (min (1+ (point)) (point-max))))
(previous-single-char-property-change pos+1 prop nil limit)))
...
3
votes
Accepted
add-text-properties throws args out of range
The first point in the buffer is 1, not 0 -- that is why the example produces an error message stating Args out of range . . .. The doc-string for add-text-properties states that START and END are ...
3
votes
Accepted
re-search-forward through visible text only
After doing some research I realized that first I worded my question imprecisely because I was not aware of the term for describing text that is invisible through folding. The term is overlay.
...
3
votes
Determine the face(s) that would be applied to a character inserted at point, after font-lock does its thing?
I don't think "inserting x and seeing the resulting font-lock highlighting" is a good approach in general. You'll likely be better off calling asking directly the code that performs this font-lock ...
3
votes
Accepted
Make region(s) invisible (not evaluated) to query-replacy and similar commands
Yes. Set variable isearch-filter-predicate to a function that returns nil for the text that you want to ignore for search and query-replace.
(Set it back to its default value of isearch-filter-...
3
votes
Accepted
Make text clickable: add urls with a loop
Your lambda has a reference to the variable 'URL', what you want is the value of 'URL'. One way to do that is with the backquote ` , which is similar to the normal quote, but allows you to evaluate ...
3
votes
How to modify a string without altering its text properties
I think you can do this:
(setq myvar (apply #'propertize "mystring" (text-properties-at 0 myvar)))
I didn't find any way to use setf or some similar kind of thing to just modify the string contents ...
3
votes
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?
AFAIK, this isn't possible (or practical) in the most ...
3
votes
How can I search for bolded text?
You can filter the interesting isearch-matches by the function registered at the variable isearch-filter-predicate.
I demonstrate this below in a simplified way.
I only check the first letter of the ...
3
votes
Org-mode add a property (e.g. effort) on the same row as my task (similar to priority and tags)
I don't know how to get it in to both normal view and the agenda view. But, in case it's helpful, one simple way to get effort into headlines in to the agenda view at least, is to edit org-agenda-...
3
votes
Accepted
How to extract text properties into a string?
You can extract properties from a given position of a string or buffer with function text-properties-at. Here's its docstring (C-h f text-properties-at):
text-properties-at is a built-in function ...
3
votes
Accepted
Why adding the display property does not work on some part of a file, while it works on other parts?
The text property is removed by font-lock in org-mode buffers.
The list org-font-lock-extra-keywords contains the function org-fontify-meta-lines-and-blocks as a matcher of a font lock keyword for ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
text-properties × 139org-mode × 20
faces × 19
font-lock × 18
overlays × 11
string × 10
org-agenda × 7
elisp × 7
fonts × 7
isearch × 6
display × 5
read-only-mode × 5
search × 4
mode-line × 4
visibility × 4
buffers × 3
text-editing × 3
minor-mode × 3
highlighting × 3
text × 3
latex × 2
hooks × 2
themes × 2
keymap × 2
colors × 2