(defun display-full-buffer-path () (interactive) "Little helper for showing full file path in minibuffer" (message (buffer-file-name))) ;;; See great post here: ;;; https://www.manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/ (defun mu-magit-kill-buffers () "Restore window configuration and kill all Magit buffers." (interactive) (let ((buffers (magit-mode-get-buffers))) (magit-restore-window-configuration) (mapc #'kill-buffer buffers))) (defcustom *last-pb-url* nil "Contains the URL of the last post to the pastebin." :set (lambda (sym val) (set-default sym val) (message "Set %s to %s" sym val))) ;; See: https://with-emacs.com/posts/tutorials/almost-all-you-need-to-know-about-variables/ (defmacro csetq (sym val) `(funcall (or (get ',sym 'custom-set) 'set-default) ',sym ,val)) (defun post-region-to-pb () "Post buffer to http://chate.io pastebin" (interactive) (csetq *last-pb-url* (substring (with-output-to-string (shell-command-on-region (region-beginning) (region-end) "curl -s -F \"file=@-\" -H \"expire:24hours\" http://chate.io:669" standard-output)) 0 -1)) (message *last-pb-url*) ;; There may be a more direct way to ;; do this? (with-temp-buffer (insert *last-pb-url*) (clipboard-kill-region (point-min) (point-max)))) (defun display-pb () "Display last pb url content, see *last-pb-url*" (interactive) (let* ((url (if *last-pb-url* *last-pb-url* (error "*last-pb-url* void"))) (r (shell-command-to-string (format "curl -s %s" url)))) (switch-to-buffer (get-buffer-create url)) (insert r)))