;; move by file lines, not screen lines
(setq line-move-visual nil)

; 'xah or 'evil or 'ergo or 'boon or 'meow or 'devil
(setq jareds-mood 'devil)
; make numpad + key be decoded as insertline key; this is necessary
; for ergoemacs, which has no other binding for what used to be C-o.
(define-key input-decode-map [kp-add] [insertline])

(require 'package) ;; You might already have this line
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
  (add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

; (require 'fill-column-indicator)


; http://blog.bookworm.at/2007/03/pretty-print-xml-with-emacs.html
(defun bf-pretty-print-xml-region (begin end)
  "Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
  (interactive "r")
  (save-excursion
    (nxml-mode)
    (goto-char begin)
    (while (search-forward-regexp "\>[ \\t]*\<" nil t) 
      (backward-char) (insert "\n") (setq end (1+ end)))
    (indent-region begin end))
  (message "Ah, much better!"))


; did not work.
; avoid colons in filenames during tramp autosaves: Windows can't deal with these
; https://github.com/syl20bnr/spacemacs/issues/7302
; (setq tramp-auto-save-directory (concat temporary-file-directory "tramp/"))

(put 'narrow-to-region 'disabled nil)

;; customize telephone-line for my mood before starting it.  other
;; mood-specific things after the customize blob, because customized
;; vars should apply.
(cond ((eq jareds-mood 'xah)
       ;; there is some cleaner way to do this without repeating all
       ;; of telephone-line-lhs's definition. but i didn't find it.
       (setq telephone-line-lhs
	     '((evil . (telephone-line-xah-fly-keys-segment))
	       (accent . (telephone-line-vc-segment
			  telephone-line-process-segment))
	       (nil . (telephone-line-minor-mode-segment
		       telephone-line-buffer-segment))))
             )
      ((eq jareds-mood 'evil)
       (setq telephone-line-lhs
             '((evil . (telephone-line-evil-tag-segment))
               (accent . (telephone-line-vc-segment
        		  telephone-line-process-segment))
               (nil . (telephone-line-minor-mode-segment
        	       telephone-line-buffer-segment)))))
      ((eq jareds-mood 'boon)
       (telephone-line-defsegment* telephone-line-boon-segment ()
         (when (boundp boon-mode)
           (let ((tag (cond
                       (boon-insert-state "INSERT")
                       (boon-command-state "COMMAND")
                       (boon-special-state "EMACS"))))
             (if telephone-line-evil-use-short-tag
                 (seq-take tag 1)
               tag))))
       (setq telephone-line-lhs
	     '((evil . (telephone-line-boon-segment))
	       (accent . (telephone-line-vc-segment
			  telephone-line-process-segment))
	       (nil . (telephone-line-minor-mode-segment
		       telephone-line-buffer-segment))))       )
      ((eq jareds-mood 'ergo)
       (setq telephone-line-lhs
             '((accent . (telephone-line-vc-segment
        		  telephone-line-process-segment))
               (nil . (telephone-line-minor-mode-segment
        	       telephone-line-buffer-segment)))))
      (t nil))



(setq telephone-line-rhs
      '((nil . (telephone-line-misc-info-segment))
	(accent . (telephone-line-major-mode-segment))
	(evil . (telephone-line-airline-position-segment))))
(setq telephone-line-primary-left-separator 'telephone-line-flat
      telephone-line-secondary-left-separator 'telephone-line-flat
      telephone-line-primary-right-separator 'telephone-line-flat
      telephone-line-secondary-right-separator 'telephone-line-flat)
(setq telephone-line-evil-use-short-tag t)
(require 'telephone-line)
(telephone-line-mode 1)

(defcustom jlj--assets-to-obfuscate
  `(("[a-zA-Z0-9.]+\\.example\\.com" ,(apply-partially #'jlj--obfuscate-fqdn
                                                       ".example.com"))
   ("192\\.168\\.1\\.[0-9]+" jlj--obfuscate-ip))
  "IT assets the names and addresses of which jlj--obfuscate-assets should obfuscate. For each regexp match, a new obfuscated thing is made using the given function, and all occurrences of the real name or address are replaced with the result of the function."
  :type '(list (list regexp function)))

(defun jlj--scheme-folding ()
  "Turn on folding when entering Scheme major mode. See customize group Folding."
  (folding-add-to-marks-list 'scheme-mode ";;{{{ " ";;}}}")
  (turn-on-folding-mode))

;; A boonish keymap for the folding minor mode
(define-prefix-command 'jlj-folding-map)
(define-key jlj-folding-map [?\C-e] 'folding-hide-current-entry)
(define-key jlj-folding-map [?\C-i] 'folding-show-current-entry)
(define-key jlj-folding-map [?\C-k] 'folding-hide-current-subtree)
(define-key jlj-folding-map [?\/] 'folding-show-current-subtree)
(define-key jlj-folding-map [?\C-u] 'folding-previous-visible-heading)
(define-key jlj-folding-map [?\C-y] 'folding-next-visible-heading)
(define-key jlj-folding-map [?\C-c] 'folding-context-next-action)
(define-key jlj-folding-map [?\C-l] 'folding-whole-buffer)
(define-key jlj-folding-map [?\;] 'folding-open-buffer)
(define-key jlj-folding-map [?\.] 'folding-display-name)
(define-key jlj-folding-map [?\C-f] 'folding-fold-region)
(define-key jlj-folding-map [?\C--] 'folding-shift-out)
(define-key jlj-folding-map [?\=] 'folding-shift-in)


(defun jlj--install-folding-map ()
  (define-key mode-specific-map "\C-w" jlj-folding-map))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(ansi-color-names-vector
   ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
 '(avy-keys '(97 114 115 116 100 104 110 101 105 111))
 '(awesome-tray-mode-line-active-color "#2fafff")
 '(awesome-tray-mode-line-inactive-color "#323232")
 '(boon-quit-key [home])
 '(boon-special-mode-list
   '(Buffer-menu-mode cfw:calendar-mode debugger-mode ediff-mode ediff-meta-mode finder-mode git-rebase-mode mu4e-headers-mode mu4e-view-mode notmuch-hello-mode notmuch-search-mode notmuch-show-mode notmuch-tree-mode org-agenda-mode pass-mode view-mode edebug-mode))
 '(browse-url-browser-function 'eww-browse-url)
 '(case-fold-search nil)
 '(completion-styles '(orderless))
 '(custom-enabled-themes '(sexy-monochrome))
 '(custom-safe-themes
   '("cec8e841d2736d48fbf6578230fdee035a7be26c624ca5a266835b040e9caed2" "9b4ae6aa7581d529e20e5e503208316c5ef4c7005be49fdb06e5d07160b67adc" "0851a8045231c27d5274da06aae06c81f9be75d04ba4c3ee43997708d3cf30d1" "1524ee33541a025ea700dfcd9e275646488d210b374783425f1664454f266183" "a04676d7b664d62cf8cd68eaddca902899f98985fff042d8d474a0d51e8c9236" "63d5b85a4a8840df8c0a321dd8769381095bc0a0b7ef03a3aa1aa50aa23ea662" "f0743a238e80c38ca3d73bc03327ae3e529f2bc33d67efb41616ea1caffaebd6" "3ebef83a2705540325b0223388796b392f9e1e54a3063e6ba4827a380ed5477c" "a5a788e89884387d68c6e5c4e84e9d3b1a5723500a5fcf56a112d87deb6362cf" "6e6982c9bbe999b057486b0cfd7ee1884ceccac1602206cb7d4ed18cdd98abad" "37768a79b479684b0756dec7c0fc7652082910c37d8863c35b702db3f16000f8" "7c0830e1aea024fc0d4e76ba3db9f78cb37c09da2290f38af1a8fe87881007f7" "cfe4d36ed4cf00a541f7ba0deb38c94808c13a3e4c717f07bc3b9c866670e8d1" "474513bacf33a439da7b9a5df1dd11a277929d8480752675fc7d5f3816d8fdef" "b07a04cf42fe1001b2119b45f40cbc368783b5b8e1721ce3728a5f2823d97a66" "72ed8b6bffe0bfa8d097810649fd57d2b598deef47c992920aef8b5d9599eefe" "2ff9ac386eac4dffd77a33e93b0c8236bb376c5a5df62e36d4bfa821d56e4e20" "09c7e6bedcc4724a003e0ff36e045822b0385582b11a52758ed77973df04f3ee" "930243b929e5886e97390710218558ab346b31f6d04c6320d5182a81761ce9ed" "1d609285d297920b97b0d230360a8d7c3f930edcf1abe96a1d82356f9a5e228d" "abe5ee8858cd1fbe36304a8c3b2315d3e0a4ef7c8588fcc45d1c23eafb725bb6" "d600c677f1777c1e4bfb066529b5b73c0179d0499dd4ffa3f599a0fb0cfbd501" "30289fa8d502f71a392f40a0941a83842152a68c54ad69e0638ef52f04777a4c" "c7f10959cb1bc7a36ee355c765a1768d48929ec55dde137da51077ac7f899521" "773e0bfa5450c75d613cbf29734cdc876c3d59dbf85b93cff3015a8687dea158" "bf798e9e8ff00d4bf2512597f36e5a135ce48e477ce88a0764cfb5d8104e8163" "1436d643b98844555d56c59c74004eb158dc85fc55d2e7205f8d9b8c860e177f" "1e9001d2f6ffb095eafd9514b4d5974b720b275143fbc89ea046495a99c940b0" "f11e219c9d043cbd5f4b2e01713c2c24a948a98bed48828dc670bd64ae771aa1" "8f97d5ec8a774485296e366fdde6ff5589cf9e319a584b845b6f7fa788c9fa9a" "2642a1b7f53b9bb34c7f1e032d2098c852811ec2881eec2dc8cc07be004e45a0" "5111a41453244802afd93eed1a434e612a8afbdf19c52384dffab129258bab6e" "0329c772ed96053a73b9ddddf96c1183e23c267955bbdf78e7933057ce9da04b" "36ca8f60565af20ef4f30783aa16a26d96c02df7b4e54e9900a5138fb33808da" "23b564cfb74d784c73167d7de1b9a067bcca00719f81e46d09ee71a12ef7ee82" "f7ef6451d988d6e2fc86deea398eee02b3371703d88f265d31a011bd240dcf99" "3d4df186126c347e002c8366d32016948068d2e9198c496093a96775cc3b3eaa" "c560237b7505f67a271def31c706151afd7aa6eba9f69af77ec05bde5408dbcd" "24cb0b5666e1e17fb6a378c413682f57fe176775eda015eb0a98d65fbb64b127" "b0eb9e6e6dcb29c6ec4bcd72605188f482d52ee019cb0ccc73b5404be4f3a6e7" "08a89acffece58825e75479333109e01438650d27661b29212e6560070b156cf" "c9ddf33b383e74dac7690255dd2c3dfa1961a8e8a1d20e401c6572febef61045" "a22f40b63f9bc0a69ebc8ba4fbc6b452a4e3f84b80590ba0a92b4ff599e53ad0" "585942bb24cab2d4b2f74977ac3ba6ddbd888e3776b9d2f993c5704aa8bb4739" "fa2af0c40576f3bde32290d7f4e7aa865eb6bf7ebe31eb9e37c32aa6f4ae8d10" "85d1dbf2fc0e5d30f236712b831fb24faf6052f3114964fdeadede8e1b329832" "bffb799032a7404b33e431e6a1c46dc0ca62f54fdd20744a35a57c3f78586646" "779df25c6240f183dd378811465566082eacc3c86ed260835382cb5c1dc54de3" "eee70baee3a2d093a98fa344480d2330eb3a17f8dfa883cc41d8008cd46fa669" "b70474b8a631f73868f01fdb047f102dd36325ecbf6789962e613e9195e165d7" "ccdd152be99a9250f5c24e09860911ff4b1519a8c4c73e4d67364514a3359f71" "ba913d12adb68e9dadf1f43e6afa8e46c4822bb96a289d5bf1204344064f041e" "146614f131e5029df850a268aff1f0e3ae16734a119904eab133755b574da37d" "c8935cb969e24ff30a6ee1da011eadc156b9f128a3b0a39cc664628838a644ad" "767a6105de48707dd6a593b62c05a7bf4ee9930c86e3225410110d95906772d6" "39546362fed4d5201b2b386dc21f21439497c9eec5fee323d953b3e230e4083e" "2f4f50d98073c01038b518066840638455657dc91dd1a225286d573926f36914" "80ae3a89f1eca6fb94a525004f66b544e347c6f756aaafb728c7cdaef85ea1f5" "7b1a2c8ec90a30cc5d039db0e52f192a291f4c3655103cf669721f94028eac27" "bcd0237b2a5b7897e482458cc62c4f3fa3d9d7f9a9667338e67d4c7a8e009819" "8e79884e89740cf6b7e0210f52e4ac995dc1f1a9a17151bfcfb4d660757a011b" "454c1c9ce70f7d807c51c890910365fd3c64a9e63f596511e9ff57dd97bbeea8" "387b487737860e18cbb92d83a42616a67c1edfd0664d521940e7fbf049c315ae" "6231254e74298a1cf8a5fee7ca64352943de4b495e615c449e9bb27e2ccae709" "3577ee091e1d318c49889574a31175970472f6f182a9789f1a3e9e4513641d86" "cbd85ab34afb47003fa7f814a462c24affb1de81ebf172b78cb4e65186ba59d2" "8f5b54bf6a36fe1c138219960dd324aad8ab1f62f543bed73ef5ad60956e36ae" "9d8ad1c413fccc14d992f6bed0ead11f1798a05ee8913daaa24a24604c212b61" "e246ff6951678c835ab95aedb99a48fdd665656eadf8b8bc0a4f60e17fbc6b7e" "e57eec7e0399272aaca7985a5cc94f3a2675db4cd2dbd79a99c72786e489e43c" "d0fd069415ef23ccc21ccb0e54d93bdbb996a6cce48ffce7f810826bb243502c" "ffba0482d3548c9494e84c1324d527f73ea4e43fff8dfd0e48faa8fc6d5c2bc7" "9e816bc85b64963710efdbc57db8545b53f7f359b0736e0b36fbc9efe07f12f4" "6ac7c0f959f0d7853915012e78ff70150bfbe2a69a1b703c3ac4184f9ae3ae02" "845103fcb9b091b0958171653a4413ccfad35552bc39697d448941bcbe5a660d" "bc836bf29eab22d7e5b4c142d201bcce351806b7c1f94955ccafab8ce5b20208" "7f6d4aebcc44c264a64e714c3d9d1e903284305fd7e319e7cb73345a9994f5ef" "10a31b6c251640d04b2fa74bd2c05aaaee915cbca6501bcc82820cdc177f5a93" "6e933f1668e124ec17fc7b6547f65ba760e06efb568a6c8091c600c67827e592" "02199888a97767d7779269a39ba2e641d77661b31b3b8dd494b1a7250d1c8dc1" "2a49f95b19d5926d940db11057077df2d01faaf33e66c5a8d4ee8043a904695f" "bdb4509c123230a059d89fc837c40defdecee8279c741b7f060196b343b2d18d" "ed17fef69db375ae1ced71fdc12e543448827aac5eb7166d2fd05f4c95a7be71" "6515fcc302292f29a94f6ac0c5795c57a396127d5ea31f37fc5f9f0308bbe19f" "5a45c8bf60607dfa077b3e23edfb8df0f37c4759356682adf7ab762ba6b10600" "6c5a5c47749e7992b4da3011595f5470f33e19f29b10564cd4f62faebbe36b91" "8a379e7ac3a57e64de672dd744d4730b3bdb88ae328e8106f95cd81cbd44e0b6" "2035a16494e06636134de6d572ec47c30e26c3447eafeb6d3a9e8aee73732396" "ed0b4fc082715fc1d6a547650752cd8ec76c400ef72eb159543db1770a27caa7" "42b9d85321f5a152a6aef0cc8173e701f572175d6711361955ecfb4943fe93af" "021720af46e6e78e2be7875b2b5b05344f4e21fad70d17af7acfd6922386b61e" "9fcac3986e3550baac55dc6175195a4c7537e8aa082043dcbe3f93f548a3a1e0" "242527ce24b140d304381952aa7a081179a9848d734446d913ca8ef0af3cef21" "8cb818e0658f6cc59928a8f2b2917adc36d882267bf816994e00c5b8fcbf6933" "3fa81193ab414a4d54cde427c2662337c2cab5dd4eb17ffff0d90bca97581eb6" "44247f2a14c661d96d2bff302f1dbf37ebe7616935e4682102b68c0b6cc80095" "73bff6f2ef60f8a1238a9ca666235d258e3acdeeed85d092ca532788dd7a33c4" "05eeb814f74b2fd4f2e6e37b4d604eb9b1daaaedfa5e692f1d485250c6b553eb" "0055e55e6a357a941027139152a67f93376616d3501055d06852f10fdc16bac0" "1f3113447a652b8436a9938bbac71ecaf022cc73ecd0d76182eb9713aa781f17" "b755c709cb46ba4599ab3a3c189a056e9736cbbb39ed9ecfc1ab1aa3d6f79021" "75c5c39809c52d48cb9dcbf1694bf2d27d5f6fd053777c194e0b69d8e49031c0" "54e08527b4f4b127ebf7359acbbbecfab55152da01716c4809682eb71937fd33" "81db42d019a738d388596533bd1b5d66aef3663842172f3696733c0aab05a150" "ef1e992ef341e86397b39ee6b41c1368e1b33d45b0848feac6a8e8d5753daa67" "ad109c1ad8115573f40e22ac2b996693b5d48052fa37b5919f70ea37c62a965e" "b143ad150e25f9b6d09ae313718f85cc785c89445f3369f74bd0d836d5881c56" "dc9a8d70c4f94a28aafc7833f8d05667601968e6c9bf998791c39fcb3e4679c9" "125fd2180e880802ae98b85f282b17f0aa8fa6cb9fc4f33d7fb19a38c40acef0" "4d80487632a0a5a72737a7fc690f1f30266668211b17ba836602a8da890c2118" "9a155066ec746201156bb39f7518c1828a73d67742e11271e4f24b7b178c4710" "4bfced46dcfc40c45b076a1758ca106a947b1b6a6ff79a3281f3accacfb3243c" "31992d4488dba5b28ddb0c16914bf5726dc41588c2b1c1a2fd16516ea92c1d8e" "0e33022384e4db1374827f51e3d9e9a2d56282c2e3568c22f1c12ad80e20cf0c" "83db918b06f0b1df1153f21c0d47250556c7ffb5b5e6906d21749f41737babb7" "47744f6c8133824bdd104acc4280dbed4b34b85faa05ac2600f716b0226fb3f6" "8b313e1793da427e90c034dbe74f3ad9092ac291846c0f855908c42a6bda1ff4" "43c1a8090ed19ab3c0b1490ce412f78f157d69a29828aa977dae941b994b4147" "bc4b650c41b16b98166b35da94b366c6a9e1e7883bbf4937c897fb7bd05aa619" "e9460a84d876da407d9e6accf9ceba453e2f86f8b86076f37c08ad155de8223c" "8ec2e01474ad56ee33bc0534bdbe7842eea74dccfb576e09f99ef89a705f5501" "d606ac41cdd7054841941455c0151c54f8bff7e4e050255dbd4ae4d60ab640c1" "4f2ede02b3324c2f788f4e0bad77f7ebc1874eff7971d2a2c9b9724a50fb3f65" "2b6bd2ebad907ee42b3ffefa4831f348e3652ea8245570cdda67f0034f07db93" "7f3ef7724515515443f961ef87fee655750512473b1f5bf890e2dc7e065f240c" "65d9573b64ec94844f95e6055fe7a82451215f551c45275ca5b78653d505bc42" "39dffaee0e575731c909bb3e4b411f1c4759c3d7510bf02aa5aef322a596dd57" "2cf7f9d1d8e4d735ba53facdc3c6f3271086b6906c4165b12e4fd8e3865469a6" default))
 '(custom-theme-directory "~/.emacs.d/lisp/themes")
 '(devil-lighter " ɤ")
 '(devil-prompt "ɤ %t")
 '(devil-repeatable-keys
   '(("%k /")
     ("%k d")
     ("%k k")
     ("%k m ^")
     ("%k m e")
     ("%k m b" "%k m f" "%k m a" "% k m e")
     ("%k m @" "%k m h")
     ("%k m y")
     ("%k p" "%k n" "%k b" "%k f" "%k a" "%k e")
     ("%k s" "%k r")
     ("%k x [" "%k x ]")
     ("%k x ^" "%k x {" "%k x }")
     ("%k x o")
     ("%k x u")))
 '(doc-view-image-width 1150)
 '(doc-view-resolution 200)
 '(face-font-family-alternatives
   '(("Inconsolata")
     ("Monospace" "courier" "fixed")
     ("courier" "CMU Typewriter Text" "fixed")
     ("Sans Serif" "helv" "helvetica" "arial" "fixed")
     ("helv" "helvetica" "arial" "fixed")))
 '(fci-rule-color "#f8fce8")
 '(fci-rule-column 80)
 '(flymake-error-bitmap '(flymake-double-exclamation-mark modus-theme-fringe-red))
 '(flymake-note-bitmap '(exclamation-mark modus-theme-fringe-cyan))
 '(flymake-warning-bitmap '(exclamation-mark modus-theme-fringe-yellow))
 '(folding-mode-hook '(jlj--install-folding-map))
 '(fringe-mode 10 nil (fringe))
 '(highlight-tail-colors '(("#2f4a00" . 0) ("#00415e" . 20)))
 '(hl-paren-background-colors '("#e8fce8" "#c1e7f8" "#f8e8e8"))
 '(hl-paren-colors '("#40883f" "#0287c8" "#b85c57"))
 '(hl-sexp-background-color "#efebe9")
 '(hl-todo-keyword-faces
   '(("HOLD" . "#cfdf30")
     ("TODO" . "#feacd0")
     ("NEXT" . "#b6a0ff")
     ("THEM" . "#f78fe7")
     ("PROG" . "#00d3d0")
     ("OKAY" . "#4ae8fc")
     ("DONT" . "#80d200")
     ("FAIL" . "#ff8059")
     ("BUG" . "#ff8059")
     ("DONE" . "#44bc44")
     ("NOTE" . "#f0ce43")
     ("KLUDGE" . "#eecc00")
     ("HACK" . "#eecc00")
     ("TEMP" . "#ffcccc")
     ("FIXME" . "#ff9977")
     ("XXX+" . "#f4923b")
     ("REVIEW" . "#6ae4b9")
     ("DEPRECATED" . "#bfd9ff")))
 '(ibuffer-deletion-face 'modus-theme-mark-del)
 '(ibuffer-filter-group-name-face 'modus-theme-mark-symbol)
 '(ibuffer-marked-face 'modus-theme-mark-sel)
 '(ibuffer-title-face 'modus-theme-pseudo-header)
 '(indent-tabs-mode nil)
 '(inhibit-startup-screen t)
 '(ispell-dictionary nil)
 '(ivy-mode nil)
 '(ivy-use-virtual-buffers t)
 '(ivy-virtual-abbreviate 'abbreviate)
 '(jdee-db-active-breakpoint-face-colors (cons nil nil))
 '(jdee-db-requested-breakpoint-face-colors (cons nil nil))
 '(jdee-db-spec-breakpoint-face-colors (cons nil nil))
 '(jlj--assets-to-obfuscate
   `(("[a-zA-Z0-9.]+\\.png\\.loc" ,(apply-partially #'jlj--obfuscate-fqdn "png.loc"))
     ("10\\.62\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("10\\.63\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("10\\.70\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("10\\.222\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("10\\.228\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("10\\.229\\.[0-9]+\\.[0-9]+" jlj--obfuscate-ip)
     ("192\\.168\\.10\\.[0-9]+" jlj--obfuscate-ip)
     ("192\\.168\\.12\\.[0-9]+" jlj--obfuscate-ip)
     ("192\\.168\\.92\\.[0-9]+" jlj--obfuscate-ip)
     ("192\\.168\\.199\\.[0-9]+" jlj--obfuscate-ip)))
 '(line-number-mode nil)
 '(linum-format " %6d ")
 '(main-line-color1 "#222232")
 '(main-line-color2 "#333343")
 '(menu-bar-mode nil)
 '(modus-operandi-theme-3d-modeline t)
 '(modus-operandi-theme-comments 'green)
 '(modus-operandi-theme-diffs 'desaturated)
 '(modus-operandi-theme-distinct-org-blocks t)
 '(modus-operandi-theme-faint-syntax t)
 '(modus-vivendi-theme-3d-modeline nil)
 '(modus-vivendi-theme-comments 'green)
 '(modus-vivendi-theme-diffs 'desaturated)
 '(modus-vivendi-theme-faint-syntax t)
 '(modus-vivendi-theme-headings ''((t)))
 '(modus-vivendi-theme-intense-paren-match t)
 '(modus-vivendi-theme-mode-line 'moody)
 '(modus-vivendi-theme-prompts 'subtle)
 '(modus-vivendi-theme-section-headings t)
 '(modus-vivendi-theme-slanted-constructs t)
 '(modus-vivendi-theme-subtle-diffs t)
 '(multikeyfreq-excluded-commands
   '(delete-backward-char eshell-send-input ivy-backward-delete-char mouse-drag-region mouse-set-point mwheel-scroll org-cycle org-delete-backward-char org-self-insert-command scroll-down-command scroll-up-command self-insert-command))
 '(nrepl-message-colors
   '("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3"))
 '(objed-cursor-color nil)
 '(org-agenda-files '("h:/Documents/todo.org"))
 '(org-archive-location "%s_archive::")
 '(org-babel-load-languages '((dot . t) (emacs-lisp . t)))
 '(org-checkbox-hierarchical-statistics nil)
 '(org-confirm-babel-evaluate nil)
 '(org-drill-done-count-color "#663311")
 '(org-drill-failed-count-color "#880000")
 '(org-drill-mature-count-color "#005500")
 '(org-drill-new-count-color "#004488")
 '(org-hierarchical-todo-statistics nil)
 '(org-latex-hyperref-template
   "\\hypersetup{
 pdfauthor={%a},
 pdftitle={%t},
 pdfkeywords={%k},
 pdfsubject={%d},
 pdfcreator={%c},
 pdflang={%L},
 colorlinks=true}
