Skip to content

Instantly share code, notes, and snippets.

@anton0xf
Created July 14, 2021 21:01
Show Gist options
  • Save anton0xf/d73c2d7c535b19a160243bf0e430f31a to your computer and use it in GitHub Desktop.
Save anton0xf/d73c2d7c535b19a160243bf0e430f31a to your computer and use it in GitHub Desktop.
;; run it by command
;; $ emacs -Q --script test2.el
(setq line "asdf qwer")
(add-face-text-property 0 4 'a t line)
(add-face-text-property 0 5 'b t line)
(print line)
;; #("asdf qwer" 0 4 (face (a b)) 4 5 (face b))
(setq word (substring line 0 4))
(print (eq (cadr (text-properties-at 0 line))
(cadr (text-properties-at 0 word))))
;; t
(setq word1 (concat word "_"))
(print (eq (cadr (text-properties-at 0 line))
(cadr (text-properties-at 0 word1))))
;; t
(add-face-text-property 0 2 'c t word1)
(print (eq (cadr (text-properties-at 0 line))
(cadr (text-properties-at 0 word1))))
;; t
(print line)
;; #("asdf qwer" 0 4 (face (a b c)) 4 5 (face b))
(add-face-text-property 0 4 'd t word)
(print line)
;; #("asdf qwer" 0 4 (face (a b c d)) 4 5 (face b))
@anton0xf
Copy link
Author

Example for cpitclaudel/company-coq#252
Tested on emacs 26.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment