1 (defun display-full-buffer-path ()
2 (interactive)
3 "Little helper for showing full file path in minibuffer"
4 (message (buffer-file-name)))
5
6 ;;; See great post here:
7 ;;; https://www.manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/
8 (defun mu-magit-kill-buffers ()
9 "Restore window configuration and kill all Magit buffers."
10 (interactive)
11 (let ((buffers (magit-mode-get-buffers)))
12 (magit-restore-window-configuration)
13 (mapc #'kill-buffer buffers)))
14
15 (defcustom *last-pb-url* nil
16 "Contains the URL of the last post to the pastebin."
17 :set (lambda (sym val)
18 (set-default sym val)
19 (message "Set %s to %s" sym val)))
20
21 ;; See: https://with-emacs.com/posts/tutorials/almost-all-you-need-to-know-about-variables/
22 (defmacro csetq (sym val)
23 `(funcall (or (get ',sym 'custom-set) 'set-default) ',sym ,val))
24
25 (defun post-region-to-pb ()
26 "Post buffer to http://chate.io pastebin"
27 (interactive)
28 (csetq *last-pb-url*
29 (substring
30 (with-output-to-string
31 (shell-command-on-region
32 (region-beginning)
33 (region-end)
34 "curl -s -F \"file=@-\" -H \"expire:24hours\" http://chate.io:669"
35 standard-output))
36 0 -1))
37 (message *last-pb-url*)
38 ;; There may be a more direct way to
39 ;; do this?
40 (with-temp-buffer
41 (insert *last-pb-url*)
42 (clipboard-kill-region (point-min) (point-max))))
43
44 (defun display-pb ()
45 "Display last pb url content, see *last-pb-url*"
46 (interactive)
47 (let* ((url (if *last-pb-url* *last-pb-url* (error "*last-pb-url* void")))
48 (r
49 (shell-command-to-string (format "curl -s %s" url))))
50 (switch-to-buffer
51 (get-buffer-create url))
52 (insert r)))