all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Samuel Wales <samologist@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: remove all my added face text properties?
Date: Mon, 31 Oct 2022 07:36:22 +0300	[thread overview]
Message-ID: <Y19QxunsjDrJ9KRI@protected.localdomain> (raw)
In-Reply-To: <CAJcAo8uR-Wz8Kzo7DxotEAJbJgVzXooP9jPg98cASHFENf17cQ@mail.gmail.com>

* 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	other threads:[~2022-10-31  4:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  2:57 remove all my added face text properties? Samuel Wales
2022-10-31  4:36 ` Jean Louis [this message]
2022-10-31 11:30   ` Emanuel Berg
2022-10-31 18:23     ` Jean Louis
2022-11-03  5:04   ` Samuel Wales

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y19QxunsjDrJ9KRI@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=samologist@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.