Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| ;;; esi-org.el --- Org mode utilities -*- lexical-binding: t -*- | |
| (require 'org) | |
| (defun esi-org-get-body () | |
| "Return plain body text for org entry at current point." | |
| (let ((prop-bounds (org-get-property-block)) | |
| (entry-text (substring-no-properties (org-get-entry)))) | |
| (string-trim | |
| (if prop-bounds | |
| (substring entry-text (+ 19 (- (cdr prop-bounds) (car prop-bounds)))) | |
| entry-text)))) | |
| (defun esi-org-delete-entry () | |
| "Delete org entry at point from the buffer." | |
| (interactive) | |
| (org-cut-subtree) | |
| (pop kill-ring)) | |
| (defun esi-org--screenshot-store-path () | |
| "Return path to a directory that stores images for given ORG-FILE-NAME. | |
| Create the directory if not present." | |
| (let ((store-directory-path (file-name-as-directory "./images"))) | |
| (unless (file-exists-p store-directory-path) | |
| (make-directory store-directory-path)) | |
| store-directory-path)) | |
| (defun esi-org--screenshot-unique-file () | |
| "Return path to a unique image file in png" | |
| (let ((image-file (concat (number-to-string (float-time)) ".png"))) | |
| (concat (esi-org--screenshot-store-path) image-file))) | |
| (defun esi-org-insert-screenshot () | |
| "Take screenshot using `import' and insert in current buffer" | |
| (interactive) | |
| (let* ((image-path (esi-org--screenshot-unique-file)) | |
| (command (concat "import " image-path))) | |
| (call-process-shell-command command) | |
| (org-insert-link nil image-path "") | |
| (org-display-inline-images))) | |
| (defun esi-org-paste-image () | |
| "Paste image from clipboard into current buffer" | |
| (interactive) | |
| (let* ((image-path (esi-org--screenshot-unique-file)) | |
| (command (concat "xclip -selection clipboard -t image/png -o > " image-path))) | |
| (call-process-shell-command command) | |
| (org-insert-link nil image-path "") | |
| (org-display-inline-images))) | |
| (provide 'esi-org) | |
| ;;; esi-org.el ends here |