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)....
Drew's user avatar
  • 77.5k
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-...
Tobias's user avatar
  • 33.2k
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 ...
Gilles 'SO- stop being evil''s user avatar
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-...
phils's user avatar
  • 51.1k
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 ...
zk_phi's user avatar
  • 446
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")))
JeanPierre's user avatar
  • 7,465
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 ...
Shmozart's user avatar
4 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. ...
Aquaactress's user avatar
  • 1,453
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 ...
Drew's user avatar
  • 77.5k
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 ...
John Kitchin's user avatar
  • 11.9k
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 ...
phils's user avatar
  • 51.1k
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 ...
db48x's user avatar
  • 18.1k
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 ...
YoungFrog's user avatar
  • 3,526
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 ...
Gabriele's user avatar
  • 1,554
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" :...
glucas's user avatar
  • 20.6k
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 ...
lawlist's user avatar
  • 19.1k
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))) ...
nispio's user avatar
  • 8,225
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 ...
Stefan's user avatar
  • 26.4k
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-...
Drew's user avatar
  • 77.5k
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 ...
rpluim's user avatar
  • 5,245
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 ...
John Kitchin's user avatar
  • 11.9k
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 ...
Basil's user avatar
  • 12.4k
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 ...
Tobias's user avatar
  • 33.2k
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-...
ngm's user avatar
  • 301
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 ...
JeanPierre's user avatar
  • 7,465
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 ...
Tobias's user avatar
  • 33.2k
3 votes
Accepted

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

Why does font-lock-mode work with various programming languages but it does not in text-mode? font-lock-mode works fine in text-mode, it's just that text-mode does not initialise font-lock-mode by ...
Basil's user avatar
  • 12.4k
3 votes
Accepted

Strange behaviour involving `display` property

I think this is exactly answered by the doc in (elisp) Replacing Specs. Consecutive text with the same display property is handled as a block, replacing it by the display property. If a list of ...
Drew's user avatar
  • 77.5k
2 votes
Accepted

How to programmatically walk along string and add text properties

The following is an alternative (but similar) method as described in the question above to walk (loop through) a string and add text properties: (defun walk-string+add-face (str) (loop with start ...
lawlist's user avatar
  • 19.1k

Only top scored, non community-wiki answers of a minimum length are eligible