insert image into text buffer

后端 未结 3 1345
醉酒成梦
醉酒成梦 2021-01-31 10:40

If I place

(insert-image (create-image \"/tmp/test.png\"))

in a buffer, place the cursor after the last parenthesis and evaluate it with

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 11:23

    If you don't want the text (actually lisp code) in the buffer, don't type it into the buffer in the first place. Try M-x eval-expression and enter your lisp code after the Eval prompt:

    (insert-image (create-image "/tmp/test.png"))
    

    Then the image is inserted at point in the buffer. You can define a function like this:

    (defun my-insert-image () (interactive) (insert-image (create-image "/tmp/test.png")))
    

    Either type M-x eval-expression and the above defun or type it into a buffer and C-x C-e after it. Then you can insert the image using M-x my-insert-image.

提交回复
热议问题