refactor rename plus old stuff
This commit is contained in:
@@ -291,16 +291,19 @@ the description. This may destroy existing links, or change their targets so use
|
||||
(delete-region link-begin (- link-end 1))
|
||||
(insert new-link)
|
||||
))))))
|
||||
(defun qwan/string-as-markdown-image-link (a-string)
|
||||
(concat ""))
|
||||
|
||||
(defun qwan/image-mode-copy-filename-as-markdown-link ()
|
||||
"Push the currently visited file name onto the kill ring."
|
||||
(defun qwan/image-mode-copy-filename-as-markdown-image-link ()
|
||||
"Push a markdown link to the currently visited image onto the kill ring."
|
||||
(interactive)
|
||||
(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)))
|
||||
(let ((markdown-link (qwan/string-as-markdown-image-link
|
||||
(qwan/relative-path-to-attachments buffer-file-name))))
|
||||
|
||||
(kill-new path-from-attachements)
|
||||
(message "Copied %s" path-from-attachements)))
|
||||
(kill-new markdown-link)
|
||||
(message "Copied %s" markdown-link)))
|
||||
|
||||
|
||||
|
||||
@@ -314,8 +317,47 @@ the description. This may destroy existing links, or change their targets so use
|
||||
(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.*")
|
||||
(ert-deftest markdown-link-tokens-should-surround-string ()
|
||||
(should (equal (qwan/string-as-markdown-image-link "prefix/image.png")
|
||||
"")))
|
||||
|
||||
(let ((full-path-in
|
||||
"/Users/willem/MyDocuments/qwan/sites/qwaneu.github.io/attachments/blogposts/2023/time-for-improvement-game-changer.svg"
|
||||
)))
|
||||
|
||||
(ert "markdown.*")
|
||||
(defun qwan/echo (new-name)
|
||||
(interactive "SRename function to:")
|
||||
(message "Will rename to %s" new-name)
|
||||
)
|
||||
|
||||
;; from @tbf@functional.cafe
|
||||
(defun movd (from to)
|
||||
(fset to (symbol-function from))
|
||||
(fset from nil)
|
||||
to)
|
||||
|
||||
;; from @tbf@functional.cafe
|
||||
(defmacro frename (from to)
|
||||
`(movd ',from ',to))
|
||||
|
||||
|
||||
(defun qrefactor/rename
|
||||
(new-name)
|
||||
"Rename function at point. You must modify references yourself"
|
||||
(interactive "MRename function to:")
|
||||
(let
|
||||
((bounds
|
||||
(bounds-of-thing-at-point 'symbol)))
|
||||
(if bounds
|
||||
(progn
|
||||
(let*
|
||||
((begin
|
||||
(car bounds))
|
||||
(end
|
||||
(cdr bounds))
|
||||
(old-name
|
||||
(buffer-substring-no-properties begin end)))
|
||||
(message "Will rename to %s" new-name)
|
||||
(frename old-name new-name)
|
||||
(delete-region begin end)
|
||||
(insert (s-dashed-words new-name))
|
||||
(message "Renamed %s to %s." old-name new-name)))
|
||||
(message "No symbol under cursor."))))
|
||||
|
||||
Reference in New Issue
Block a user