help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remove all my added face text properties?


From: Jean Louis
Subject: Re: remove all my added face text properties?
Date: Mon, 31 Oct 2022 07:36:22 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* Samuel Wales <samologist@gmail.com> [2022-10-31 05:58]:
> i set face properties in a roughly as follows:
> 
> (defun highlight-1 (extent)
>              (let ((p (point)))
>                ;; fixme what do we do to =remove= all of these
>                ;; added face properties in the buffer?  we need
>                ;; to do that when re-running this function to not
>                ;; keep the old stuff around.
>                ;;
>                ;; get-text-property but we need to get all?
>                ;; set-text-properties start end face?
>                (add-face-text-property p (+ extent p) '(:inverse-video t))))
> 
> what does one do to keep all the text properties, including face text
> properties, in the buffer, as they were before i first highlighted
> anyghing, while at the same time removing the face properties i added?
>  thank you.

This function will take buffer text without properties and insert it
again. This will most probably remove your properties, and then
because of major mode again highlight whatever was highlighted.

(defun rcd-buffer-remove-properties (&optional text)
  "Remove all properties for TEXT, otherwise buffer."
  (interactive)
  (let* ((buffer-or-text (if text nil t))
         (text (if buffer-or-text (buffer-substring-no-properties (point-min) 
(point-max)) text))
         (point (point)))
    (erase-buffer)
    (insert text)
    (goto-char point)))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]