.emacs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. (custom-set-variables
  2. ;; It is licensed under the GNU General Public License version 3 (or any later version).
  3. ;; You should have recieved a version of the GPL version 3 with this file (see COPYING.GPL),
  4. ;; if not see the FSF's website: https://www.gnu.org/licenses/gpl-3.0.en.html
  5. ;; custom-set-variables was added by Custom.
  6. ;; If you edit it by hand, you could mess it up, so be careful.
  7. ;; Your init file should contain only one such instance.
  8. ;; If there is more than one, they won't work right.
  9. '(ansi-color-faces-vector
  10. [default default default italic underline success warning error])
  11. '(ansi-color-names-vector
  12. ["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
  13. '(blink-cursor-mode nil)
  14. '(custom-enabled-themes '(whiteboard))
  15. '(custom-safe-themes
  16. '("1a094b79734450a146b0c43afb6c669045d7a8a5c28bc0210aba28d36f85d86f" "da8e6e5b286cbcec4a1a99f273a466de34763eefd0e84a41c71543b16cd2efac" "77515a438dc348e9d32310c070bfdddc5605efc83671a159b223e89044e4c4f1" "a455366c5cdacebd8adaa99d50e37430b0170326e7640a688e9d9ad406e2edfd" default))
  17. '(indent-line-function 'insert-tab t)
  18. '(indent-tabs-mode nil)
  19. '(iread-chars 20)
  20. '(iread-delay-milliseconds 400)
  21. '(iread-delay-seconds 0)
  22. '(iread-screenlength 100)
  23. '(ispell-dictionary nil)
  24. '(line-move-visual nil)
  25. '(max-lisp-eval-depth (expt 2 10))
  26. '(max-specpdl-size 34294)
  27. '(package-selected-packages
  28. '(tabbar session pod-mode muttrc-mode mutt-alias markdown-mode initsplit htmlize graphviz-dot-mode folding ess eproject elpher diminish csv-mode company color-theme-modern cmake-mode browse-kill-ring boxquote bm bar-cursor apache-mode))
  29. '(python-shell-interpreter "python3")
  30. '(send-mail-function 'sendmail-send-it)
  31. '(shell-command-default-error-buffer 'stderror-buffer t)
  32. '(tab-width 5)
  33. '(tool-bar-mode nil)
  34. '(undo-outer-limit (expt 2 24))
  35. '(visible-bell t)
  36. )
  37. (electric-indent-mode 0)
  38. ;; I basically never want to hit this key
  39. (global-set-key (kbd "<insert>") 'nil)
  40. (custom-set-faces
  41. ;; custom-set-faces was added by Custom.
  42. ;; If you edit it by hand, you could mess it up, so be careful.
  43. ;; Your init file should contain only one such instance.
  44. ;; If there is more than one, they won't work right.
  45. )
  46. (if (display-graphic-p)
  47. (setq initial-frame-alist
  48. '(
  49. (tool-bar-lines . 0)
  50. (width . 106)
  51. (height . 60)
  52. (background-color . "black")
  53. (foreground-color . "orange")
  54. (left . 50)
  55. (top . 50)))
  56. (setq initial-frame-alist '( (tool-bar-lines . 0))))
  57. (setq default-frame-alist initial-frame-alist)
  58. (put 'scroll-left 'disabled nil)
  59. (defun twitterablep () "is region twitterable? #elisp" (interactive) (message (if (> 140 (abs (- (point) (mark)))) "yes" "no")))
  60. (defun nullp (l)
  61. "is this null?"
  62. (equal '() l))
  63. (defun reduce (p l)
  64. "reduce function?"
  65. (if
  66. (nullp l)
  67. l
  68. (if (listp l)
  69. (if (= (length l) 1)
  70. l
  71. (if (= (length l) 2)
  72. (funcall p (car l) (car (cdr l)))
  73. (reduce p
  74. (cons
  75. (funcall p (car l)
  76. (car (cdr l)))
  77. (cdr
  78. (cdr l))))))
  79. l)
  80. ))
  81. (defun map (f l)
  82. "map function?"
  83. (if
  84. (nullp l)
  85. '()
  86. (if (listp l)
  87. (if (= 1 (length l))
  88. (list (funcall f (car l)))
  89. (if (> (length l) 1)
  90. (cons (map f (car l))
  91. (map f (cdr l)))))
  92. (funcall f l)
  93. )))
  94. (require 'dired-x)
  95. ; broken? (require ’ess-r-mode)
  96. ; (setq web-browser "/home/themusicgod1/palemooon/Pale-Moon-27.3.0_Release/obj-x86_64-unknown-linux-gnu/dist/bin/palemoon");
  97. (setq web-browser "/home/themusicgod1/tor-browser/tor-browser_en-US/Browser/runtorbrowser.sh")
  98. ; (setq web-browser "chromium-browser")
  99. (fset 'traverse-hyperlink-line
  100. (format "(shell-command \"%s '\C-e' & sleep 0.6; \")\C-x\C-e\C-f\C-p\C-k\C-d" web-browser))
  101. (fset 'unsqlize-delete
  102. "\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-d\C-s\"\C-b\C-k\C-f")
  103. (fset 'url-macro-1 "\C-d\C-d\C-d\C-n\C-d")
  104. (fset 'run-delete-sqls-in-ansi-term
  105. [C-S-down S-up (menu-bar) edit copy ?\C-x ?\C-f return ?\C-s ?T ?D ?L ?\C-m return ?\M-x ?a ?n ?s ?i ?- ?t ?e ?r ?m return return ?s ?q ?l ?i ?t ?e ?3 ? ?u ?r ?l ?s ?. ?d ?b return S-insert ?e ?x ?i ?t return ?\; return ?. ?e ?x ?i ?t return ?e ?x ?i ?t return ?\C-x ?k return ?\C-x ?k return ?\C-x ?k return C-up C-down])
  106. (fset 'twitter-macro-1
  107. [?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?f backspace ?\C-f ?a ?g ?a ?i ?n ? ?\C-e ?\C-f])
  108. (fset 'tweet
  109. [?\C-k ?\M-x ?u backspace ?u backspace ?b ?u ?f ?f ?e ?r ?- ?m ?e ?n ?u return ?\C-s ?t ?w ?i ?t ?t ?e ?r ?\C-m return S-insert return ?\C-x left ?\M-x ?b ?u ?f ?f ?e ?r ?- ?m ?e ?n ?u return ?\C-n return ?\C-d])
  110. (defun dec2hex (dec) "decimal to hex" (interactive dec2hex) (message "%x" dec))
  111. (defun hex2dec (hex) "hex to decimal" (interactive hex2dec) (message "%d" hex))
  112. (defun hex2dec1 (hex) "hex to decimal" (interactive hex2dec) (message "%d" (message "#x%x" hex)))
  113. ;; https://github.com/bard/mozrepl/wiki/Emacs-integration
  114. (add-to-list 'load-path "/home/themusicgod1/emacs")
  115. (autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
  116. (add-hook 'javascript-mode-hook 'javascript-custom-setup)
  117. (defun javascript-custom-setup ()
  118. (moz-minor-mode 1))
  119. ;; https://github.com/RenWenshan/emacs-moz-controller
  120. (add-to-list 'load-path "/home/themusicgod1/emacs/emacs-moz-controller")
  121. (require 'moz-controller)
  122. (fset 'firefox-macro-1
  123. "\C-cml\C-y")
  124. (fset 'moz-macro-2
  125. [?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?u ?p return C-end return ?g ?B ?r ?o ?w ?s ?e ?r ?. ?g ?e ?t ?B ?r ?o ?w ?s ?e ?r ?F ?o ?r ?T ?a ?b ?\( ?g ?B ?r ?o ?w ?s ?e ?r ?. ?s ?e ?l ?e ?c ?t ?e ?d ?T ?a ?b ?\) ?. ?c ?u ?r ?r ?e ?n ?t ?U ?R ?I ?. ?s ?p ?e ?c return ?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?d ?o ?w ?n return])
  126. (fset 'moz-macro-3
  127. [?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?u ?p return ?\C-p home ?\C-k ?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?d ?o ?w ?n return ?\C-y return ?\C-p ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-d ?\C-s ?\' backspace ?\" ?\C-b ?\C-d ?\C-f])
  128. (fset 'moz-close-tab
  129. [?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?u ?p return ?g ?B ?r ?o ?w ?s ?e ?r ?. ?r ?e ?m ?o ?v ?e ?C ?r ?u ?r ?e ?n backspace backspace backspace backspace backspace ?u ?r ?r ?e ?n ?t ?T ?a ?b ?\( ?\) ?\; return ?\M-x ?w ?i ?n ?d ?m ?o ?v ?e ?- ?d ?o ?w ?n return])
  130. (global-set-key '[(f1)] 'traverse-hyperlink-line)
  131. (global-set-key '[(f2)] 'unsqlize-delete)
  132. (global-set-key '[(f3)] 'twitter-macro-1)
  133. (global-set-key '[(f4)] 'url-macro-1)
  134. (global-set-key '[(f5)] 'firefox-macro-2)
  135. (global-set-key '[(f6)] 'firefox-macro-3)
  136. (global-set-key '[(f7)] 'moz-close-tab)
  137. (defun sum (L) (reduce '+ L))
  138. (defun sizeof (L) (length L))
  139. (defun getElement (N L)
  140. "returns the Nth element of list L. 0 indexed"
  141. (if (<= N 0)
  142. (car L)
  143. (getElement (- N 1 ) (cdr L) )
  144. )
  145. )
  146. (defun listOfNfs (N f)
  147. "returns a list of N fs"
  148. (if (<= N 0)
  149. '()
  150. (cons f (listOfNfs (- N 1) f))))
  151. (defun sign (N)
  152. (if (numberp N)
  153. (if (> N 0) 1
  154. (if (< N 0) -1
  155. 0)) NaN
  156. ))
  157. (defun log2 (N) (/ (log N) (log 2)))
  158. (defun entropy (P1) (- (+ (* P1 (log2 P1)))))
  159. (defun zero? (Z)
  160. (if (numberp Z )
  161. (if (= Z 0)
  162. 1
  163. nil)
  164. nil))
  165. (defun eqv? (A B)
  166. (if (and (numberp A ) (numberp B) )
  167. (if (= A B)
  168. 1
  169. nil)
  170. nil))
  171. (defun binome
  172. (n k)
  173. (if (> k n) '(help, I'm trapped in a universe factory!)
  174. (if (zero? k) 1
  175. (if (eqv? k n) 1
  176. (+ (funcall 'binome (- n 1) k) (funcall 'binome (- n 1) (- k 1)) )
  177. )
  178. ))
  179. )
  180. (defun avg (L) (/ (sum L) (length L)))
  181. (defun positiveintegerp (n)
  182. "0+ is positive here"
  183. (if (integerp n)
  184. (if (>= n 0)
  185. 1
  186. nil)
  187. nil
  188. )
  189. )
  190. (defun ! (N)
  191. (if (positiveintegerp N)
  192. (if (= N 0)
  193. 1
  194. (if (> N 0)
  195. (* N (! (- N 1))) N))
  196. "error: incorrect data, positive integer required"))
  197. (defun do-n-times (f n x)
  198. "call function f with arity 1 on data x on itself n times, f1(f2(f...(fn(x)))). n must be positive nonzero integer"
  199. (if (> n 0)
  200. (funcall f (do-n-times f (- n 1) x))
  201. x)
  202. )
  203. (defun mf (m) (/ (- (expt 2.0 m) 1) (expt 2.0 m)))
  204. (defun nsp (P1 P2)
  205. (setq diff (abs (- P1 P2)))
  206. ;; ordinal
  207. (setq fair (string-to-int (format "%d" (/ 1.0 (entropy diff)))))
  208. ;;(message "entropy diff %d" (/ 1.0 (entropy diff)))
  209. ;;(message "fair %d" fair)
  210. ;; we want this in flips of a number
  211. (mf fair)
  212. )
  213. (defun whatprob (p) (/ (+ (- 2) (sqrt (- 4 (* 4 p ) ))) (* -2)))
  214. (defun whatprob2 (p) (- (* 2 p) (* p p)))
  215. (defun drop-1 (L) (reverse (cdr (reverse L))))
  216. (defun drop (L n)
  217. (setq err "drop requires a positive integer argument n (drop <list> N)")
  218. (if (= n 0)
  219. L
  220. (if (< n 1)
  221. (message "%s" err)
  222. (if (not (listp L))
  223. (message "%s" err)
  224. (do-n-times 'drop-1 n L)))))
  225. (defun successor (n)
  226. "successor function"
  227. (+ n 1))
  228. (defun 名单 ( &rest ns) ns)
  229. (defun *L (L1 L2 f)
  230. "takes function/binary relation f and applies it like dot product to lists L1 & L2's members"
  231. (*L-helper L1 L2 f (sizeof L1) ))
  232. (defun *L-helper (L1 L2 f N)
  233. (if (not (= N 0))
  234. (cons (funcall f (car L1) (car L2)) (*L-helper (cdr L1) (cdr L2) f (- N 1)))))
  235. (defun nCr (a b)
  236. "a choose b : a > b, (a,b) e Z+. The problem with doing it this way is a,b can get too big. at ~19 we start seeing overflows. if we ever need this, rewrite to reduce factors"
  237. (if (and (positiveintegerp a) (positiveintegerp b))
  238. (if (and (>= a b) (>= a 0) (>= b 0) (< a 19) (< b 19))
  239. (/ (! a) (* (! (- a b) ) (! b)))
  240. "error: nCr range error")
  241. "error: nCr requires positive integers"))
  242. (setq max_int (- (expt 2 61) 1))
  243. (setq e (exp 1))
  244. (setq pi (* 4 (atan 1)))
  245. (fset 'justify-hard-to-read-block
  246. [escape ?7 ?9 right C-right return C-left return end delete ? home])
  247. (defun ^ (a b)
  248. (expt a b))
  249. (defun stddev (L)
  250. "finds standard deviation of list L"
  251. (sqrt (/ (std-helper L (avg L)) (- (sizeof L) 1))))
  252. (defun std-helper (L a)
  253. "recursively goes through L, adding partial standard deviation sum as it goes"
  254. (if (nullp L)
  255. 0
  256. (+ (^ (- (car L) a) 2) (std-helper (cdr L) a))))
  257. (defun stderr (L)
  258. "standard error"
  259. (/ (stddev L) (sqrt (sizeof L)) ))
  260. (defun dot (L1 L2)
  261. ; "dot product" of L1 and L2
  262. (if (and (= (sizeof L1) 0)
  263. (= (sizeof L1) 0))
  264. '()
  265. (if (= (sizeof L1) (sizeof L2))
  266. (cons (* (car L2) (car L1))
  267. (dot (cdr L1) (cdr L2)))
  268. "lists not equal size")))
  269. (defun sumfrom1ton (N) (message "%x" (/ (* N (+ N 1)) 2)))
  270. ;; i don't remember how to use this one
  271. (defun debias (bias belief)
  272. (+ 50 (* (sign (- belief 50)) (sqrt (* (- 1 bias ) (expt (- belief 50) 2))))))
  273. (when window-system
  274. (set-fringe-style 1)
  275. (set-cursor-color "white"))