chd/.emacs.d/usefulScripts.el

76 lines
2.3 KiB
EmacsLisp
Raw Normal View History

2020-01-04 22:53:01 +00:00
;; org-mode shit.
(defun my/org-mode-hook ()
"Stop the org-level headers from increasing in height relative to the other text."
(dolist (face '(org-level-1
org-level-2
org-level-3
org-level-4
org-level-5))
(set-face-attribute face nil :weight 'semi-bold :height 1.0)))
(add-hook 'org-mode-hook 'my/org-mode-hook)
;; makes a task show up m-f, but you can't cycle todos;
<%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>
2021-03-08 17:22:39 +00:00
;; these xah- funcs are REALLY useful during security CTFs lmfao.
;; sql shit, etc.
(defun xah-html-decode-percent-encoded-url ()
"Decode percent encoded URL of current line or selection.
Example:
%28D%C3%BCrer%29
becomes
(Dürer)
Example:
%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8
becomes
文本编辑器
URL `http://ergoemacs.org/emacs/emacs_url_percent_decode.html'
Version 2018-10-26"
(interactive)
(let ( $p1 $p2 $input-str $newStr)
(if (use-region-p)
(setq $p1 (region-beginning) $p2 (region-end))
(setq $p1 (line-beginning-position) $p2 (line-end-position)))
(setq $input-str (buffer-substring-no-properties $p1 $p2))
(require 'url-util)
(setq $newStr (url-unhex-string $input-str))
(if (string-equal $newStr $input-str)
(progn (message "no change" ))
(progn
(delete-region $p1 $p2)
(insert (decode-coding-string $newStr 'utf-8))))))
(defun xah-html-encode-percent-encoded-url ()
"Percent encode URL in current line or selection.
Example:
http://example.org/(Dürer)
becomes
http://example.org/(D%C3%BCrer)
Example:
http://example.org/文本编辑器
becomes
http://example.org/%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8
URL `http://ergoemacs.org/emacs/emacs_url_percent_decode.html'
Version 2018-10-26"
(interactive)
(let ($p1 $p2 $input-str $newStr)
(if (use-region-p)
(setq $p1 (region-beginning) $p2 (region-end))
(setq $p1 (line-beginning-position) $p2 (line-end-position)))
(setq $input-str (buffer-substring-no-properties $p1 $p2))
(require 'url-util)
(setq $newStr (url-encode-url $input-str))
(if (string-equal $newStr $input-str)
(progn (message "no change" ))
(progn
(delete-region $p1 $p2)
(insert $newStr)))))