Cleanups for org-screenshot
This commit is contained in:
@@ -48,21 +48,22 @@
|
||||
(defun org-screenshot ()
|
||||
(interactive)
|
||||
(let* ((heading-name (org-get-heading t t t t))
|
||||
;; Strip out the font information from the heading name
|
||||
(_ (set-text-properties 0 (length heading-name) nil heading-name))
|
||||
(_ (shell-command (concat org-screenshot-exec-path " " org-screenshot-exec-args)))
|
||||
;; shell-command returns immediately, so wait until the screenshot is likely to have been taken
|
||||
(_ (sit-for 0.25))
|
||||
(in-file (car (nreverse (directory-files org-screenshot-import-path 'full "GameNotes.*.png"))))
|
||||
(out-dir-name (file-name-sans-extension (file-name-nondirectory buffer-file-name)))
|
||||
(out-dir (file-name-as-directory (concat (file-name-as-directory org-screenshot-export-path) out-dir-name)))
|
||||
(out-file (concat out-dir heading-name "-" (org-id-uuid) ".png")))
|
||||
(if (and (stringp in-file) (file-exists-p in-file))
|
||||
(progn
|
||||
(if (stringp in-file)
|
||||
(save-excursion
|
||||
(unless (file-exists-p out-dir)
|
||||
(make-directory out-dir))
|
||||
(rename-file in-file out-file)
|
||||
(message (format "Saved %S to %S" in-file out-file))
|
||||
(save-excursion
|
||||
(org-next-visible-heading 1)
|
||||
(org-open-line 1)
|
||||
(org-insert-link nil out-file)))
|
||||
(org-next-visible-heading 1)
|
||||
(org-open-line 1)
|
||||
(org-insert-link nil out-file))
|
||||
(message "Failed to find saved screenshot."))))
|
||||
|
||||
Reference in New Issue
Block a user