Skip to content

Instantly share code, notes, and snippets.

View xenodium's full-sized avatar
😸
[in Emacs]

xenodium

😸
[in Emacs]
View GitHub Profile
@xenodium
xenodium / org2md.sh
Created January 28, 2024 12:31
Converting my org blog to markdown
$ pandoc -f org -t markdown-smart --strip-comments --wrap=none --lua-filter=org.lua index.org -o output.md && sed -i '' 's/{width="[0-9]*%"}//g' output.md
org.lua:
function Header(el)
el.attr = pandoc.Attr("", {}, {})
return el
end
function CodeBlock(el)
@xenodium
xenodium / extend-elisp-demos.el
Created January 12, 2024 09:39
Add own elisp-demos snippets
(defun advised:elisp-demos--search (orig-fun symbol)
(cl-letf* ((orig-insert-file-contents (symbol-function 'insert-file-contents))
((symbol-function 'insert-file-contents)
(lambda (filename &optional visit beg end replace)
(apply orig-insert-file-contents filename visit beg end replace nil)
(apply orig-insert-file-contents "/private/tmp/mine.org" visit beg end replace nil))))
(funcall orig-fun symbol)))
(advice-add 'elisp-demos--search :around #'advised:elisp-demos--search)
@xenodium
xenodium / send-to-kindle-as-txt.el
Last active September 16, 2023 19:36
Select text in an Emacs buffer and send with M-x send-to-kindle-as-txt
(defcustom send-to-kindle-from-email
nil
"Your own email address to send from via mu4e."
:type 'string
:group 'send-to-kindle)
(defcustom send-to-kindle-to-email
nil
"Your Kindle email address to send pdf to."
:type 'string
@xenodium
xenodium / send-to-kindle-as-pdf.el
Last active September 15, 2023 06:17
Select some text and invoke via M-x send-to-kindle-as-pdf
(defcustom send-to-kindle-from-email
nil
"Your own email address to send from via mu4e."
:type 'string
:group 'send-to-kindle)
(defcustom send-to-kindle-to-email
nil
"Your Kindle email address to send pdf to."
:type 'string
@xenodium
xenodium / eval-uncommented-region.el
Last active September 27, 2023 02:38
Eval commented out code
(defun ar/eval-uncommented-region (start end)
(interactive "r")
(let ((text (buffer-substring-no-properties start end)))
(with-temp-buffer
(insert text)
(emacs-lisp-mode)
(uncomment-region (point-min) (point-max))
(eval-buffer)
(message "Evaluated"))))
@xenodium
xenodium / dwim-shell-commands.el
Created July 15, 2023 16:05
dwim-shell-commands-duplicate tramp experiment
(defun dwim-shell-commands-duplicate ()
(interactive)
(dwim-shell-command-on-marked-files
"Duplicate file(s)."
"cp '<<f>>' '<<f(u)>>'"
:utils '("cp" "scp")
:post-process-template
(lambda (script file)
(if (tramp-tramp-file-p file)
;; Tramp file path start with "/ssh:". Drop it.
@xenodium
xenodium / dwim-shell-command-loading.el
Last active September 16, 2023 19:49
Basic dwim-shell-command setup
(use-package dwim-shell-command
:ensure t
:bind (:map dired-mode-map
("C-c d" . dwim-shell-commands-duplicate))
:config
;; Loads all my own dwim shell commands.
(require 'dwim-shell-commands))
@xenodium
xenodium / mu4e-mark-junk-candidates-using-chatgp.el
Last active June 9, 2023 16:19
[Experiment] Mark mu4e messages as spam/junk using ChatGPT NOTE: sender email, name, subject, and docid sent to ChatGPT
;; Needs make-mu4e-context :vars mu4e-spam-folder set.
;; Generates `mu4e-headers-mark-for-spam'.
(mu4e~headers-defun-mark-for spam)
(defun ar/mu4e-mark-junk-candidates-using-chatgpt ()
"Mark potential messages as junk by asking ChatGPT."
(interactive)
(save-restriction
(narrow-to-region (window-start)
@xenodium
xenodium / mu4e-reply-to-spammer.el
Last active June 6, 2023 17:05
Decline sender offer from mu4e using chatgpt-shell
(defun ar/chatgpt-decline-offer-from-sender ()
(interactive)
(unless (eq major-mode 'mu4e-compose-mode)
(user-error "Not in mu4e:compose mode"))
(let ((chatgpt-shell-prompt-query-response-style 'inline))
(chatgpt-shell-send-to-buffer
(concat "write a succinct email reply body and kindly decline explictly to the following email as I am not interested: \n\n"
(buffer-substring-no-properties (point-min) (point-max))))))
@xenodium
xenodium / dwim-shell-commands.el
Last active December 3, 2022 18:02
dwim-shell-commands-video-to-hevc-mkv
(defun dwim-shell-commands-video-to-hevc-mkv ()
"Convert all marked videos to hevc mkv."
(interactive)
(dwim-shell-command-on-marked-files
"Convert video to h265 "
"REPO_DIR=/tmp/other_video_transcoding
if ! [ -d \"$REPO_DIR\" ]
then
git clone https://github.com/donmelton/other_video_transcoding.git $REPO_DIR
fi