Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.86 KB

README.org

File metadata and controls

57 lines (37 loc) · 1.86 KB

emage.el

This package is used to enhance image insertion and yank on Emacs.

Usage

Clone or download this repository (path of the folder is the <path-to-emage> used below).

In your ~/.emacs, add the following lines:

(add-to-list 'load-path "<path-to-emage>") ; add emage to your load-path

(require 'emage)

(global-set-key (kbd "C-c i i") 'emage-insert-clipboard-image-to-point)   ;; image insert
(global-set-key (kbd "C-c i y") 'emage-yank-image-at-point-to-clipboard)  ;; image yank

Global set key is not required, you can call these two commands with M-x.

Customization

To set default image saving directory for all buffers:

(setq-default emage-image-dir "images")

You can also use hook to change emage-image-dir when entering a specific mode. If you want to change the default directory to images and make emage-image-dir to be filename without extension in org mode, you can do as following:

(setq-default emage-image-dir "images")

(add-hook 'org-mode-hook
          (lambda ()
            (setq-local emage-image-dir (file-name-sans-extension (file-name-nondirectory (buffer-file-name))))))

Two ways to use your own image name generator:

(setq emage-image-name-generator #'(lambda () (format-time-string "%Y%m%d_%H%M%S")))
(defun emage-user-image-name-generator ()
  (format-time-string "%Y%m%d_%H%M%S"))

(setq emage-image-name-generator #'emage-user-image-name-generator)

If you change emage-user-image-name-generator, I advise you to make a description of how it generates filename and pass that description to emage-image-name-generator-description which is used as image name generating hint in minibuffer.

(setq emage-image-name-generator-description "default current timestamp")