Tidy dwpost.el, autocomplete tags from file

master
trémeur 1 year ago
parent 9814f3a36b
commit 2aa482f31e

@ -3,8 +3,11 @@
(setq dw-username "tobli") (setq dw-username "tobli")
(setq dw-pin "0397") (setq dw-pin "0397")
(setq dw-defaultlocation "🔺") (setq dw-defaultlocation "🔺")
(setq dw-tagslist "~/Documents/drive/admin/emacs/tags.txt")
(setq dw-iconfile "~/Documents/drive/admin/emacs/iconchoose.el") (setq dw-iconfile "~/Documents/drive/admin/emacs/iconchoose.el")
(setq lastfm-login t) ;; boolean (setq lastfm-login t) ;; boolean
(setq log t)
(setq logfile "~/Documents/drive/org/calendar/habit.org")
(setq lastfm-user "litrovers") (setq lastfm-user "litrovers")
;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
@ -45,16 +48,14 @@
(defun dwsecurity () (defun dwsecurity ()
"Set security level for DW post" "Set security level for DW post"
(setq security (completing-read "Security (public, access, private): " '("public" "access" "private"))) (setq security (completing-read "Security (public, access, private): " '("public" "access" "private")))
(if (equal security "") (unless (equal security "")
(sleep-for 0)
(insert (concat "post-security: " security "\n"))))) (insert (concat "post-security: " security "\n")))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
(defun dwmood () (defun dwmood ()
"Set mood for DW post" "Set mood for DW post"
(setq mood (completing-read "Mood: " '("accomplished" "aggravated" "amused" "angry" "annoyed" "anxious" "apathetic" "artistic" "awake" "bitchy" "blah" "blank" "bored" "bouncy" "busy" "calm" "cheerful" "chipper" "cold" "complacent" "confused" "contemplative" "content" "cranky" "crappy" "crazy" "creative" "crushed" "curious" "cynical" "depressed" "determined" "devious" "dirty" "disappointed" "discontent" "distressed" "ditzy" "dorky" "drained" "drunk" "ecstatic" "embarrassed" "energetic" "enraged" "enthralled" "envious" "exanimate" "excited" "exhausted" "flirty" "frustrated" "full" "geeky" "giddy" "giggly" "gloomy" "good" "grateful" "groggy" "grumpy" "guilty" "happy" "high" "hopeful" "horny" "hot" "hungry" "hyper" "impressed" "indescribable" "indifferent" "infuriated" "intimidated" "irate" "irritated" "jealous" "jubilant" "lazy" "lethargic" "listless" "lonely" "loved" "melancholy" "mellow" "mischievous" "moody" "morose" "naughty" "nauseated" "nerdy" "nervous" "nostalgic" "numb" "okay" "optimistic" "peaceful" "pensive" "pessimistic" "pissed off" "pleased" "predatory" "productive" "quixotic" "recumbent" "refreshed" "rejected" "rejuvenated" "relaxed" "relieved" "restless" "rushed" "sad" "satisfied" "scared" "shocked" "sick" "silly" "sleepy" "sore" "stressed" "surprised" "sympathetic" "thankful" "thirsty" "thoughtful" "tired" "touched" "uncomfortable" "weird" "working" "worried"))) (setq mood (completing-read "Mood: " '("accomplished" "aggravated" "amused" "angry" "annoyed" "anxious" "apathetic" "artistic" "awake" "bitchy" "blah" "blank" "bored" "bouncy" "busy" "calm" "cheerful" "chipper" "cold" "complacent" "confused" "contemplative" "content" "cranky" "crappy" "crazy" "creative" "crushed" "curious" "cynical" "depressed" "determined" "devious" "dirty" "disappointed" "discontent" "distressed" "ditzy" "dorky" "drained" "drunk" "ecstatic" "embarrassed" "energetic" "enraged" "enthralled" "envious" "exanimate" "excited" "exhausted" "flirty" "frustrated" "full" "geeky" "giddy" "giggly" "gloomy" "good" "grateful" "groggy" "grumpy" "guilty" "happy" "high" "hopeful" "horny" "hot" "hungry" "hyper" "impressed" "indescribable" "indifferent" "infuriated" "intimidated" "irate" "irritated" "jealous" "jubilant" "lazy" "lethargic" "listless" "lonely" "loved" "melancholy" "mellow" "mischievous" "moody" "morose" "naughty" "nauseated" "nerdy" "nervous" "nostalgic" "numb" "okay" "optimistic" "peaceful" "pensive" "pessimistic" "pissed off" "pleased" "predatory" "productive" "quixotic" "recumbent" "refreshed" "rejected" "rejuvenated" "relaxed" "relieved" "restless" "rushed" "sad" "satisfied" "scared" "shocked" "sick" "silly" "sleepy" "sore" "stressed" "surprised" "sympathetic" "thankful" "thirsty" "thoughtful" "tired" "touched" "uncomfortable" "weird" "working" "worried")))
(if (equal mood "") (unless (equal mood "")
(sleep-for 0)
(insert (concat "post-mood: " mood "\n"))))) (insert (concat "post-mood: " mood "\n")))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
@ -63,10 +64,7 @@
(setq music (lastfm-user-get-recent-tracks :user lastfm-user :from 1 :to 1)) (setq music (lastfm-user-get-recent-tracks :user lastfm-user :from 1 :to 1))
(setq music (replace-regexp-in-string (regexp-quote "\" \"") " " (format "%S" music) nil 'literal)) (setq music (replace-regexp-in-string (regexp-quote "\" \"") " " (format "%S" music) nil 'literal))
(sleep-for 1) (sleep-for 1)
(if (not music) (unless (not music)
(setq music "nil"))
(if (equal music "nil")
(sleep-for 0)
(insert (concat "post-music: " (insert (concat "post-music: "
(let* ((musicjunk (let* ((musicjunk
(format "%S" music)) (format "%S" music))
@ -84,27 +82,33 @@
(sleep-for 0) (sleep-for 0)
(insert (concat "post-icon: "icon "\n"))))) (insert (concat "post-icon: "icon "\n")))))
(unless (string-equal system-type "android")
(defun dwtags ()
"Set tags for DW post"
(setq basetags (s-split "\n" (f-read dw-tagslist) t))
(setq tagslist (completing-read-multiple "Tags: " basetags))
(setq tags (s-join "," tagslist))
(insert (concat "post-tags: org-export," tags "\n"))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
(defun dwlocation () (defun dwlocation ()
"Set location for DW post" "Set location for DW post"
(setq location (read-string "Location: " dw-defaultlocation)) (setq location (read-string "Location: " dw-defaultlocation))
(if (equal location "") (unless (equal location "")
(sleep-for 0)
(insert (concat "post-location: " location "\n"))))) (insert (concat "post-location: " location "\n")))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
(defun dwmusic-manual () (defun dwmusic-manual ()
"Set current music for DW post if lastfm.el not set up" "Set current music for DW post if lastfm.el not set up"
(setq music (read-string "Music: ")) (setq music (read-string "Music: "))
(if (equal music "") (unless (equal music "")
(sleep-for 0)
(insert (concat "post-music: " music "\n"))))) (insert (concat "post-music: " music "\n")))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
(defun dw-posted () (defun dw-posted ()
"Log DW post" "Log DW post"
(find-file-noselect "~/Documents/drive/org/calendar/habit.org") (find-file-noselect logfile)
(with-current-buffer "habit.org" (with-current-buffer (file-name-nondirectory logfile)
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "RECUR dw posts") (re-search-forward "RECUR dw posts")
(org-shiftright) (org-shiftright)
@ -112,14 +116,14 @@
(save-buffer)))) (save-buffer))))
(unless (string-equal system-type "android") (unless (string-equal system-type "android")
(defun dwpost (psubject tags) (defun dwpost ()
"Post to DW" "Post to DW"
(interactive (list (read-string "Post title (REQUIRED): ") (interactive)
(read-string "Tags (comma-separated): "))) (setq psubject (read-string "Post title (REQUIRED): "))
(dwexport) (dwexport)
(compose-mail (concat dw-username "+" dw-pin "@post.dreamwidth.org") psubject) (compose-mail (concat dw-username "+" dw-pin "@post.dreamwidth.org") psubject)
(with-current-buffer (concat "*unsent mail to " dw-username "*") (with-current-buffer (concat "*unsent mail to " dw-username "*")
(insert (concat "post-tags: org-export, " tags "\n")) (dwtags)
(dwsecurity) (dwsecurity)
(dwlocation) (dwlocation)
(dwicon newname) (dwicon newname)
@ -134,4 +138,5 @@
(kill-buffer (concat "*sent mail to " dw-username "*")) (kill-buffer (concat "*sent mail to " dw-username "*"))
(with-current-buffer oldname (with-current-buffer oldname
(delete-file newname)) (delete-file newname))
(dw-posted))) (cond
(log t (dw-posted)))))

@ -0,0 +1,5 @@
# name: star
# key: star
# binding: C-c s
# --
Loading…
Cancel
Save