102

私は独自のカスタムカラーテーマを開発してきましたが、カーソルの下のテキストに影響を与えるフォント面のリストを取得できれば非常に便利です。

Textmateのshowcurrentscopeコマンドのようなものです。

これにより、Mxのcustomize-faceを実行し、使用可能なオプションを調べて、現在使用している単語に影響を与えるオプションを推測する手間を省くことができます。

何か案は?

4

6 に答える 6

184

what-cursor-position接頭辞付きの引数は、他の情報の中でも特に、ポイントの下の面を示します。

キーボードショートカットはCuCx=です。

出力例(faceプロパティは最後の段落に示されています):

             position: 5356 of 25376 (21%), column: 4
            character: r (displayed as r) (codepoint 114, #o162, #x72)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x72
               syntax: w    which means: word
             category: .:Base, L:Left-to-right (strong), a:ASCII, l:Latin, r:Roman
          buffer code: #x72
            file code: #x72 (encoded by coding system undecided-unix)
              display: by this font (glyph code)
    nil:-apple-Monaco-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1 (#x55)

Character code properties: customize what to show
  name: LATIN SMALL LETTER R
  general-category: Ll (Letter, Lowercase)
  decomposition: (114) ('r')

There are text properties here:
  face                 org-level-2
  fontified            t

[back]
于 2009-08-07T03:36:16.937 に答える
69

Mxdescribe-face

于 2009-08-08T18:53:16.373 に答える
44

what-face次のコードで定義できます。

(defun what-face (pos)
  (interactive "d")
  (let ((face (or (get-char-property (pos) 'read-face-name)
                  (get-char-property (pos) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))

その後、

M-x what-face

現在のポイントで見つかった顔を印刷します。

(組み込まれていないことを指摘してくれたthedzwhat-faceに感謝します。)

于 2009-08-07T01:02:23.990 に答える
8

トレイの顔は正しい軌道に乗っています。それは私をこれを持っていたメーリングリストの電子メールに導きました:

(defun what-face (pos)
    (interactive "d")
        (let ((face (or (get-char-property (point) 'read-face-name)
            (get-char-property (point) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))
于 2009-08-07T01:20:08.790 に答える
2

「what-face」コードにバグがあります。関数は引数として「pos」を取りますが、顔を取得するときにそれを使用しません。代わりに、メッセージが後でposを要求しても、「(point)」を使用します。 「%dに顔がない」場合。

于 2013-12-30T17:25:42.917 に答える
0

@tray関数を試しましたが、機能しませんでした。@thedz定義は機能します。

(defun what-face (pos)
  (interactive "d")
  (let ((face (or (get-char-property (point) 'read-face-name)
                  (get-char-property (point) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))

いくつかの調査の後、私はその理由を見つけました:

  • (point)ポイントの値を整数として返す関数です。
  • pos(interactive "d")ポイントの位置となる戻り値を整数として取得します。
  • get-char-property位置を期待します。この場合、関数によって与えられます(point)
于 2021-02-20T02:38:50.040 に答える