[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). I use 3 instead of 4 in the example here.]
(let* ((foo #("foo" 0 3 (fontified t face font-lock-function-name-face)))
What are Overlays?
First of all, they are elisp objects. This will be relevant later.
As you said yourself, they represent layers that apply on top of
regions of the buffer. These layers have text properties, just like
the actual text in the buffer. Any regular property that an overlay
has, applies to the text below it. However, there are some properties
Add the following to your init-file:
(defun unpropertize-kill-ring ()
(setq kill-ring (mapcar 'substring-no-properties kill-ring)))
(add-hook 'kill-emacs-hook 'unpropertize-kill-ring)
How it works
substring-no-properties removes any text properties from a given string. kill-ring is a list of strings; we're using mapcar to apply substring-no-properties ...
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 work:
Unless SYMBOL is marked as “risky” (i.e., it has a non-‘nil’
‘risky-local-variable’ property), all text properties specified in
SYMBOL’s value are ...
You need to (before adding property read-only), make the first character have a value that includes read-only for property front-sticky:
(put-text-property 1 2 'front-sticky '(read-only)) ; Do this one first.
(put-text-property (point-min) 50 'read-only t)
See the Elisp manual, node Sticky Properties.
The problem was that although the first char had a non-...
See libraries cus-edit.el and wid-edit.el (and their top-level libraries custom.el and widget.el, and associated component libraries), which are included with GNU Emacs. The former makes use of the latter. The latter defines basic (and not-so-basic) form-entry thingies, called "widgets", in a hierarchy. You can use these predefined widgets and functions in ...
Use the raise display property. As explained in (info "(elisp) Other Display Specs"):
This kind of display specification raises or lowers the text it
applies to, relative to the baseline of the line.
FACTOR must be a number, which is interpreted as a multiple of the
height of the affected text. If it is positive, that ...
What you want to do is to set the display-table entry for character LEFT-TO-RIGHT EMBEDDING to the glyph that is used for character SECTION SIGN.
(aset (or (window-display-table) standard-display-table)
8234 ; 0x202A, which is the char LEFT-TO-RIGHT EMBEDDING
(vector (make-glyph-code ?§)))
If the selected window has its own display table, then ...
One simple solution is to use savehist-20.el.
It is a version of savehist.el that works with all Emacs versions (20+). It automatically strips history elements of properties, and it does not save variables in savehist-additional-variables whose values are propertized strings.
In other words, you can read the file it saves even in an Emacs version (e.g. 20) ...
Yes, it’s possible
A couple of points on your function:
Don’t cut the text before you need it.
Use the third argument for search-forward-regexp to avoid getting errors.
(defun source-to-final ()
"Cut refs from the txt, but letting them appear as text properties."
I've whipped up a working example of a function that takes a string and temporarily displays it with a timeout after the buffer text:
(defun my-momentarily-display-after-buffer-end (string &optional timeout)
(let ((ov (make-overlay (point-max) (point-max))))
(overlay-put ov 'after-string
(concat (propertize " " 'display
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-keywords.
Use the property font-lock-face instead of face in those buffers.
The modified version of your example would be:
(insert #("abc" 0 3 (font-lock-face (:...
You can use the mouse-face property.
For example, the following snippet will make "f" look like a button when you hover the mouse pointer over it:
(concat "[" (propertize "f" 'mouse-face 'mode-line-highlight) "]:add file")
'local-map (make-mode-line-mouse-map 'mouse-1 'aria2-add-file)) " "))
Another possibility would be to display line numbers and say the line number before the word, or, since looking over to get the exact line number would be bothersome, you could have the algorithm search within + or - 5 or 10 lines of the number you say.
Or perhaps declare a region or function that you are working in and have all searches only look there. I ...
As far as I understand, compose-region and the underlying composition text property can only result in displaying a single glyph (which may be built from several parts). When you pass multiple glyphs, they are assembled together in a single cell. The TAB character says to enlarge the cell so that the composite glyph fits entirely. It doesn't result in ...
OK, here's a simple demonstration of @Lindydancer's technique, which in this case turns the whole buffer invisible.
(defun my-mode () "my-mode" (interactive)
(setq font-lock-defaults '(my-mode-font-lock-keywords t)))
(defvar my-mode-font-lock-keywords nil
"Keywords/Regexp for ...
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 specifies which properties to add. It should have the form of a property list (see Property Lists): a list whose elements include the property names ...
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 char is just to separate this lighter from the previous one.)
Well, I just tried, using this code, but it did not work for me. You might try fiddling a bit ...
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 see no strings. I see only buffer text (presumably). What you apparently want to do is put something (strings perhaps?) as a text property (or as multiple text ...
(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-region'.
Read-only text is given the face `my-read-only'."
(let ((inhibit-read-only t))
Text properties are not globally defined for the string but for each character in the string. Therefore, text properties cannot be transposed literally if strings are different.
Although different objects may have similar characteristics, the properties are intrinsic to each object. The text properties are defined specifically for each object, whatever its ...
See the documentation on the function image-size:
image-size is a built-in function in `C source code'.
(image-size SPEC &optional PIXELS FRAME)
Return the size of image SPEC as pair (WIDTH . HEIGHT). PIXELS non-nil means return the size in pixels, otherwise return the size in canonical character units. FRAME is the frame on which the image ...
@Malabarba's comment provides the answer. Try it interactively: M-x hc-highlight-chars.
It works for me. I use C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET to insert character LRE (U+202A) in a buffer.
Then I use M-x hc-highlight-chars, and at the prompt I enter the same character (the same way: C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET).
Then I hit RET again to ...
Here is what works in general as described above (associating text with data using the 'field property). The string for each field is augmented with a 'field text property containing the underlying data. The string for the whole row is augmented with a custom property prefixed with the name of the major mode (e.g. 'grid-engine-job) which contains the ...
A followup to @rekado's great answer -
I do this kind of thing all the time. I often put the entire alist on the buffer text (or on a string, depending on the use case), as a text-property value: (propertize string 'my-data the-alist).
It's worth pointing out, because it might not be obvious to everyone, that the actual data - not a copy of it, is being ...
@PythonNut is correct that (image-size) is the function you are looking for. With it, you can extract the height and width from an image in image-mode like so:
(let* ((image-dimensions (image-size (image-get-display-property) :pixels))
(width (car image-dimensions))
(height (cdr image-dimensions))
For example and maybe on a ...