See the following code block:

#+BEGIN_SRC emacs-lisp 
(setq s #("abc" 0 3 (face (:foreground "red"))))
(pp s)

: #("abc" 0 3
:   (face
:    (:foreground "red")))

which is as expected, but literally just by evaluating,

#+BEGIN_SRC emacs-lisp

: abc

#+BEGIN_SRC emacs-lisp
(pp s) ;; how did s change?

: "abc"

I noticed this when calling C-c C-c on

#+BEGIN_SRC emacs-lisp

actually removes fontification on the mode line of the current clocking task.

This does not happen for C-x C-e(eval-last-sexp).

I'm using Org 9.1.9 on Emacs 26.3.

  • What is your question? – Tobias Mar 28 at 20:52

Let us have a look at org-no-properties which is used for removing the properties from the result string:

(defsubst org-no-properties (s &optional restricted)
  "Remove all text properties from string S.
When RESTRICTED is non-nil, only remove the properties listed
in `org-rm-props'."
  (if restricted (remove-text-properties 0 (length s) org-rm-props s)
    (set-text-properties 0 (length s) nil s))

For removing the text properties they use the destructive in-place functions remove-text-properties and set-text-properties.

That is the cause for the removal of the text properties from the original string.

They should copy the string with seq-copy before removing the properties.

The current behavior is unpleasant handling that could almost be regarded as a bug. Maybe, you should write an enhancement request with M-x report-emacs-bug RET.

Currently you are responsible for copying. Change your source block to:

(seq-copy org-mode-line-string)

Or use the advice I proposed in the answer to your related question.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.