#StackBounty: #gnus #mu4e Editing a printed representation of object in elisp – change gnus button text-property

Bounty: 50

In the follow-up of this question, I am trying to edit a gnus-button text-property, called gnus-data, so that when my invitation emails are exported/updated into org-mode any MS safelinks have been filtered out. Now, I have no idea of what the text property is a printed representation of. I’ve tried to do a car or hash-table-count to check if it’s a list or hash-table and got a wrong argument type for both. type-of isn’t much more helpful, as it returns gnus-icalendar-event-request.

My problem is how to update that representation to filter out the safelinks and then save it back in the gnus-data text-property?

The below function is based on my previous question and has my current progress towards retrieving the printed representation object.

(defun unsafelinks (vmode)
  "This function filters MS safelinks from a message buffer"
  (let ((simple-url-regexp "https?://") urls)
      ;; edit text URLs
      (while (search-forward-regexp simple-url-regexp nil t)
    (when-let ((url (thing-at-point 'url))
           (bounds (thing-at-point-bounds-of-url-at-point)))
      (delete-region (car bounds) (cdr bounds))
      (insert (my-decode-safelink url))))
      ;; edit gnus data for invitation save/update to org-mode
      (while (not (eobp)) 
    (goto-char (next-overlay-change (point)))
    (when-let (link (get-text-property (point) 'gnus-data))
      (if (equal (get-text-property (point) 'gnus-callback) 'gnus-icalendar-sync-event-to-org)
          (type-of (eval link))))
    (goto-char (next-overlay-change (point))))
      ;; edit widget URLs
      (while (not (eobp)) 
    (goto-char (next-overlay-change (point)))
    (when-let (link (get-text-property (point) 'shr-url))             
      (and (string-match simple-url-regexp link) 
           ;; change overlay url echo
           (when (overlay-put (car (overlays-at (point))) 'help-echo (my-decode-safelink link)) t)
           ;; change url text-properties 
           (add-text-properties (point) (next-overlay-change (point)) (list 'shr-url (my-decode-safelink link) 'help-echo (my-decode-safelink link))) 
    (goto-char (next-overlay-change (point))))
      (when vmode (gnus-article-prepare-display)
        (set-buffer-modified-p nil)

And this is an edited example of what the printed representation looks like (I’ve inserted the link example from my previous question).

#s(gnus-icalendar-event-request "donald.duck@disney.com" "Disney catch-up meeting" "This is a general meeting.n________________________________________________________________________________nJoin Disney Teams Meeting<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Foffice.memoriesflower.com%2FPermission%2F%2525%2524%255E%2526%2526*%2523%2523%255E%2524%2525%255E%2526%255E*%2526%2523%255E%2525%2525%2526%2540%255E*%2523%2526%255E%2525%2523%2526%2540%2525*%255E%2540%255E%2523%2525%255E%2540%2526%2525*%255E%2540%2Foffice.php&data=01%7C01%7Cdavid.levin%40mheducation.com%7C0ac9a3770fe64fbb21fb08d50764c401%7Cf919b1efc0c347358fca0928ec39d8d5%7C0&sdata=PEoDOerQnha%2FACafNx8JAep8O9MdllcKCsHET2Ye%2B4%3D&reserved=0>n________________________________________________________________________________nn" "Disney Teams Meeting"
                (24387 42168)
                (24387 45768)
                nil "040000008200E00074C5B7101A82E00800000000304C204C352DD601000000000000000010000000EC49B8272CC9E446882F1BCD53D14E6B" "REQUEST" t required
                ("Mickey Mouse" "mickey.mouse@disney.com" "Goofy" "Goofy@disney.com" )

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.