Skip to content

Ynjxsjmh/emage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

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")

About

Enhance image insertion and yank on Emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published