General cleanup: reorganising snippets, tidying if statements, documenting functions
This commit is contained in:
parent
18c64c71c4
commit
4aa4de17f5
30 changed files with 128 additions and 99 deletions
|
@ -3,13 +3,14 @@
|
|||
(setq dw-username "tobli")
|
||||
(setq dw-pin "0397")
|
||||
(setq dw-defaultlocation "🔺")
|
||||
(setq dw-iconfile "~/Documents/drive/org/iconchoose.el")
|
||||
(setq dw-iconfile "~/Documents/drive/admin/emacs/iconchoose.el")
|
||||
(setq lastfm-login t) ;; boolean
|
||||
(setq lastfm-user "litrovers")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun dwexport ()
|
||||
"Export HTML for DW posting"
|
||||
(let ((org-export-with-author 'nil)
|
||||
(org-export-with-creator 'nil)
|
||||
(org-export-with-date 'nil)
|
||||
|
@ -31,6 +32,7 @@
|
|||
(write-file newname)))
|
||||
|
||||
(defun dwdraft ()
|
||||
"Export HTML for DW posting and copy it to the clipboard"
|
||||
(interactive)
|
||||
(dwexport)
|
||||
(with-current-buffer newname
|
||||
|
@ -40,6 +42,7 @@
|
|||
(delete-file newname)))
|
||||
|
||||
(defun dwsecurity ()
|
||||
"Set security level for DW post"
|
||||
(setq security (completing-read-multiple "Security (public, access, private): " '("public" "access" "private")))
|
||||
(if (not security)
|
||||
(setq security "skip"))
|
||||
|
@ -52,6 +55,7 @@
|
|||
(substring securityjunk 2 end))"\n"))))
|
||||
|
||||
(defun dwmood ()
|
||||
"Set mood for DW post"
|
||||
(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 "skip"))
|
||||
|
@ -64,6 +68,7 @@
|
|||
(substring moodjunk 2 end))"\n"))))
|
||||
|
||||
(defun dwmusic ()
|
||||
"Set current music for DW post"
|
||||
(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))
|
||||
(sleep-for 1)
|
||||
|
@ -78,6 +83,7 @@
|
|||
(substring musicjunk 4 end))"\n"))))
|
||||
|
||||
(defun dwicon (thefile)
|
||||
"Set icon for DW post"
|
||||
(setq icon "skip")
|
||||
(load-file dw-iconfile)
|
||||
(with-current-buffer thefile
|
||||
|
@ -87,26 +93,31 @@
|
|||
(insert (concat "post-icon: "icon "\n"))))
|
||||
|
||||
(defun dwlocation ()
|
||||
"Set location for DW post"
|
||||
(setq location (read-string "Location: " dw-defaultlocation))
|
||||
(if (equal location "")
|
||||
(sleep-for 0)
|
||||
(insert (concat "post-location: " location "\n"))))
|
||||
|
||||
(defun dwmusic-manual ()
|
||||
"Set current music for DW post if lastfm.el not set up"
|
||||
(setq music (read-string "Music: "))
|
||||
(if (equal music "")
|
||||
(sleep-for 0)
|
||||
(insert (concat "post-music: " music "\n"))))
|
||||
|
||||
(defun dw-posted ()
|
||||
"Log DW post"
|
||||
(find-file-noselect "~/Documents/drive/org/calendar/habit.org")
|
||||
(with-current-buffer "habit.org"
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "RECUR dw posts")
|
||||
(org-shiftright)
|
||||
(sleep-for 1)
|
||||
(save-buffer)))
|
||||
|
||||
(defun dwpost (psubject tags)
|
||||
"Post to DW"
|
||||
(interactive (list (read-string "Post title (REQUIRED): ")
|
||||
(read-string "Tags (comma-separated): ")))
|
||||
(dwexport)
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
(defun dwuser ()
|
||||
"Insert HTML link to a DW personal account"
|
||||
(interactive)
|
||||
(setq theuser (read-string "DW username: "))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://" theuser ".dreamwidth.org/profile\"><img src=\"https://www.dreamwidth.org/img/silk/identity/user.png\" alt=\"[personal profile]\" width=\"17\" height=\"17\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://" theuser ".dreamwidth.org/\"><b>" theuser "</b></a></span>")))
|
||||
(setq ao3 (y-or-n-p "For AO3?"))
|
||||
(if ao3
|
||||
(insert (concat "<a href=\"https://" theuser ".dreamwidth.org/profile\" rel=\"nofollow\"><img src=\"https://www.dreamwidth.org/img/silk/identity/user.png\" width=\"17\" height=\"17\" /></a><b><a href=\"https://" theuser ".dreamwidth.org\" rel=\"nofollow\">" theuser "</a></b>"))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://" theuser ".dreamwidth.org/profile\"><img src=\"https://www.dreamwidth.org/img/silk/identity/user.png\" alt=\"[personal profile]\" width=\"17\" height=\"17\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://" theuser ".dreamwidth.org/\"><b>" theuser "</b></a></span>"))))
|
||||
|
||||
(defun dwcomm ()
|
||||
"Insert HTML link to a DW community"
|
||||
(interactive)
|
||||
(setq theuser (read-string "DW comm name: "))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://" theuser ".dreamwidth.org/profile\"><img src=\"https://www.dreamwidth.org/img/silk/identity/community.png\" alt=\"[community profile]\" width=\"17\" height=\"17\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://" theuser ".dreamwidth.org/\"><b>" theuser "</b></a></span>")))
|
||||
(setq ao3 (y-or-n-p "For AO3?"))
|
||||
(if ao3
|
||||
(insert (concat "<a href=\"https://" theuser ".dreamwidth.org/profile\" rel=\"nofollow\"><img src=\"https://www.dreamwidth.org/img/silk/identity/community.png\" width=\"17\" height=\"17\" /></a><b><a href=\"https://" theuser ".dreamwidth.org\" rel=\"nofollow\">" theuser "</a></b>"))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://" theuser ".dreamwidth.org/profile\"><img src=\"https://www.dreamwidth.org/img/silk/identity/community.png\" alt=\"[community profile]\" width=\"17\" height=\"17\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://" theuser ".dreamwidth.org/\"><b>" theuser "</b></a></span>"))))
|
||||
|
||||
(defun ao3user ()
|
||||
"Insert HTML link to an AO3 user"
|
||||
(interactive)
|
||||
(setq theuser (read-string "AO3 username: "))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://archiveofourown.org/users/" theuser "/profile\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" alt=\"[archiveofourown.org profile]\" width=\"16\" height=\"16\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://archiveofourown.org/users/" theuser "\"><b>" theuser "</b></a></span>")))
|
||||
|
||||
(defun ao3safe-dwuser ()
|
||||
(interactive)
|
||||
(setq theuser (read-string "DW username: "))
|
||||
(insert (concat "<a href=\"https://" theuser ".dreamwidth.org/profile\" rel=\"nofollow\"><img src=\"https://www.dreamwidth.org/img/silk/identity/user.png\" width=\"17\" height=\"17\" /></a><b><a href=\"https://" theuser ".dreamwidth.org\" rel=\"nofollow\">" theuser "</a></b>")))
|
||||
|
||||
(defun ao3safe-dwcomm ()
|
||||
(interactive)
|
||||
(setq theuser (read-string "DW comm name: "))
|
||||
(insert (concat "<a href=\"https://" theuser ".dreamwidth.org/profile\" rel=\"nofollow\"><img src=\"https://www.dreamwidth.org/img/silk/identity/community.png\" width=\"17\" height=\"17\" /></a><b><a href=\"https://" theuser ".dreamwidth.org\" rel=\"nofollow\">" theuser "</a></b>")))
|
||||
|
||||
(defun ao3safe-ao3user ()
|
||||
(interactive)
|
||||
(setq theuser (read-string "AO3 username: "))
|
||||
(insert (concat "<a href=\"https://archiveofourown.org/users/" theuser "/profile\" rel=\"nofollow\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" width=\"16\" height=\"16\" /></a><b><a href=\"https://archiveofourown.org/users/" theuser "\" rel=\"nofollow\">" theuser "</a></b>")))
|
||||
(setq ao3 (y-or-n-p "For AO3?"))
|
||||
(if ao3
|
||||
(insert (concat "<a href=\"https://archiveofourown.org/users/" theuser "/profile\" rel=\"nofollow\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" width=\"16\" height=\"16\" /></a><b><a href=\"https://archiveofourown.org/users/" theuser "\" rel=\"nofollow\">" theuser "</a></b>"))
|
||||
(insert (concat "<span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://archiveofourown.org/users/" theuser "/profile\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" alt=\"[archiveofourown.org profile]\" width=\"16\" height=\"16\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://archiveofourown.org/users/" theuser "\"><b>" theuser "</b></a></span>"))))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(defun fic-ao3 ()
|
||||
"Format fic for posting to AO3 and export it"
|
||||
(interactive)
|
||||
(org-format)
|
||||
(save-buffer)
|
||||
|
@ -44,6 +45,7 @@
|
|||
(delete-file newname)))
|
||||
|
||||
(defun fic-export ()
|
||||
"Export fic to HTML, EPUB, PDF"
|
||||
(interactive)
|
||||
(shell-command "cp ~/.emacs.d/fic-export-files/FFXYevon.ttf .")
|
||||
(setq asal (y-or-n-p "ASAL?"))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(defun red ()
|
||||
"Set exported HTML file to red"
|
||||
(interactive)
|
||||
(setq oldname (concat (file-name-base) ".org"))
|
||||
(setq newname (concat (file-name-base) ".html"))
|
||||
|
@ -9,6 +10,7 @@
|
|||
(write-file newname)))
|
||||
|
||||
(defun blue ()
|
||||
"Set exported HTML file to blue"
|
||||
(interactive)
|
||||
(setq oldname (concat (file-name-base) ".org"))
|
||||
(setq newname (concat (file-name-base) ".html"))
|
||||
|
@ -19,6 +21,7 @@
|
|||
(write-file newname)))
|
||||
|
||||
(defun green ()
|
||||
"Set exported HTML file to green"
|
||||
(interactive)
|
||||
(setq oldname (concat (file-name-base) ".org"))
|
||||
(setq newname (concat (file-name-base) ".html"))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(defun org-format ()
|
||||
"Correct formatting in an org file"
|
||||
(interactive)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward " -" nil t)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(defun periodise ()
|
||||
(setq periodfile "~/Documents/drive/org/period.org")
|
||||
"Return day of menstrual cycle"
|
||||
(setq periodfile "~/Documents/drive/admin/emacs/period.org")
|
||||
(find-file-noselect periodfile)
|
||||
(setq thebuffer (file-name-nondirectory periodfile))
|
||||
(with-current-buffer thebuffer
|
||||
|
@ -17,8 +18,9 @@
|
|||
(insert (concat "Day " (format "%S" days))))
|
||||
|
||||
(defun menstruate ()
|
||||
"Mark beginning of menstrual cycle"
|
||||
(interactive)
|
||||
(setq periodfile "~/Documents/drive/org/period.org")
|
||||
(setq periodfile "~/Documents/drive/admin/emacs/period.org")
|
||||
(find-file-noselect periodfile)
|
||||
(setq thebuffer (file-name-nondirectory periodfile))
|
||||
(with-current-buffer thebuffer
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(setq daysoff '("2022-12-23" "2022-12-24" "2022-12-25" "2022-12-26" "2022-12-27" "2022-12-28" "2022-12-29" "2022-12-30" "2022-12-31" "2023-01-01" "2023-01-02" "2023-01-03" "2023-03-17" "2023-04-07" "2023-04-14" "2023-05-01" "2023-05-08" "2023-07-12" "2023-07-13" "2023-12-22" "2023-12-23" "2023-12-24" "2023-12-25" "2023-12-26" "2023-12-27" "2023-12-28" "2023-12-29" "2023-12-30" "2023-12-31" "2023-01-01" "2023-01-02" "2024-03-18" "2024-03-29" "2024-03-30" "2024-03-31" "2024-04-01" "2024-04-02" "2024-04-03" "2024-04-04" "2024-04-05" "2024-05-06" "2024-07-12" "2024-07-15" "2024-12-23" "2024-12-24" "2024-12-25" "2024-12-26" "2024-12-27" "2024-12-28" "2024-12-29" "2024-12-30" "2024-12-31" "2025-01-01")) ;; to update in 2025
|
||||
(load-file "~/Documents/drive/admin/emacs/daysoff.el")
|
||||
(if (equal (format-time-string "%a") "Sat")
|
||||
(setq workday nil)
|
||||
(if (equal (format-time-string "%a") "Sun")
|
||||
|
@ -6,7 +6,3 @@
|
|||
(if (member (format-time-string "%Y-%m-%d") daysoff)
|
||||
(setq workday nil)
|
||||
(setq workday t))))
|
||||
|
||||
(defun isworkday ()
|
||||
(eq workday t))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue