From e56299d08c40e5e6aaaef9b25d6a8ba8db9b7dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sat, 30 Apr 2022 18:54:07 +0100 Subject: [PATCH] Update dwpost --- custom/dwpost.el | 158 +++++++++------------------------------ snippets/org-mode/player | 6 ++ 2 files changed, 42 insertions(+), 122 deletions(-) create mode 100644 snippets/org-mode/player diff --git a/custom/dwpost.el b/custom/dwpost.el index 9470c03..da855a8 100644 --- a/custom/dwpost.el +++ b/custom/dwpost.el @@ -1,5 +1,4 @@ -(defun dwdraft () - (interactive) +(defun dwexport () (let ((org-export-with-author 'nil) (org-export-with-creator 'nil) (org-export-with-date 'nil) @@ -18,137 +17,52 @@ (delete-region (line-beginning-position) (line-end-position)) (goto-line 3) (delete-region (line-beginning-position) (line-end-position)) - (write-file newname) - (kill-ring-save (point-min) (point-max))) - (kill-buffer newname) - (with-current-buffer oldname - (delete-file newname))) + (write-file newname))) -(defun dwpost (psubject tags icon) - (interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") - (let ((org-export-with-author 'nil) - (org-export-with-creator 'nil) - (org-export-with-date 'nil) - (org-export-with-section-numbers 'nil) - (org-export-time-stamp-file 'nil) - (org-export-with-toc 'nil) - (org-html-validation-link 'nil)) - (org-html-export-to-html)) - (defvar oldname (concat (file-name-base) ".org")) - (defvar newname (concat (file-name-base) ".html")) - (find-file-noselect newname) - (with-current-buffer newname - (goto-line 1) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 2) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 3) - (delete-region (line-beginning-position) (line-end-position)) - (write-file newname)) - (kill-buffer newname) - (compose-mail "tobli+0397@post.dreamwidth.org" psubject) - (with-current-buffer "*unsent mail to tobli*" - (insert (concat "post-tags: org-export, "tags "\n\n")) - (insert (concat "post-icon: "icon "\n\n")) - (insert-file-contents newname) - (message-send-and-exit)) - (kill-buffer "*sent mail to tobli*") - (with-current-buffer oldname - (delete-file newname))) - -(defun dwpost-public (psubject tags icon) - (interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") - (let ((org-export-with-author 'nil) - (org-export-with-creator 'nil) - (org-export-with-date 'nil) - (org-export-with-section-numbers 'nil) - (org-export-time-stamp-file 'nil) - (org-export-with-toc 'nil) - (org-html-validation-link 'nil)) - (org-html-export-to-html)) - (defvar oldname (concat (file-name-base) ".org")) - (defvar newname (concat (file-name-base) ".html")) - (find-file-noselect newname) - (with-current-buffer newname - (goto-line 1) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 2) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 3) - (delete-region (line-beginning-position) (line-end-position)) - (write-file newname)) - (kill-buffer newname) - (compose-mail "tobli+0397@post.dreamwidth.org" psubject) - (with-current-buffer "*unsent mail to tobli*" - (insert "post-security: public\n") - (insert (concat "post-tags: org-export, "tags "\n\n")) - (insert (concat "post-icon: "icon "\n\n")) - (insert-file-contents newname) - (message-send-and-exit)) - (kill-buffer "*sent mail to tobli*") - (with-current-buffer oldname - (delete-file newname))) - -(defun dwpost-access (psubject tags icon) - (interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") - (let ((org-export-with-author 'nil) - (org-export-with-creator 'nil) - (org-export-with-date 'nil) - (org-export-with-section-numbers 'nil) - (org-export-time-stamp-file 'nil) - (org-export-with-toc 'nil) - (org-html-validation-link 'nil)) - (org-html-export-to-html)) - (defvar oldname (concat (file-name-base) ".org")) - (defvar newname (concat (file-name-base) ".html")) - (find-file-noselect newname) +(defun dwdraft () + (interactive) + (dwexport) (with-current-buffer newname - (goto-line 1) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 2) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 3) - (delete-region (line-beginning-position) (line-end-position)) - (write-file newname)) + (kill-ring-save (point-min) (point-max))) (kill-buffer newname) - (compose-mail "tobli+0397@post.dreamwidth.org" psubject) - (with-current-buffer "*unsent mail to tobli*" - (insert "post-security: access\n") - (insert (concat "post-tags: org-export, "tags "\n\n")) - (insert (concat "post-icon: "icon "\n\n")) - (insert-file-contents newname) - (message-send-and-exit)) - (kill-buffer "*sent mail to tobli*") (with-current-buffer oldname (delete-file newname))) -(defun dwpost-me (psubject tags icon) - (interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") - (let ((org-export-with-author 'nil) - (org-export-with-creator 'nil) - (org-export-with-date 'nil) - (org-export-with-section-numbers 'nil) - (org-export-time-stamp-file 'nil) - (org-export-with-toc 'nil) - (org-html-validation-link 'nil)) - (org-html-export-to-html)) - (defvar oldname (concat (file-name-base) ".org")) - (defvar newname (concat (file-name-base) ".html")) - (find-file-noselect newname) - (with-current-buffer newname - (goto-line 1) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 2) - (delete-region (line-beginning-position) (line-end-position)) - (goto-line 3) - (delete-region (line-beginning-position) (line-end-position)) - (write-file newname)) +(defun dwpost (psubject tags icon location) + (interactive (list (read-string "Post title (REQUIRED): ") + (read-string "Tags (comma-separated): ") + (read-string "Icon: ") + (read-string "Location: " "🏠"))) + (setq security (completing-read-multiple "Security (public, access, private): " '("public" "access" "private"))) + (if (not security) + (setq security "xpublicx")) + (setq mood (completing-read-multiple "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 (not mood) + (setq mood "xnonex")) + (dwexport) (kill-buffer newname) (compose-mail "tobli+0397@post.dreamwidth.org" psubject) (with-current-buffer "*unsent mail to tobli*" - (insert "post-security: private\n") (insert (concat "post-tags: org-export, "tags "\n\n")) + (insert (concat "post-security: " + (let* ((stringjunk + (format "%S" security)) + (end (- (length stringjunk) 2))) + (substring stringjunk 2 end))"\n\n")) (insert (concat "post-icon: "icon "\n\n")) + (insert (concat "post-mood: " + (let* ((moodjunk + (format "%S" mood)) + (end (- (length moodjunk) 2))) + (substring moodjunk 2 end))"\n\n")) + (insert (concat "post-location: "location "\n\n")) + (setq music (lastfm-user-get-recent-tracks :user "litrovers" :from 1 :to 1)) + (setq music (replace-regexp-in-string (regexp-quote "\" \"") " – " (format "%S" music) nil 'literal)) + (insert (concat "post-music: " + (let* ((musicjunk + (format "%S" music)) + (end (- (length musicjunk) 4))) + (substring musicjunk 4 end))"\n\n")) (insert-file-contents newname) (message-send-and-exit)) (kill-buffer "*sent mail to tobli*") diff --git a/snippets/org-mode/player b/snippets/org-mode/player new file mode 100644 index 0000000..eacdd92 --- /dev/null +++ b/snippets/org-mode/player @@ -0,0 +1,6 @@ +# name: audio-player +# key: player +# -- +#+HTML: + +$0 \ No newline at end of file