Skip to main content
26 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
  • 79.1k
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.7k
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
  • 53.1k
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
  • 79.1k
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,473
4 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.6k
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
  • 12.1k
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
  • 53.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
  • 19.1k
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.7k
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,546
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,680
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.9k
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
  • 79.1k
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,585
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
  • 12.1k
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.6k
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.7k
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

How to extract text properties into a string?

I had the same question for a long time. I don't know a "native" solution but a work-around using (format "%S" ...): (propertize "hello" 'face 'italic) ;; => #("hello" 0 5 (face italic)) (...
xuchunyang's user avatar
  • 14.8k
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,515
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.7k
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
  • 79.1k
3 votes
Accepted

Using query-replace to add text properties to replacement strings in Emacs

If you check any character of bar in the replacement with C-u C-x =, you'll see that there IS a text property there: ... There are text properties here: face hi-yellow The reason ...
NickD's user avatar
  • 33.6k
2 votes

text-properties bloat persistent undo files

Here is the solution I eventually came up with. (Thanks to @phils for optimizations). As far as I can tell, it seems to be working without issues. (defun nadvice/undo-tree-ignore-text-properties (old-...
PythonNut's user avatar
  • 10.5k
2 votes

masking text in an org-mode buffer

Put such text in drawers - which have very similar functionality. They are not hidden because of the fear from shoulder surfers, but they are considered to be unsightly, under the covers stuff so ...
Jeeves's user avatar
  • 659
2 votes
Accepted

undo-tree -- history file without text-properties

The following is a modified version of undo-tree-save-history. As the code in the first version of your question I don't write to a file but output the undo tree as a string. I hope that is okay. The ...
Tobias's user avatar
  • 33.7k

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