Add interactive wrapper around path function
copied from image-file-name added test to see that file name unchanged when no attachments
This commit is contained in:
@@ -293,10 +293,15 @@ the description. This may destroy existing links, or change their targets so use
|
||||
))))))
|
||||
|
||||
(defun qwan/image-mode-copy-filename-as-markdown-link ()
|
||||
"example: /Users/willem/MyDocuments/qwan/sites/qwaneu.github.io/attachments/blogposts/2023/time-for-improvement-game-changer.svg
|
||||
result: "
|
||||
"Push the currently visited file name onto the kill ring."
|
||||
(interactive)
|
||||
(image-mode-copy-file-name-as-kill))
|
||||
(unless buffer-file-name
|
||||
(error "The current buffer doesn't visit an image file"))
|
||||
(let ((path-from-attachements (qwan/relative-path-to-attachments buffer-file-name)))
|
||||
|
||||
(kill-new path-from-attachements)
|
||||
(message "Copied %s" path-from-attachements)))
|
||||
|
||||
|
||||
|
||||
(defun qwan/relative-path-to-attachments (full-path)
|
||||
@@ -304,14 +309,10 @@ the description. This may destroy existing links, or change their targets so use
|
||||
|
||||
(require 'ert)
|
||||
(ert-deftest relative-path-to-attachments-removes-prefix ()
|
||||
"Building block for creating url to images in the site"
|
||||
(should (equal (qwan/attachments-remove-prefix-path "prefix/attachments") "/attachments")))
|
||||
|
||||
(ert-deftest relative-five-does-not-equal-four ()
|
||||
(should
|
||||
(eql 5 5)))
|
||||
|
||||
|
||||
(ert-deftest relative-path-to-attachments-does-not-remove-prefix-when-no-attachments ()
|
||||
(should (equal (qwan/attachments-remove-prefix-path "prefix/somethingelse") "prefix/somethingelse")))
|
||||
|
||||
(ert "relative.*")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user