function to strip path
This commit is contained in:
@@ -213,9 +213,28 @@
|
||||
(after! (magit)
|
||||
(remove-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
|
||||
|
||||
;; HACK show small snippets for backlinks preview in roam-buffer
|
||||
;; there is currently a problem in org-mode that shows an error
|
||||
;; org-element--cache: Unregistered buffer modifications detected. Resetting.
|
||||
;; but this also happens without this function, it appears to be an interaction between org-roam and changes in orgmode.
|
||||
(defun qwan/brief-preview ()
|
||||
(let* ((elem (org-element-context))
|
||||
(parent (org-element-property :parent elem)))
|
||||
;; TODO: alt handling for non-paragraph elements
|
||||
(string-trim-right (buffer-substring-no-properties
|
||||
(org-element-property :begin parent)
|
||||
(org-element-property :end parent)))))
|
||||
|
||||
(setq org-roam-preview-function #'qwan/brief-preview)
|
||||
|
||||
;; cursor moved back to ?beginning of line? too often
|
||||
(setq evil-move-cursor-back nil)
|
||||
|
||||
|
||||
;; to enable multiple org-roam dirs
|
||||
;; https://github.com/org-roam/org-roam/issues/1527
|
||||
(setq-default enable-local-variables t)
|
||||
|
||||
;; two functions from:
|
||||
;; https://zzamboni.org/post/my-emacs-configuration-with-commentary/#reformatting-an-org-buffer
|
||||
(defun zz/org-reformat-buffer ()
|
||||
@@ -272,3 +291,30 @@ 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/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: "
|
||||
(interactive)
|
||||
(image-mode-copy-file-name-as-kill))
|
||||
|
||||
|
||||
(defun qwan/relative-path-to-attachments (full-path)
|
||||
(substring full-path (string-search "/attachments" full-path 0) ))
|
||||
|
||||
(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 "relative.*")
|
||||
|
||||
(let ((full-path-in
|
||||
"/Users/willem/MyDocuments/qwan/sites/qwaneu.github.io/attachments/blogposts/2023/time-for-improvement-game-changer.svg"
|
||||
)))
|
||||
|
||||
Reference in New Issue
Block a user