From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: How to remove all text properties? Date: Thu, 10 Nov 2022 07:25:18 +0300 Message-ID: <2eca931bf774b4459744cabda9638c49.support1@rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38508"; mail-complaints-to="usenet@ciao.gmane.io" To: Help GNU Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 10 05:26:40 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osz9E-0009rv-Oy for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 10 Nov 2022 05:26:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osz8p-0004bW-Hp; Wed, 09 Nov 2022 23:26:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osz8o-0004ai-Dt for help-gnu-emacs@gnu.org; Wed, 09 Nov 2022 23:26:14 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osz8m-0000E8-8u for help-gnu-emacs@gnu.org; Wed, 09 Nov 2022 23:26:13 -0500 Original-Received: from localhost ([::ffff:102.82.46.36]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000081FE9.00000000636C7D41.0000573E; Wed, 09 Nov 2022 21:25:37 -0700 Received-SPF: pass client-ip=217.170.207.13; envelope-from=support1@rcdrun.com; helo=stw1.rcdrun.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:140880 Archived-At: This particular situation is related to showing arbitrary links in Emacs buffers. My intention is to have this type of Hyperlinks in Emacs buffers: ⟦ (hyperscope 123) ⟧ The above is template interpolation snippet, reference: RCD Template Interpolation System for Emacs: https://hyperscope.link/3/7/1/3/3/RCD-Template-Interpolation-System-for-Emacs.html The snippet alone is supposed to be bound to 2 possible directions: - to display itself as Emacs button (link) within Emacs buffer, depending of the mode of invocation; - to contain function that is to be executed upon pressing the button; What I wish to solve is removal of button text properties at time point when I wish to delete the button and reverse it back to original. The original link or snippet will be following: ⟦ (hyperscope 123) ⟧ The button will be "Hello" I wish to reverse the text properties of "Hello" to plain text properties and display original ⟦ (hyperscope 123) ⟧ Here is how button will be displayed: (insert-text-button "Hello" 'action (lambda (b) (message "Here")) 'follow-link t 'hyperscope-link 123) If one evaluates the above, one will see "Hello" underlined and with some text color, in general it will have different text properties. After evaluating above, user will get following: (insert-text-button "Hello" 'action (lambda (b) (message "Here")) 'follow-link t 'hyperscope-link 123)Hello And then by executing the function below, the "Hello" above will disappear and it will be reverted to ⟦ (hyperscope 123) ⟧ (defun rcd-revert-source () (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))) ;; It searches for text properties and reverts it back, ;; but with errors, as font is still red. (rcd-revert-source) 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. I guess that (rcd-revert-source) is not perfect, what am I missing? Why are text properties removed in mail-mode but not in Emacs Lisp mode? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/