")
 '(org-log-done 'time)
 '(org-mode-hook
   '(#[0 "\301\211\20\207"
         [imenu-create-index-function org-imenu-get-tree]
         2]
     #[0 "\300\301\302\303\304$\207"
         [add-hook change-major-mode-hook org-show-all append local]
         5]
     #[0 "\300\301\302\303\304$\207"
         [add-hook change-major-mode-hook org-babel-show-result-all append local]
         5]
     org-babel-result-hide-spec org-babel-hide-all-hashes auto-fill-mode))
 '(org-refile-targets (list (cons nil (cons :maxlevel 2))))
 '(org-return-follows-link t)
 '(org-startup-indented t)
 '(org-todo-keywords '((sequence "WAITING" "TODO" "DONE")))
 '(org-todo-repeat-to-state "TODO")
 '(org-use-sub-superscripts '{})
 '(package-selected-packages
 '(yaml-mode ansible org-present zpresent spacious-padding logstash-conf org-mind-map lentic web-server weyland-yutani-theme sly nov ement fennel-mode ox-gemini org-superstar omtose-phellack-theme pyvenv-auto paredit warm-night-theme geiser-guile geiser geiser-chicken spacegray-theme soft-charcoal-theme slime abyss-theme ample-theme djvu elpher ox-rst ripgrep unicode-fonts no-spam uuid marginalia embark-consult embark orderless selectrum consult vertico dockerfile-mode x509-mode forth-mode browse-at-remote cider sesman clojure-mode eziam-theme scad-mode acme-theme sexy-monochrome-theme monotropic-theme constant-theme graphviz-dot-mode mood-line mood-one-theme modus-vivendi-theme modus-operandi-theme browse-url-dwim magit parchment-theme almost-mono-themes borland-blue-theme nordless-theme northcode-theme nord-theme nofrils-acme-theme multikeyfreq fireplace boon csv-mode ein markdown-mode puppet-mode dad-joke keyfreq avy-zap avy ggtags counsel-projectile projectile command-log-mode counsel vc-fossil visible-mark esup sudden-death jammer arjen-grey-theme atom-dark-theme clues-theme dark-krystal-theme darkburn-theme eink-theme foggy-night-theme green-screen-theme gruvbox-theme heroku-theme inverse-acme-theme iodine-theme labburn-theme leuven-theme evil-visual-mark-mode excorporate telephone-line xah-fly-keys which-key url-http-ntlm toml-mode plan9-theme ergoemacs-mode))
 '(pdf-view-midnight-colors '("#eeeeee" . "#000000"))
 '(pos-tip-background-color "#414E63")
 '(pos-tip-foreground-color "#BEC8DB")
 '(powerline-color1 "#222232")
 '(powerline-color2 "#333343")
 '(rainbow-identifiers-choose-face-function 'rainbow-identifiers-cie-l*a*b*-choose-face t)
 '(rainbow-identifiers-cie-l*a*b*-color-count 1024 t)
 '(rainbow-identifiers-cie-l*a*b*-lightness 80 t)
 '(rainbow-identifiers-cie-l*a*b*-saturation 25 t)
 '(rustic-ansi-faces [nil nil nil nil nil nil nil nil])
 '(safe-local-variable-values
   '((Package . CL-UNICODE)
     (Base . 10)
     (Package . FLEXI-STREAMS)
     (Syntax . COMMON-LISP)))
 '(scheme-mode-hook '(geiser-mode--maybe-activate jlj--scheme-folding) t)
 '(scroll-bar-mode nil)
 '(sentence-end-double-space nil)
 '(show-paren-mode nil)
 '(sml/active-background-color "#98ece8")
 '(sml/active-foreground-color "#424242")
 '(sml/inactive-background-color "#4fa8a8")
 '(sml/inactive-foreground-color "#424242")
 '(telephone-line-evil-use-short-tag t)
 '(telephone-line-mode nil)
 '(tool-bar-mode nil)
 '(transient-mark-mode nil)
 '(vc-annotate-background "#2B2B2B")
 '(vc-annotate-background-mode nil)
 '(vc-annotate-color-map
   '((20 . "#BC8383")
     (40 . "#CC9393")
     (60 . "#DFAF8F")
     (80 . "#D0BF8F")
     (100 . "#E0CF9F")
     (120 . "#F0DFAF")
     (140 . "#5F7F5F")
     (160 . "#7F9F7F")
     (180 . "#8FB28F")
     (200 . "#9FC59F")
     (220 . "#AFD8AF")
     (240 . "#BFEBBF")
     (260 . "#93E0E3")
     (280 . "#6CA0A3")
     (300 . "#7CB8BB")
     (320 . "#8CD0D3")
     (340 . "#94BFF3")
     (360 . "#DC8CC3")))
 '(vc-annotate-very-old-color "#DC8CC3")
 '(vertico-mode t)
 '(visible-bell nil)
 '(xterm-color-names
   ["#000000" "#ff8059" "#44bc44" "#eecc00" "#2fafff" "#feacd0" "#00d3d0" "#a8a8a8"])
 '(xterm-color-names-bright
   ["#181a20" "#f4923b" "#80d200" "#cfdf30" "#79a8ff" "#f78fe7" "#4ae8fc" "#ffffff"]))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :extend nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 128 :width normal :foundry "IBM " :family "IBM Plex Mono"))))
 '(mode-line-highlight ((t (:box nil))))
 '(mode-line-inactive ((t (:box nil))))
 '(org-done ((t (:background "#D0D0D0" :foreground "#222222" :weight bold :height 0.8))))
 '(org-todo ((t (:inverse-video t :weight bold :height 0.8))))
 '(show-paren-match ((t (:inherit sp-show-pair-match-face :foreground "black" :background "yellow" :weight bold))))
 '(variable-pitch ((t (:height 1.2 :foundry "outline" :family "IBM Plex Sans Light")))))

