2

text-properties-at returns a list of various text properties.

I want to remove: display (image :type xpm :file /Users/HOME/.0.data/.0.emacs/.0.images/ezimage/box-plus.xpm :scale 1.1070588235294117 :ascent center). The image may change, so I'd like a general approach that targets the display property and any value that may exist in relation thereto.

I thought I was dealing with a plist and I read about remprop, but it strips everything in the entire list -- i.e., it makes the whole list nil.

    (let ((props (text-properties-at 0 OBJECT)))
      (setq props (remprop 'props 'display)))
  • 1
    remprop deals with a symbol's property list - a concept very rarely used in Emacs Lisp (plausible uses for it are debugging of ELisp code, saving extra information with special variables). – wvxvw Jan 19 '17 at 10:34
  • As for the implementation of such function, you would have to specify whether you want it to be in-place, or to return a copy, what to do with multiple entries of the same property-value pair and whether it's OK to use (setf (car ...) ...) or similar. – wvxvw Jan 19 '17 at 10:40
  • 1
    Does (remove-text-properties START END '(display nil) OBJECT) work for you? though I am not sure about what you want. – xuchunyang Jan 19 '17 at 10:56
  • What @xuchunyang said. It's not clear just what you want to do. Use remove-text-properties to remove any given properties altogether. If you want to modify one or more properties, see set-text-properties. – Drew Jan 19 '17 at 14:48
  • Thank you @wvxvw @xuchunyang @Drew @pingi for looking at this particular thread/issue. I ended up using org-plist-delete to remove the pair of PROPERTY / VALUE from the PLIST. The inspiration for this project was to fix a bug in org-agenda-highlight-todo which takes text properties found at the beginning of a string and creates a new " " space between the org-mode todo-keyword and the priority. I am using icons set with org-agenda-category-icon-alist and my particular org-agenda-prefix-format leaves the icon right where org-agenda-highlight-todo can find it -- i.e., FIXME :) – lawlist Jan 19 '17 at 18:58
1

cl-remprop deletes a property that is associated with the symbol props itself. This property list is nil already. (And remprop only returns true if something was found+deleted, and nil otherwise.)

In your case, the property list you want to change is the value the symbol happens to be bound to.

The function you search is likely remove-text-properties:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Changing-Properties.html#Changing-Properties

  • I upvoted because this answer teaches me about cl-remprop and explains why it was not working as I had erroneously expected. I ended up using org-plist-delete to modify the list of properties because my use-case was to fix a bug that comes about when org-agenda-highlight-todo copies text properties from the beginning of a string and creates a new space " " elsewhere that has the copied text properties applied to it. – lawlist Jan 19 '17 at 19:24
  • If you found the correct solution to your problem there nothing against posting an answer to your own question. emacs.stackexchange.com/help/self-answer – Vera Johanna Jan 20 '17 at 8:27
  • 1
    I posted an answer 14 hours ago, but there is something like a 36 or 48 hour waiting period before an original poster can accept his/her own answer. – lawlist Jan 20 '17 at 8:42
0

org-mode contains a handy function called org-plist-delete inside org-macs.el

(let ((props (text-properties-at 0 OBJECT)))
  (setq props (org-plist-delete props 'display)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.