all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eduardo Ochs <eduardoochs@gmail.com>
To: Jean Louis <bugs@gnu.support>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: How to remove all text properties?
Date: Sun, 13 Nov 2022 02:16:11 -0300	[thread overview]
Message-ID: <CADs++6hvkMBZWL5n4F4tWmvMi4DuqK-Epnh+yAgOWRV7fa87eQ@mail.gmail.com> (raw)
In-Reply-To: <2eca931bf774b4459744cabda9638c49.support1@rcdrun.com>

On Thu, 10 Nov 2022 at 01:26, Jean Louis <bugs@gnu.support> wrote:
>
> The problem that I see is that my function above can revert text
> properties in this *mail* buffer in major-mode ⇒ mail-mode, but it
> cannot revert text properties in emacs-lisp-mode, where "Hello"
> becomes read, and then after reverting, the original snippet ⟦
> (hyperscope 123) ⟧ becomes red too.


Hi Jean Louis,

I saved this to the file /tmp/o,

--snip--snip--

(defun rcd-insert-hello ()
  (interactive)
  (insert-text-button "Hello"
                      'action (lambda (b) (message "Here"))
                      'follow-link t
                      'hyperscope-link 123))

(defun rcd-revert-source ()
  (interactive)
  (let ((point (point)))
    (save-excursion
      (goto-char (point-min))
      (let (my-prop)
        (while (setq my-prop
                     (text-property-search-forward
                      'hyperscope-link))
          (when my-prop
            (let ((begin (prop-match-beginning my-prop))
                  (end (prop-match-end my-prop))
                  (value (prop-match-value my-prop)))
              (set-text-properties (1- begin) end nil)
              (delete-region begin end)
              (goto-char begin)
              (insert (format "⟦ (hyperscope-link %s) ⟧" value)))))))
    (goto-char point)))

;; (rcd-insert-hello)
;; (rcd-revert-source)

--snip--snip--

and then I tried this:

  1. without changing its mode from fundamental-mode to something else
     I ran the two defuns and the (rcd-insert-hello); it inserted a
     button whose text was "Hello",

  2. I ran my `find-eregionpp', defined here,

       (find-efunction 'find-eregionpp)
       (find-eev "eev-blinks.el" "find-eregionpp")
       http://angg.twu.net/eev-current/eev-blinks.el.html#find-eregionpp

     on the ")Hello\n", and saved its output in another file - I will
     discuss it soon,

  3. I ran the (rcd-revert-source) - it converted the "Hello" to this:

       "⟦ (hyperscope-link 123) ⟧"

  4. I ran some undos to delete the "⟦ (hyperscope-link 123) ⟧" and
     the "Hello",

  5. I ran `M-x emacs-lisp-mode',

  6. I ran the (rcd-insert-hello) again. It inserted a button whose
     text was "Hello". That button worked as expected - typing
     RET on it ran (message "Here") - but it didn't look like a
     button: it was displayed in font-lock-comment-face,

  7. I ran `M-x find-eregionpp' on the ")Hello\n" and saved its
     output in another file,

  8. I ran the (rcd-revert-source). It worked as before - it
     converted the "Hello" to this:

       "⟦ (hyperscope-link 123) ⟧"

  9. I ran some undos.

Here is the output of the `find-eregionpp's. The first one, that
was run with the file in fundamental-mode, gave this:

  ((")")
   ("Hello"
    (action (lambda (b) (message "Here")))
    (button (t))
    (category default-button)
    (follow-link t)
    (hyperscope-link 123))
   ("\n"))

and the second one, that was run with the file in
emacs-lisp-mode, gave this:

  ((")"
    (face font-lock-comment-face)
    (fontified t))
   ("Hello"
    (action (lambda (b) (message "Here")))
    (button (t))
    (category default-button)
    (face font-lock-comment-face)
    (follow-link t)
    (fontified t)
    (hyperscope-link 123))
   ("\n"
    (face font-lock-comment-face)
    (fontified t)))

The difference was that in emacs-lisp-mode all three intervals
had these extra properties:

    (face font-lock-comment-face)
    (fontified t)

In fundamental-mode the face of the "Hello" was inherited from the
`(category default-button)'. I found that face - `button' - with `C-u
C-x =', but here are three low-level links that sort of point to that
information:

  (find-egrep "grep --color=auto -nH --null -e default-button *.el */*.el")
  (find-efile "button.el" "(put 'default-button 'face 'button)")
  (describe-text-category 'default-button)

In emacs-lisp-mode the "Hello" had this among its text properties,

  (face font-lock-comment-face)

and this took precedence over the face from the category.

Does that help?
  Cheers,
    Eduardo Ochs
    http://angg.twu.net/eepitch.html



      parent reply	other threads:[~2022-11-13  5:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10  4:25 How to remove all text properties? Jean Louis
2022-11-10 18:18 ` Emanuel Berg
2022-11-12  8:33   ` Jean Louis
2022-11-13  5:16 ` Eduardo Ochs [this message]

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=CADs++6hvkMBZWL5n4F4tWmvMi4DuqK-Epnh+yAgOWRV7fa87eQ@mail.gmail.com \
    --to=eduardoochs@gmail.com \
    --cc=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    /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.