Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dnxbjyj authored Oct 8, 2021
2 parents cf94648 + 8512fb4 commit faaab51
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pasteex-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,24 @@
(unless (buffer-file-name)
(user-error "Current buffer is not related to any file."))
;; make img dir if not exists
(setq img-dir (concatenate 'string "./" (file-name-nondirectory (buffer-file-name)) "_imgs/"))
(setq img-dir (concatenate 'string (file-name-directory (buffer-file-name)) "img/"))
(unless (file-directory-p img-dir)
(make-directory img-dir))
;; build image file name (use `pasteex_screenshot' as prefix, following buffer name, following datetime string)
(setq img-file-name (format "pasteex_screenshot_%s_%s.png" (file-name-base (buffer-file-name)) (format-time-string "%Y%m%d%H%M%S")))
(setq img-file-name (format "scr_%s_%s.png" (file-name-base (buffer-file-name)) (format-time-string "%Y%m%d%H%M%S")))
(setq full-img-path (concatenate 'string img-dir img-file-name))
;; save image file to img-dir by invoking pasteex executable command
(let* ((shell-command-str ""))
(cond
((eq system-type 'darwin) (setq shell-command-str (format "%s - > %s%s" pasteex-macos-executable-path img-dir img-file-name)) )
((eq system-type 'windows-nt) (setq shell-command-str (format "%s /q %s %s" pasteex-executable-path img-dir img-file-name)))
((eq system-type 'windows-nt) (setq shell-command-str (format "%s -q %s" pasteex-executable-path full-img-path)))
(t (user-error "Only Support Macos and Windows")))
(message "shell command str is:%s" shell-command-str)

(shell-command shell-command-str)
)

(setq relative-img-file-path (concatenate 'string img-dir img-file-name))
(setq relative-img-file-path (concatenate 'string "./img/" img-file-name))
;; check is png file or not
(unless (pasteex-is-png-file relative-img-file-path)
;; delete the generated file
Expand Down

0 comments on commit faaab51

Please sign in to comment.