Skip to content

Instantly share code, notes, and snippets.

@Gijs-Koot
Last active October 1, 2021 12:59
Show Gist options
  • Save Gijs-Koot/a33ac9344340529406c2550857c91580 to your computer and use it in GitHub Desktop.
Save Gijs-Koot/a33ac9344340529406c2550857c91580 to your computer and use it in GitHub Desktop.
(defvar gh-publish-base-dir "~/Documents/project/Gijs-Koot.github.io/"
"Base directory of publishing project")
(defun gh-publish-fix-image-links (fn)
(with-temp-file fn
(progn
(insert-file-contents fn)
(goto-char (point-min))
(while (re-search-forward "src=\"\\(images/[a-z]+\.[a-z]+\\)\"" nil t)
(replace-match (concat "src=\"/assets/" (match-string 1) "\"")))
)))
(defun gh-publish-hook-fix-image-links (orig-fn produced-fn)
(message (concat "Fixing links in " produced-fn))
(gh-publish-fix-image-links produced-fn)
)
(define-minor-mode gh-publish-mode
"Helper stuff for publishing to blog"
:lighter " GH"
:keymap `((,(kbd "C-q C-p") . org-publish-all))
(if gh-publish-mode
(add-hook
'org-publish-after-publishing-hook 'gh-publish-hook-fix-image-links)
(remove-hook 'org-publish-after-publishing-hook 'gh-publish-hook-fix-image-links)
)
)
;; BASE CUSTOMIZATION
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(global-set-key (kbd "\C-cb") 'browse-url-at-point)
(global-set-key (kbd "<f5>") 'revert-buffer)
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
;; UTF-8 support - see http://www.skybert.net/emacs/how-to-get-unicode-in-the-terminal/
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(setq-default left-margin-width 1 right-margin-width 1)
(delete-selection-mode 1)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'image-mode-hook 'auto-revert-mode)
(ido-mode t)
(setq ido-everywhere t)
(setq ido-enable-flex-matching t)
(set-frame-font "Hack")
(setq sql-connection-alist
'(("octocvdb"
(sql-product 'postgres)
(sql-user "octocvdb-dev")
(sql-database "octocvdb")
(sql-server "woco.c0ua58qw1jej.eu-central-1.rds.amazonaws.com"))))
;; PACKAGES
(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/"))
package-archive-priorities '(("melpa-stable" . 1)))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package))
;; USE-PACKAGE
(require 'use-package)
(use-package nano-theme
:ensure t)
(use-package python
:ensure t
;; :hook (python-mode . lsp-deferred)
:custom
(python-shell-interpreter "ipython3")
(python-shell-interpreter-args "-i --simple-prompt")
;; (dap-python-executable "python3")
;; (dap-python-debugger 'debugpy)
:config
;; (require 'dap-python)
)
(use-package ob-ess-julia
:ensure t
:config
;; Add ess-julia into supported languages:
(org-babel-do-load-languages 'org-babel-load-languages
(append org-babel-load-languages
'((ess-julia . t))))
;; Link this language to ess-julia-mode (although it should be done by default):
(setq org-src-lang-modes
(append org-src-lang-modes '(("ess-julia" . ess-julia)))))
(use-package ob-ipython
:ensure t)
(use-package org
:ensure org-plus-contrib
:config
(setq org-confirm-babel-evaluate nil)
(setq org-log-done 'time)
(setq org-agenda-include-diary nil)
(org-babel-do-load-languages
'org-babel-load-languages
'((shell . t)
(python . t)
(ipython . t)
(julia . t)
))
:bind ("C-c a" . 'org-agenda)
:hook (org-babel-after-execute-hook . org-redisplay-inline-images))
(use-package org-roam
:ensure t
:init
(setq org-roam-directory "~/Documents/notes/roam")
:hook (after-init . org-roam-mode)
)
(use-package ox-reveal
:ensure t
:config
(setq org-reveal-root "https://revealjs.com/")
)
(use-package elpy
:ensure t
:init
(pyvenv-mode 1)
(pyvenv-tracking-mode 1)
:config
(setq python-check-command "black")
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "console --simple-prompt"
;; python-shell-prompt-regexp "In \\[[0-9]+\\]: "
;; python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
;; python-shell-prompt-detect-failure-warning nil)
;; (add-to-list 'python-shell-completion-native-disabled-interpreters
;; "jupyter")
(setq elpy-rpc-python-command "python3")
(setq elpy-test-runner 'elpy-test-pytest-runner)
;; :hook (python-mode . elpy-enable)
;; :hook (python-mode . pyvenv-mode)
)
(use-package multiple-cursors :ensure t)
(use-package yaml-mode :ensure t)
(use-package company
:ensure t
:after lsp-mode)
(use-package company-quickhelp
:ensure t
:config (company-quickhelp-mode))
(use-package json-mode :ensure t)
(use-package magit :ensure t)
(use-package window-numbering
:ensure t
:hook (after-init . window-numbering-mode))
(use-package expand-region
:ensure t
:bind ("C-=" . er/expand-region))
(use-package smartparens-config
;; see https://ebzzry.io/en/emacs-pairs/
:ensure smartparens
:config (progn (show-smartparens-global-mode t) (smartparens-global-mode t))
:hook (inferior-python-mode-hook . turn-off-smartparens-mode)
)
(use-package which-key
:ensure t
:config (which-key-mode))
(use-package modus-themes
:ensure t)
(use-package doom-themes
:ensure t
:config
(setq custom-safe-themes
'("b35a14c7d94c1f411890d45edfb9dc1bd61c5becd5c326790b51df6ebf60f402" "f0dc4ddca147f3c7b1c7397141b888562a48d9888f1595d69572db73be99a024" "6b2636879127bf6124ce541b1b2824800afc49c6ccd65439d6eb987dbf200c36" default)))
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(use-package projectile
:ensure t
:custom
((projectile-completion-system 'ivy))
:config
(define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)
(projectile-mode 1)
(setq projectile-switch-project-action 'projectile-dired)
(setq projectile-globally-ignored-directories
'(".git" "venv")))
(use-package counsel-projectile
:ensure t
:config (counsel-projectile-mode))
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
:init
(progn
(setq dashboard-items '((recents . 10) (projects 5) (bookmarks 3) (agenda 10))
)))
(use-package treemacs :ensure t
:bind (:map global-map ([f8] . treemacs))
:init
(defun treemacs-custom-filter (file _)
(or (s-ends-with? ".pyc" file)
(string= "__pycache__" file)
(string= ".vscode" file)
(string= "venv" file)
(string= ".venv" file)
(s-ends-with? "egg-info" file)
(string= ".pytest_cache" file)
))
:config
(push #'treemacs-custom-filter treemacs-ignored-file-predicates))
(use-package lsp-mode
:ensure t
:commands lsp
:config
(setq lsp-completion-enable nil)
)
(use-package lsp-ui
:ensure t)
(use-package lsp-julia
:ensure t
:config
(setq lsp-julia-default-environment "~/.julia/environments/v1.5"))
(use-package julia-repl
:ensure t
:config
:hook (julia-mode-hook . julia-repl-mode))
(use-package vterm
:ensure t
:bind (:map global-map ("C-x t" . 'vterm)))
(use-package counsel
:ensure t
:init
(ivy-mode 1)
(counsel-mode 1)
:bind (:map global-map ("C-x C-f" . 'counsel-find-file)
("C-s" . 'swiper))
)
(use-package pdf-tools
:ensure t
:config
(pdf-tools-install)
:hook (pdf-view-mode-hook 'image-mode))
(use-package excorporate
:ensure t
:config
(setq excorporate-configuration (quote ("g.koot@octo.nu" . "https://outlook.office365.com/EWS/Exchange.asmx"))))
(load "~/.emacs.d/agenda-files")
(load "~/.emacs.d/gh-publish")
(put 'downcase-region 'disabled nil)
;; notifications
(use-package notifications)
(defvar pommodoro-timeout "10" "Duration of a pommodoro timer")
(defvar pommodoro-current-timer nil "The current pommodoro timer")
(defun pommodoro--notify (message)
"Notify of a message"
(shell-command
(format "notify-send -i messagebox_info -u critical 'Pommodoro done' %s" message)))
(defun pommodoro--set-timer (message seconds)
"Set a timer for a message"
(setq pommodoro-current-timer
(run-at-time seconds nil #'pommodoro-notify message)))
(defun pommodoro--check-timer ()
;; TODO I think this is broken
(if (and pommodoro-current-timer (time-less-p (current-time)
(timer--time pommodoro-current-timer)))
(if (yes-or-no-p "There is a current pommodoro running, do you want to cancel it? ")
(cancel-timer pommodoro-current-timer) (throw 'cancel t))))
(defun pommodoro-start-timer ()
"Start a pommodoro timer which shows a notification after 25 minutes"
(interactive)
(catch 'cancel
(progn
;; TODO add timer check
(pommodoro--set-timer (read-string "Task description: ") (* 25 60)))))
(defun pommodoro-show-timer ()
(interactive)
(message "Pommodoro done at %s"
(format-time-string "%T" (timer--time pommodoro-current-timer))))
(global-set-key (kbd "<f2>") #'pommodoro-start-timer)
(global-set-key (kbd "<f3>") #'pommodoro-show-timer)
(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.
'(custom-safe-themes
'("fe666e5ac37c2dfcf80074e88b9252c71a22b6f5d2f566df9a7aa4f9bea55ef8" "bde7af9e749d26cbcbc3e3ac2ac9b13d52aa69b6148a8d6e5117f112f2797b42" "96c56bd2aab87fd92f2795df76c3582d762a88da5c0e54d30c71562b7bf9c605" "1c082c9b84449e54af757bcae23617d11f563fc9f33a832a8a2813c4d7dfb652" "93a0885d5f46d2aeac12bf6be1754faa7d5e28b27926b8aa812840fe7d0b7983" "3a3de615f80a0e8706208f0a71bbcc7cc3816988f971b6d237223b6731f91605" "ecba61c2239fbef776a72b65295b88e5534e458dfe3e6d7d9f9cb353448a569e" "d2e9c7e31e574bf38f4b0fb927aaff20c1e5f92f72001102758005e53d77b8c9" "b54826e5d9978d59f9e0a169bbd4739dd927eead3ef65f56786621b53c031a7c" "a3fa4abaf08cc169b61dea8f6df1bbe4123ec1d2afeb01c17e11fdc31fc66379" "b35a14c7d94c1f411890d45edfb9dc1bd61c5becd5c326790b51df6ebf60f402" "f0dc4ddca147f3c7b1c7397141b888562a48d9888f1595d69572db73be99a024" "6b2636879127bf6124ce541b1b2824800afc49c6ccd65439d6eb987dbf200c36" default))
'(package-selected-packages
'(nano-theme nano-emacs modus-themes ob-ess-julia ob-julia ox-publish python-mode modus-vivendi-theme ewal-doom-themes counsel-projectile ob-ipython excorporate htmlize org-tempo ox-reveal org-roam wgrep pdf-tools yaml-mode window-numbering which-key vterm virtualenv use-package smartparens org-plus-contrib multiple-cursors magit lsp-ui lsp-julia julia-repl json-mode expand-region elpy doom-themes doom-modeline dashboard counsel company-quickhelp))
'(safe-local-variable-values
'((org-publish-project-alist
("org-posts" :base-directory "/home/gijs/Documents/project/Gijs-Koot.github.io/_org" :base-extension "org" :publishing-directory "/home/gijs/Documents/project/Gijs-Koot.github.io/" :publishing-function org-html-publish-to-html :body-only t :html-extension "md" :recursive t)
("org-images" :base-directory "/home/gijs/Documents/project/Gijs-Koot.github.io/_org/_posts/images" :base-extension "png\\|jpg" :publishing-directory "/home/gijs/Documents/project/Gijs-Koot.github.io/assets/images" :recursive t :publishing-function org-publish-attachment))
(eval progn
(setq pyvenv-activate
(concat
(projectile-project-root)
".venv"))
(elpy-enable))
(eval progn
(message "Hello")
(setq pyvenv-activate
(concat
(projectile-project-root)
".venv"))
(elpy-enable)
(message "Done"))
(eval progn
(message "Hello")
(setq pyvenv-activate
(concat
(projectile-project-root)
".venv"))
(message "Done"))
(eval progn
(message "Hello")
(setq pyvenv-activate
(concat
(projectile-project-root)
".venv")))
(eval progn
(setq pyvenv-activate
(concat
(projectile-project-root)
".venv")))
(eval setq pyvenv-activate
(concat
(projectile-project-root)
".venv"))
(pyvenv-activate . ~/Documents/woco-model-training/venv)
(pyvenv-activate quote venv)
(projectile-project-test-cmd . pytest)
(eval setq pyvenv-activate
(concat
(projectile-project-root)
"venv")))))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment