1

テキスト プロパティを使用して、あるバッファから別のバッファにテキストをコピーしたいと考えています。ので、私は持っています

(with-current-buffer from-buffer
  (setq text-to-copy (buffer-substring beg end)))

すべてのテキスト プロパティを使用して、コピーするテキストを別のバッファに挿入するにはどうすればよいですか? 私は特に「顔」の特性に興味があります。

関数 buffer-substring はリストを返します。たとえば、("substring" 42 51 (face font-lock-keyword-face) 52 59 (face font-lock-function-name-face))

このリストを渡す(insert text-to-copy)と、テキスト プロパティが無視されるようです

4

3 に答える 3

2

挿入のターゲットバッファでがオンになっている場合、フォント化が開始されると、faceプロパティがリセットされます。 「face」を「font-lock-」に置き換えるには、font-lock-modeオフにするか、テキストプロパティを変更する必要があると思います。font-lock-mode挿入前の面」。

于 2009-11-24T14:58:37.727 に答える
0

' insert' 関数は、テキスト プロパティを含む文字列をそのまま処理する必要があります。buffer-substringデフォルトでは、存在する場合はテキスト プロパティを含む文字列を返すため、' '(insert text-to-copy)だけで十分です。

一方、テキストプロパティなしbuffer-substring-no-propertiesで文字列を抽出したい場合は、代わりに使用したいでしょう

于 2009-11-24T14:07:32.087 に答える
0

それはうまくいくはずです。これはEmacs 23.1.1からのものです:

buffer-substring is a built-in function in `C source code'.

(buffer-substring start end)

Return the contents of part of the current buffer as a string.
The two arguments start and end are character positions;
they can be in either order.
The string returned is multibyte if the buffer is multibyte.

This function copies the text properties of that part of the buffer
into the result string; if you don't want the text properties,
use `buffer-substring-no-properties' instead.

コマンドをdescribe-text-propertiesインタラクティブに使用して、実際に取得したものを確認できます。

describe-text-properties is an interactive compiled Lisp function in
`descr-text.el'.

It is bound to <C-down-mouse-2> <dp>, <menu-bar> <edit> <props> <dp>.
(describe-text-properties pos &optional output-buffer)

Describe widgets, buttons, overlays and text properties at pos.
Interactively, describe them for the character after point.
If optional second argument output-buffer is non-nil,
insert the output into that buffer, and don't initialize or clear it
otherwise.
于 2009-11-24T14:08:09.417 に答える