Skip to content

Commit

Permalink
fix #146 (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Rajput
  • Loading branch information
jayrajput authored Mar 30, 2024
1 parent b90277b commit 10ed2a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
22 changes: 20 additions & 2 deletions ekg-denote-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,26 @@
:kws '("portfolio" "tag2"))))
(should (equal denote (ekg-denote-create note))))

; text is copied as it is
; title is truncated, copied and sluggified
;; scalar title values shall work
(let* ((time (time-convert (current-time) 'integer))
(denote-directory "/tmp")
(denote-id (format-time-string denote-id-format time))
(ekg-default-capture-mode 'org-mode)
(note (make-ekg-note :id "ID1"
:creation-time time
:text "Text"
:properties `(:titled/title "MyTitle")
:tags '("date/20230101" "portfolio")))
(denote (make-ekg-denote :id denote-id
:note-id "ID1"
:title "mytitle"
:text "Text"
:path (format "/tmp/%s--mytitle__portfolio.org" denote-id )
:kws '("portfolio"))))
(should (equal denote (ekg-denote-create note))))

;; text is copied as it is
;; title is truncated, copied and sluggified
(let* ((time (time-convert (current-time) 'integer))
(denote-directory "/tmp")
(denote-id (format-time-string denote-id-format time))
Expand Down
7 changes: 5 additions & 2 deletions ekg-denote.el
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ length of combined KWS is not more than the given COMBINED-LENGTH."
(not (string-prefix-p "date/" tag))) (ekg-note-tags note)))
(kws (ekg-denote-sublist-keywords
(denote-sluggify-keywords tags) ekg-denote-export-combined-keywords-len))
(ekg-title (or (car (plist-get (ekg-note-properties note) :titled/title)) ""))
(ekg-title (plist-get (ekg-note-properties note) :titled/title))
(ekg-title (if (listp ekg-title) (car ekg-title) ekg-title))
(ekg-title (or ekg-title ""))
(title (string-limit (denote-sluggify ekg-title) ekg-denote-export-title-max-len))
(signature-slug "")
(path (denote-format-file-name (file-name-as-directory denote-directory) id kws title ext signature-slug)))
Expand Down Expand Up @@ -173,7 +175,7 @@ Optionally add front-matter."
(ekg-note-creation-time note)
(ekg-note-tags note)
(plist-get (ekg-note-properties note) :titled/title)
(truncate-string-to-width (ekg-note-text note) 100 nil nil "...")))
(truncate-string-to-width (or (ekg-note-text note) "") 100 nil nil "...")))

(defun ekg-denote-assert-notes-have-creation-time (notes)
"Raise error if NOTES are missing creation-time.
Expand Down Expand Up @@ -209,6 +211,7 @@ Denote uses creation-time as ID and assume it to be unique."
(ekg-denote--backup denote))
(ekg-denote--rename-if-path-changed denote)
(ekg-denote--text-save denote)))
(message "ekg-denote-export: completed.")
(ekg-denote-set-last-export start-time)))

(provide 'ekg-denote)
Expand Down

0 comments on commit 10ed2a6

Please sign in to comment.