1

The text to be processed has special words marked with a special font. The required text is copied to the clipboard with the mouse (from firefox). The text is pasted into the clipboard emacs("ctrl-y"). It is assumed that copying to the clipboard will also be required text properties (namely, the distinctive font of certain words) with subsequent transfer to the buffer emacs.

When such copied text is pasted into "LibreOffice Write", it is noticeable that the required the words have inherited the distinctive font, hence the inference that the text properties are on the clipboard.

In the emacs buffer, pasted text is printed in the same font. It is known that printing content buffer, namely character display is configurable in emacs buffer and is not important here.

It is assumed that the properties of the copied text also ended up in the emacs buffer. The task is to catch words in special font. It is supposed to use the text search functions by character property values.

Thanks for the reply Drew. A test procedure has been created:

(defun msgFace
  (fc nhl knc)
  (message "Шрифт `%s', начало области `%d', конец области `%d'" fc nhl knc))

variable edited yank-handled-properties:

((font-lock-face . yank-handle-font-lock-face-property) (category . yank-handle-category-property) (font . msgFace))

print to mini buffer (echo area) after pasting text:

Шрифт ‘nil’, начало области ‘74564’, конец области ‘75138’

Which text property character do you want to use? The copied text uses three fonts

    ;;;emacs mode texinfo emacs=>clipboard
  (gui-get-selection 'CLIPBOARD)
  ;;;==>#("потребуются @emph{freeze} сопрограммы" 0 12 (fontified t) 12 13 (fontified t) 13 17 (fontified t face font-lock-keyword-face) 17 18 (fontified t) 18 24 (fontified t face italic) 24 37 (fontified t))
  ;;;firefox=>clipboard
  (gui-get-selection 'CLIPBOARD)
  ;;;==>A Lisp object is a piece of data used and manipulated by Lisp programs. For our purposes, a type or data type is a set of possible objects. " 0 159 (foreign-selection STRING))

List properties = (foreign-selection STRING) -?

4
  • I don't understand what you're doing with your "test" procedure. And message doesn't write to the minibuffer; it writes to the echo area. Can you provide a step-by-step recipe that illustrates what you're copying and pasting etc.? A face includes font information...
    – Drew
    Commented Jun 21, 2023 at 22:35
  • open resource in firefox "gnu.org/software/emacs/manual/html_node/elisp/…", copy the first paragraph "Emacs normally displays an error message when an error is signaled and not handled with condition-case. While Edebug is active and executing instrumented code, it normally responds to all unhandled errors. You can customize this with the options edebug-on-error and edebug-on-quit; see Edebug Options."
    – uanr81
    Commented Jun 22, 2023 at 20:36
  • Words "condition-case", "edebug-on-error", "edebug-on-quit" и "Edebug Options" have different spelling. It is required to catch such words in the emacs buffer after inserting a text fragment. when printing (gui-selection-value), I cannot determine the differences in the properties of the characters of the given words.
    – uanr81
    Commented Jun 22, 2023 at 20:37
  • thanks for the note echo area
    – uanr81
    Commented Jun 22, 2023 at 20:38

1 Answer 1

0

M-x customize-option yank-properties

yank-handled-properties is a variable defined in simple.el.

Its value is

((font-lock-face . yank-handle-font-lock-face-property)
 (category . yank-handle-category-property))`

Documentation:

List of special text property handling conditions for yanking.

Each element should have the form (PROP . FUN), where PROP is a property symbol and FUN is a function. When the yank command inserts text into the buffer, it scans the inserted text for stretches of text that have eq values of the text property PROP; for each such stretch of text, FUN is called with three arguments: the property's value in that text, and the start and end positions of the text.

This is done prior to removing the properties specified by yank-excluded-properties.

You can customize this variable.

See the Emacs manual, node Yanking.

2
  • That's for yanking Emacs<->Emacs, this is from firefox. This sounds like they'd want to investigate yank-media-types, which is new in emacs-29 (I suspect firefox is providing text/html)
    – rpluim
    Commented Jun 21, 2023 at 13:33
  • Thanks for the answer. Added text in question
    – uanr81
    Commented Jun 21, 2023 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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