(cond
 ((string-equal system-configuration "x86_64-w64-mingw32")
  (progn
    (setq python-shell-interpreter "python.exe")
    (setq x509-openssl-cmd "C:/Program Files/Git/usr/bin/openssl.exe")
    (setq python-shell-exec-path
          '("c:/program files/python310"
            "c:/program files/python38"
            "c:/program files/python37"))
    (setq diff-command "\"C:\\Program Files\\Git\\usr\\bin\\diff.exe\"")
    (setq ediff-diff-program "c:\\program files\\git\\usr\\bin\\diff.exe")
    (setq ediff-patch-program "\"c:\\program files\\git\\usr\\bin\\patch.exe\"")
    (setq org-agenda-files '("h:/Documents/todo.org"))
    ))
 ((string-equal system-name "wtsvSecurity01")
  (setq org-capture-templates
        (apply append
               (if (boundp 'org-capture-templates) org-capture-templates '())
               '(("t" "todo")
                 ("tt" "todo" entry
                  (file+headline "h:/documents/todo.org" "inbox")
                  "** TODO %? %^g")
                 ("tc" "change" entry
                  (file+headline "h:/documents/todo.org" "inbox")
                  "** CFILE %?
:PROPERTIES:
:change: tbd
:END:")
                 ("ts" "service request" entry
                  (file+headline "h:/documents/todo.org" "inbox")
                  "** SRFILE %?
:PROPERTIES:
:ticket: tbd
:END:"))))
  )
  )



(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook)

(defun show-filename () (interactive) (message buffer-file-name))
(global-set-key (kbd "C-x g") 'show-filename)

(cond ((eq jareds-mood 'xah)
       (require 'xah-fly-keys)
       (xah-fly-keys-set-layout "colemak-mod-dhm")
       ;; (xah-fly-keys-set-layout "colemak-mod-dh")
       ;; (xah-fly-keys-set-layout "qwerty")
       (xah-fly-keys 1)
       (require 'which-key)
       (which-key-mode))
      ((eq jareds-mood 'evil)
       (require 'evil)
       (evil-mode 1))
      ((eq jareds-mood 'boon)
       (require 'boon-colemak-dhm)
       (boon-mode)
       ;; dactyl manuform
       (define-key boon-moves-map "(" '("(-" . boon-navigate-backward))
       (define-key boon-moves-map ")" '("-)" . boon-navigate-forward)))
      ((eq jareds-mood 'devil)
       (require 'devil)
       (setq devil-lighter " \u2A63")
       (setq devil-prompt "\u2A63 %t")
       (global-devil-mode)
       (global-set-key (kbd "C-,") 'global-devil-mode))
      ((eq jareds-mood 'meow)
       (defun meow-setup ()
         (setq meow-cheatsheet-layout meow-cheatsheet-layout-colemak-dh)
         (meow-motion-overwrite-define-key
          ;; Use e to move up, n to move down.
          ;; Since special modes usually use n to move down, we only overwrite e here.
          '("e" . meow-prev)
          '("<escape>" . ignore))
         (meow-leader-define-key
          '("?" . meow-cheatsheet)
          ;; To execute the originally e in MOTION state, use SPC e.
          '("e" . "H-e")
          '("1" . meow-digit-argument)
          '("2" . meow-digit-argument)
          '("3" . meow-digit-argument)
          '("4" . meow-digit-argument)
          '("5" . meow-digit-argument)
          '("6" . meow-digit-argument)
          '("7" . meow-digit-argument)
          '("8" . meow-digit-argument)
          '("9" . meow-digit-argument)
          '("0" . meow-digit-argument))
         (meow-normal-define-key
          '("0" . meow-expand-0)
          '("1" . meow-expand-1)
          '("2" . meow-expand-2)
          '("3" . meow-expand-3)
          '("4" . meow-expand-4)
          '("5" . meow-expand-5)
          '("6" . meow-expand-6)
          '("7" . meow-expand-7)
          '("8" . meow-expand-8)
          '("9" . meow-expand-9)
          '("-" . negative-argument)
          '(";" . meow-reverse)
          '("," . meow-inner-of-thing)
          '("." . meow-bounds-of-thing)
          '("[" . meow-beginning-of-thing)
          '("]" . meow-end-of-thing)
          '("/" . meow-visit)
          '("a" . meow-append)
          '("A" . meow-open-below)
          '("b" . meow-back-word)
          '("B" . meow-back-symbol)
          '("c" . meow-change)
          '("d" . meow-delete)
          '("e" . meow-prev)
          '("E" . meow-prev-expand)
          '("f" . meow-find)
          '("g" . meow-cancel-selection)
          '("G" . meow-grab)
          '("h" . meow-left)
          '("H" . meow-left-expand)
          '("i" . meow-right)
          '("I" . meow-right-expand)
          '("j" . meow-join)
          '("k" . meow-kill)
          '("l" . meow-line)
          '("L" . meow-goto-line)
          '("m" . meow-mark-word)
          '("M" . meow-mark-symbol)
          '("n" . meow-next)
          '("N" . meow-next-expand)
          '("o" . meow-block)
          '("O" . meow-to-block)
          '("p" . meow-yank)
          '("q" . meow-quit)
          '("r" . meow-replace)
          '("s" . meow-insert)
          '("S" . meow-open-above)
          '("t" . meow-till)
          '("u" . meow-undo)
          '("U" . meow-undo-in-selection)
          '("v" . meow-search)
          '("w" . meow-next-word)
          '("W" . meow-next-symbol)
          '("x" . meow-delete)
          '("X" . meow-backward-delete)
          '("y" . meow-save)
          '("z" . meow-pop-selection)
          '("'" . repeat)
          '("<escape>" . ignore)))
       (require 'meow)
       (meow-setup)
       (meow-global-mode 1))
       ((eq jareds-mood 'ergo)
        (require 'ergoemacs-mode)
        (setq ergoemacs-theme nil) ;; Uses Standard Ergoemacs keyboard theme
        (setq ergoemacs-keyboard-layout "us") ;; Assumes QWERTY keyboard layout
        (ergoemacs-mode 1))
      (t nil))


(autoload 'scad-mode "scad-mode" "A major mode for editing OpenSCAD code." t)
(add-to-list 'auto-mode-alist '("\\.scad$" . scad-mode))

(defun spit-scad-last-expression ()
  (interactive)
  (cider-interactive-eval
    (format    
      "(require 'scad-clj.scad)
       (spit \"eval.scad\" (scad-clj.scad/write-scad %s))"
      (cider-last-sexp))))
;(define-key cider-mode-map (kbd "C-c 3") 'spit-scad-last-expression)

(define-skeleton blog-post-skeleton "a pelican blog post" "title: "
	 str "\n" (make-string (length str) ?#) "\n" (concat ":date: " (format-time-string "%Y-%m-%d %H:%M\n")) ":author: jaredj\n" ":category: " _)

; get the I-beam APL character for xah-fly-keys insert mode indicator
(set-fontset-font "fontset-default" #x2336 "APL385 Unicode")


(defun jared-open-line (&optional N)
  "Open a new line above this one, avoiding splitting. Like vi's O, not like Emacs' C-o."
  (interactive "p")
  (beginning-of-line)
  (open-line (or N 1))
  (indent-for-tab-command))
  
					; fix the s command in xah-fly-keys
(cond ((eq jareds-mood 'xah)
       (progn
         (substitute-key-definition 'open-line 'jared-open-line
				  xah-fly-key-map)
       (global-set-key (kbd "M-DEL") 'xah-fly-command-mode-activate))))

(require 'sudden-death)
(transient-mark-mode 1)

;; original at https://oremacs.com/2015/01/26/occur-dwim/
(defun my/occur-dwim-silently ()
  "Call `occur' with a symbol, or do nothing. No prompts."
  (interactive)
  (let ((sym (thing-at-point 'symbol)))
    (cond
     ((region-active-p)
      (progn
        (let ((thing-to-occur
               (buffer-substring-no-properties
                (region-beginning)
                (region-end))))
          (occur thing-to-occur))))
     ((stringp sym)
      (progn
        (occur sym)))
     (t (message "no symbol found to occur")))))

;; (defun my/projectile-multi-occur-dwim-silently ()
;;   "Call `occur' with a symbol, or do nothing. No prompts."
;;   (interactive)
;;   (let ((sym (thing-at-point 'symbol)))
;;     (cond
;;      ((region-active-p)
;;       (progn
;;         (let ((thing-to-occur
;;                (buffer-substring-no-properties
;;                 (region-beginning)
;;                 (region-end))))
;;           (multi-occur (projectile-project-buffers)
;;                        thing-to-occur))))
;;      ((stringp sym)
;;       (progn
;;         (multi-occur (projectile-project-buffers) sym)))
;;      (t (message "no symbol found to occur")))))

;;   ;; Don't ask before re-reading changed TAGS files
;;   (setq tags-revert-without-query t)
;;   ;; NO warning when loading large TAGS files
;;   (setq large-file-warning-threshold nil)
;;   (add-hook 'prog-mode-hook
;;     (lambda ()
;;       (add-hook 'after-save-hook
;;                 'counsel-etags-virtual-update-tags 'append 'local)))

;; https://stackoverflow.com/a/50167337

(when (version< emacs-version "26")
  (with-eval-after-load "ibuf-ext"
    (define-ibuffer-filter visiting-file
    "Limit current view to buffers that are visiting a file."
      (:description "visiting a file"
            :reader nil)
      (with-current-buffer buf (buffer-file-name))))
  (with-eval-after-load "ibuffer"
    (autoload 'ibuffer-filter-by-visiting-file "ibuf-ext")
    (define-key ibuffer-mode-map (kbd "/ v") 'ibuffer-filter-by-visiting-file)))

(require 'keyfreq)
(keyfreq-mode 1)
(keyfreq-autosave-mode 1)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)


(defun jlj--flip-last-name-first-in-region (begin end)
  (interactive (list (region-beginning) (region-end)))
  (save-excursion
    (save-restriction
      (narrow-to-region begin end)
      (progn
        (goto-char (point-min))
        (while (search-forward-regexp "^\\([^,\n]+\\), *\\([^\n]+\\)$" nil t)
          (replace-match "\\2 \\1"))))))

(defun jlj--obfuscate-ip (real-ip)
  (let* ((h (gnutls-hash-digest 'SHA256 real-ip))
         (n (reduce 'logxor h)))
    (format "192.0.2.%d" n)))

(defun jlj--obfuscate-fqdn (obfuscated-domain real-fqdn)
  (let* ((h (gnutls-hash-digest 'SHA256 real-fqdn))
         (names '(alpha bravo charlie delta echo foxtrot golf
                        hotel india juliett kilo lima mike
                        november oscar papa quebec romeo sierra
                        tango uniform victor whiskey xray yankee zulu))
         (part1 (nth (% (elt h 0) (length names)) names))
         (part2 (format "%d" (elt h 3)))
         (final (format "%s-%s.%s" part1 part2 obfuscated-domain)))
    final))
            
(defun jlj--obfuscate-assets (begin end)
  (interactive (list (region-beginning) (region-end)))
  (let ((replacement-kinds jlj--assets-to-obfuscate)
        replacements)
    (save-excursion
      (save-restriction
        (narrow-to-region begin end)
        (progn
          (dolist (k replacement-kinds)
            (goto-char (point-min))
            (let ((re (car k)) (fun (cadr k)))
              (while (search-forward-regexp re nil t)
                (let ((m (match-string-no-properties 0)))
                  (unless (assoc m replacements)
                    (setq replacements (cons (cons m (funcall fun m))
                                             replacements)))))))
          (dolist (r replacements)
            (goto-char (point-min))
            (while (search-forward (car r) nil t)
              (replace-match (cdr r)))))))))

(require 'ox-beamer)
(require 'ox-latex)

;; fold up applied preambles.
;; https://github.com/jaredjennings/apply-preambles
;; https://www.emacswiki.org/emacs/FoldingMode

(folding-add-to-marks-list 'clojure-mode ";; --- BEGIN" ";; --- END")
(folding-add-to-marks-list 'scad-mode ";; --- BEGIN" ";; --- END")

(defun insert-secreq-implements-clipboard-uri (fragment uri)
  "Insert a snailcrusader (Turtle) comment signifying that a document fragment secreq:implements a URI which is on the clipboard."
  ;; https://stackoverflow.com/a/9646268
  (interactive
   (list (read-string (format "Document fragment (must be unique and sane; default %s): "
                              (thing-at-point 'word))
                      nil nil (thing-at-point 'word))
         (let ((uri (cond ((string-match-p "//" (car kill-ring))
                                 (car kill-ring))
                                ((string-match-p "//" (gui-get-selection))
                                 (gui-get-selection))
                                (t ""))))
           (read-string (format "Requirement URI (default \"%s\"): " uri)
                        nil nil uri))))
  (let ((present-comment-start comment-start)
        (comment-start (concat comment-start "t")))
    (save-excursion
      (beginning-of-line)
      (open-line 1)
      (insert comment-start " <#" fragment "> " "secreq:implements" " <"
              uri "> ."))))

(multikeyfreq-mode 1)
(multikeyfreq-autosave-mode 1)
(require 'keyfreq)
(keyfreq-mode 1)
(keyfreq-autosave-mode 1)

;; find-file /ssh:somebsdhost|sudo:|iocage:jailname:/path/to/file

(require 'tramp)
(setq tramp-methods
      (cons '("iocage"
              (tramp-login-program "iocage")
              (tramp-login-args (("console") ("%h")))
              (tramp-remote-shell "/bin/sh")
              (tramp-remote-shell-login ("-l"))
              (tramp-remote-shell-args ("-c")))
            tramp-methods))


;; https://www.emacswiki.org/emacs/KillingAndYanking
(defun yank-interleaved (separator)
  "Yank the previous kill, interleaving each line of the yanked
      text with a line in current buffer.
    
    Interleaving begins on the line containing point, and moves
    downward. If point is at the beginning of the line, the yanked
    lines are inserted before the buffer lines. If it is at the end
    of the line, the yanked lines are inserted after.
    
    If the argument SEPARATOR is given, insert this between each
    buffer line and yanked line."
  ;; TODO: Make it work with active region
  (interactive "MSeparator: ")
  (let ((yank (current-kill 1 t))
        dir line)
    (if (null (string-match-p "\n" yank))
    	(yank)
      (setq dir
    	    (cond
    	     ((bolp) 'front)
    	     ((eolp) 'back)
    	     (t (user-error "Call with point at beginning or end of line"))))
      (setq yank (split-string yank "\n" t "\\s-"))
      (while (setq line (pop yank))
    	(if (eq dir 'front)
    	    (progn
    	      (beginning-of-line)
    	      (insert line)
    	      (insert separator))
    	  (end-of-line)
    	  (insert separator)
    	  (insert line))
       	(forward-line)))))

;; (global-set-key (kbd "C-x f") #'find-file-at-point)
(ffap-bindings)
(global-set-key (kbd "C-c o l") #'org-store-link)
(global-set-key (kbd "C-c o a") #'org-agenda)
(global-set-key (kbd "C-c o c") #'org-capture)
;; make frame opaque when focused, and semitransparent when unfocused
;; HA HA DISREGARD THAT I RUN EDIFF
;; (set-frame-parameter (selected-frame) 'alpha '(100 . 50))
(set-frame-parameter (selected-frame) 'alpha '(100 . 100))

(defun shuffle-lines (reverse beg end)
  "Sort lines in region randomly; REVERSE non-nil means nothing.
Interactively, REVERSE is the prefix argument, and BEG and END are the region.
Called from a program, there are three arguments:
REVERSE (non-nil means reverse order), BEG and END (region to sort).
The variable `sort-fold-case' determines nothing."
  (interactive "P\nr")
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (let ;; To make `end-of-line' and etc. to ignore fields.
	  ((inhibit-field-text-motion t))
	(sort-subr reverse 'forward-line 'end-of-line nil nil (lambda (a b) (= 0 (% (random) 2))))))))

;; this was my attempt to get emoji to show
;; it was too slow. tofu is much faster

;; ;; https://gist.github.com/alanthird/7152752d384325a83677f4a90e1e1a05
;; ;; Provided by Sebastian Urban
;; ;; More information at https://idiocy.org/emacs-fonts-and-fontsets.html

;; (set-fontset-font "fontset-default" 'adlam "Noto Sans Adlam")
;; (set-fontset-font "fontset-default" 'anatolian "Noto Sans Anatolian Hieroglyphs")
;; (set-fontset-font "fontset-default" 'arabic "Noto Sans Arabic")
;; (set-fontset-font "fontset-default" 'aramaic "Noto Sans Imperial Aramaic Regular")
;; (set-fontset-font "fontset-default" 'armenian "Noto Sans Armenian")
;; (set-fontset-font "fontset-default" 'avestan "Noto Sans Avestan")
;; (set-fontset-font "fontset-default" 'balinese "Noto Sans Balinese")
;; (set-fontset-font "fontset-default" 'bamum "Noto Sans Bamum")
;; (set-fontset-font "fontset-default" 'batak "Noto Sans Batak")
;; (set-fontset-font "fontset-default" 'bengali "Noto Sans Bengali")
;; (set-fontset-font "fontset-default" 'brahmi "Noto Sans Brahmi")
;; (set-fontset-font "fontset-default" 'buginese "Noto Sans Buginese")
;; (set-fontset-font "fontset-default" 'buhid "Noto Sans Buhid")
;; (set-fontset-font "fontset-default" 'burmese "Noto Sans Myanmar")
;; (set-fontset-font "fontset-default" 'canadian-aboriginal "Noto Sans Canadian Aboriginal")
;; (set-fontset-font "fontset-default" 'carian "Noto Sans Carian")
;; (set-fontset-font "fontset-default" 'chakma "Noto Sans Chakma")
;; (set-fontset-font "fontset-default" 'cham "Noto Sans Cham")
;; (set-fontset-font "fontset-default" 'cherokee "Noto Sans Cherokee")
;; (set-fontset-font "fontset-default" 'cjk-misc "Noto Sans CJK SC Regular")
;; (set-fontset-font "fontset-default" 'coptic "Noto Sans Coptic Regular")
;; (set-fontset-font "fontset-default" 'cuneiform "Noto Sans Cuneiform")
;; (set-fontset-font "fontset-default" 'cypriot-syllabary "Noto Sans Cypriot")
;; (set-fontset-font "fontset-default" 'deseret "Noto Sans Deseret")
;; (set-fontset-font "fontset-default" 'devanagari "Noto Sans Devanagari")
;; (set-fontset-font "fontset-default" 'egyptian "Noto Sans Egyptian Hieroglyphs Regular")
;; (set-fontset-font "fontset-default" 'ethiopic "Noto Sans Ethiopic")
;; (set-fontset-font "fontset-default" 'georgian "Noto Sans Georgian")
;; (set-fontset-font "fontset-default" 'glagolitic "Noto Sans Glagolitic")
;; (set-fontset-font "fontset-default" 'gothic "Noto Sans Gothic")
;; (set-fontset-font "fontset-default" 'gujarati "Noto Sans Gujarati")
;; (set-fontset-font "fontset-default" 'gurmukhi "Noto Sans Gurmukhi")
;; (set-fontset-font "fontset-default" 'han "Noto Sans CJK SC Regular")
;; (set-fontset-font "fontset-default" 'han "Noto Sans CJK TC Regular" nil 'append)
;; (set-fontset-font "fontset-default" 'hangul "Noto Sans CJK KR Regular")
;; (set-fontset-font "fontset-default" 'hanunoo "Noto Sans Hanunoo")
;; (set-fontset-font "fontset-default" 'hebrew "Noto Sans Hebrew")
;; (set-fontset-font "fontset-default" 'inscriptional-pahlavi "Noto Sans Inscriptional Pahlavi")
;; (set-fontset-font "fontset-default" 'inscriptional-parthian "Noto Sans Inscriptional Parthian")
;; (set-fontset-font "fontset-default" 'javanese "Noto Sans Javanese")
;; (set-fontset-font "fontset-default" 'kaithi "Noto Sans Kaithi")
;; (set-fontset-font "fontset-default" 'kana "Noto Sans CJK JP Regular")
;; (set-fontset-font "fontset-default" 'kannada "Noto Sans Kannada")
;; (set-fontset-font "fontset-default" 'kayah-li "Noto Sans Kayah Li")
;; (set-fontset-font "fontset-default" 'kharoshthi "Noto Sans Kharoshthi")
;; (set-fontset-font "fontset-default" 'khmer "Noto Sans Khmer")
;; (set-fontset-font "fontset-default" 'lao "Noto Sans Lao")
;; (set-fontset-font "fontset-default" 'lepcha "Noto Sans Lepcha")
;; (set-fontset-font "fontset-default" 'limbu "Noto Sans Limbu")
;; (set-fontset-font "fontset-default" 'linear-b "Noto Sans Linear B")
;; (set-fontset-font "fontset-default" 'lisu "Noto Sans Lisu")
;; (set-fontset-font "fontset-default" 'lycian "Noto Sans Lycian")
;; (set-fontset-font "fontset-default" 'lydian "Noto Sans Lydian")
;; (set-fontset-font "fontset-default" 'malayalam "Noto Sans Malayalam")
;; (set-fontset-font "fontset-default" 'mandaic "Noto Sans Mandaic")
;; (set-fontset-font "fontset-default" 'meetei-mayek "Noto Sans Meetei Mayek")
;; (set-fontset-font "fontset-default" 'mongolian "Noto Sans Mongolian")
;; (set-fontset-font "fontset-default" 'tai-lue "Noto Sans New Tai Lue Regular")
;; (set-fontset-font "fontset-default" 'nko "Noto Sans NKo Regular")
;; (set-fontset-font "fontset-default" 'ogham "Noto Sans Ogham")
;; (set-fontset-font "fontset-default" 'ol-chiki "Noto Sans Ol Chiki")
;; (set-fontset-font "fontset-default" 'old-italic "Noto Sans Old Italic Regular")
;; (set-fontset-font "fontset-default" 'old-persian "Noto Sans Old Persian Regular")
;; (set-fontset-font "fontset-default" 'old-south-arabian "Noto Sans Old South Arabian Regular")
;; (set-fontset-font "fontset-default" 'old-turkic "Noto Sans Old Turkic")
;; (set-fontset-font "fontset-default" 'oriya "Noto Sans Oriya")
;; (set-fontset-font "fontset-default" 'osage "Noto Sans Osage")
;; (set-fontset-font "fontset-default" 'osmanya "Noto Sans Osmanya")
;; (set-fontset-font "fontset-default" 'phags-pa "Noto Sans Phags Pa")
;; (set-fontset-font "fontset-default" 'phoenician "Noto Sans Phoenician")
;; (set-fontset-font "fontset-default" 'rejang "Noto Sans Rejang")
;; (set-fontset-font "fontset-default" 'runic "Noto Sans Runic")
;; (set-fontset-font "fontset-default" 'samaritan "Noto Sans Samaritan")
;; (set-fontset-font "fontset-default" 'saurashtra "Noto Sans Saurashtra")
;; (set-fontset-font "fontset-default" 'shavian "Noto Sans Shavian")
;; (set-fontset-font "fontset-default" 'sinhala "Noto Sans Sinhala")
;; (set-fontset-font "fontset-default" 'sinhala-archaic-number "Noto Sans Sinhala")
;; (set-fontset-font "fontset-default" 'sundanese "Noto Sans Sundanese")
;; (set-fontset-font "fontset-default" 'syloti-nagri "Noto Sans Syloti Nagri")
;; ;;(set-fontset-font "fontset-default" 'syriac "Noto Sans Syriac Eastern")
;; (set-fontset-font "fontset-default" 'syriac "Noto Sans Syriac Estrangela")
;; ;;(set-fontset-font "fontset-default" 'syriac "Noto Sans Syriac Western")
;; (set-fontset-font "fontset-default" 'tagalog "Noto Sans Tagalog")
;; (set-fontset-font "fontset-default" 'tagbanwa "Noto Sans Tagbanwa")
;; (set-fontset-font "fontset-default" 'tai-le "Noto Sans Tai Le")
;; (set-fontset-font "fontset-default" 'tai-tham "Noto Sans Tai Tham")
;; (set-fontset-font "fontset-default" 'tai-viet "Noto Sans Tai Viet")
;; (set-fontset-font "fontset-default" 'tamil "Noto Sans Tamil")
;; (set-fontset-font "fontset-default" 'telugu "Noto Sans Telugu")
;; (set-fontset-font "fontset-default" 'thaana "Noto Sans Thaana")
;; (set-fontset-font "fontset-default" 'thai "Noto Sans Thai")
;; (set-fontset-font "fontset-default" 'tibetan "Noto Sans Tibetan")
;; (set-fontset-font "fontset-default" 'tifinagh "Noto Sans Tifinagh")
;; (set-fontset-font "fontset-default" 'ugaritic "Noto Sans Ugaritic")
;; (set-fontset-font "fontset-default" 'vai "Noto Sans Vai")
;; (set-fontset-font "fontset-default" 'yi "Noto Sans Yi")
;; (set-fontset-font "fontset-standard" 'symbol "Noto Color Emoji")


(require 'no-spam)

;; Use default parameter values.
(no-spam-add-repeat-delay next-line)

;; Set a 10-second repeat delay for `forward-char'.
(no-spam-add-repeat-delay forward-char 10)

;; Have the delay not apply in the minibuffer.
(no-spam-add-repeat-delay backward-char nil minibufferp)

;; Have `forward-paragraph' and `backward-paragraph' share a delay.
(no-spam-add-repeat-delay (forward-paragraph backward-paragraph))

;; Enable the repeat delays.
(no-spam-mode)

;; unassociate .sch files with scheme: i edit lepton-schematic files which are not scheme
(setq auto-mode-alist (cons '("\\.\\(scm\\|stk\\|ss\\)\\'" . scheme-mode)
                            (assoc-delete-all ".sch" auto-mode-alist #'string-match)))


(setq slime-lisp-implementations
      '((sbcl
         ("/usr/bin/sbcl"))
        (clasp
         ("/usr/local/bin/clasp"))))
(setq inferior-lisp-program "/usr/bin/sbcl")

(setq mastodon-instance-url "https://emacs.ch/"
      mastodon-active-user "jaredj")

(defun make-ci-regex-region (start end)
  "Make the string in the region into a case-insensitive regex that will match that string in any case."
  (interactive "r")
  (if (> (point) (mark)) (exchange-point-and-mark))
  (insert-char ?/)
  (cl-do () ((>= (point) (mark)))
    (when (eq ?w (char-syntax (following-char)))
      (insert-char ?\[)
      (insert-char (following-char))
      (upcase-char 1)
      (forward-char)
      (insert-char ?\])))
  (insert-char ?/))

(defun decode-hex-string (hex-string)
  (let ((res nil))
    (dotimes (i (/ (length hex-string) 2) (apply #'concat (reverse res)))
      (let ((hex-byte (substring hex-string (* 2 i) (* 2 (+ i 1)))))
        (push (format "%c" (string-to-number hex-byte 16)) res)))))
(defun hex-decode-region (start end)
  (interactive "r")
  (replace-region-contents start end
                           (lambda ()
                             (decode-hex-string (buffer-string)))))