dotfiles/doom/.doom.d/config.el

164 lines
6.0 KiB
EmacsLisp
Raw Normal View History

2022-11-05 20:57:02 +01:00
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Jeffrey Serio"
user-mail-address "hyperreal@fedoraproject.org")
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
2022-11-24 07:10:34 +01:00
(setq doom-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 28)
doom-variable-pitch-font (font-spec :family "Rubik")
doom-unicode-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 28)
doom-big-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 28))
;; (setq doom-font (font-spec :family "Iosevka" :size 30)
;; doom-variable-pitch-font (font-spec :family "Rubik")
;; doom-unicode-font (font-spec :family "Iosevka" :size 30)
;; doom-big-font (font-spec :family "Iosevka" :size 30))
2022-11-05 20:57:02 +01:00
;; Use catppuccin-mocha theme
(setq doom-theme 'catppuccin-mocha)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/Nextcloud/org/")
;; Set bpython as Python shell interpreter
(add-hook! python-mode-hook
(setq python-shell-interpreter "bpython"))
;; Make vterm open in another window
(setq vterm-other-window 1)
;; Keybinding to kill-whole-line
(global-set-key (kbd "M-9") 'kill-whole-line)
;; Popup rule for yasnippet
(defun yas-popup-isearch-prompt (prompt choices &optional display-fn)
(when (featurep 'popup)
(popup-menu*
(mapcar
(lambda (choice)
(popup-make-item
(or (and display-fn (funcall display-fn choice))
choice)
:value choice))
choices)
:prompt prompt
;; start isearch mode immediately
:isearch t
)))
(setq yas-prompt-functions '(yas-popup-isearch-prompt yas-maybe-ido-prompt yas-completing-prompt yas-no-prompt))
;; Copy all or text selection
(defun xah-copy-all-or-region ()
"Put the whole buffer content to `kill-ring', or text selection if there's one.
Respects `narrow-to-region'.
URL `https://ergomacs.org/emacs/emacs_copy_cut_all_or_region.html'
Version 2015-08-22"
(interactive)
(if (use-region-p)
(progn
(kill-new (buffer-substring (region-beginning) (region-end)))
(message "Text selection copied."))
(progn
(kill-new (buffer-string))
(message "Buffer content copied."))))
;; Cut all or text selection
(defun xah-cut-all-or-region ()
"Cut the whole buffer content to `kill-ring', or text selection if there's one.
Respects `narrow-to-region'.
URL `https://ergomacs.org/emacs/emacs_copy_cut_all_or_region.html'
Version 2015-08-22"
(interactive)
(if (use-region-p)
(progn
(kill-new (buffer-substring (region-beginning) (region-end)))
(delete-region (region-beginning) (region-end)))
(progn
(kill-new (buffer-string))
(delete-region (point-min) (point-max)))))
2022-11-24 07:10:34 +01:00
;; open URL in Firefox
(defun browse-host-firefox (url &rest ignored)
2022-11-05 20:57:02 +01:00
"Browse URL with the host's Firefox using distrobox-exec."
(interactive "sURL: ")
(shell-command (concat "distrobox-host-exec firefox " url)))
2022-11-24 07:10:34 +01:00
(setq browse-url-browser-function 'browse-host-firefox)
2022-11-05 20:57:02 +01:00
;; after copy Ctrl+c in Linux X11, you can paste by `yank' in emacs
(setq select-enable-clipboard t)
;; after mouse selection copy in X11, you can paste by `yank' in emacs
(setq select-enable-primary t)
;; set keybinding for paste
(global-set-key (kbd "C-S-V") #'clipboard-yank)
;; Smart home key
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line.
Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
(interactive "^")
(let ((oldpos (point)))
(back-to-indentation)
(and (= oldpos (point))
(beginning-of-line))))
(global-set-key (kbd "<home>") 'smart-beginning-of-line)
(global-set-key (kbd "<end>") 'end-of-line)
;; Autoformat on save
(setq +format-on-save-enabled-modes
'(emacs-lisp-mode
python-mode))
(setq-hook! 'python-mode-hook +format-with 'black)
;; org-mode, close items with timestamp
(setq org-log-done 'time)
;; open Emacs in a maxmimized window
(add-to-list 'default-frame-alist '(fullscreen . maximized))
;; mastodon
2022-11-24 07:10:34 +01:00
(setq mastodon-instance-url "https://mastodon.hyperreal.coffee"
2022-11-05 20:57:02 +01:00
mastodon-active-user "hyperreal")
;; use gemtext2md to convert gmi to md and move to zola main site directory
(defun gemini-to-zola-main ()
"Convert gmi to md, send to zola main site content directory, and open file
to edit frontmatter."
(interactive)
(setq filename-prefix "~/Nextcloud/sites/hyperreal.coffee/content/")
(setq filename (concat filename-prefix (file-name-base buffer-file-name) ".md"))
(async-shell-command (concat "gemtext2md < " (buffer-file-name) " > " filename))
(find-file filename))
;; Build zola main site
(defun build-zola-main ()
"Build zola main site."
(interactive)
(let ((default-directory "~/Nextcloud/sites/hyperreal.coffee"))
2022-11-24 07:10:34 +01:00
(shell-command (concat "zola build -o ~/public/html"))))
2022-11-05 20:57:02 +01:00
2022-11-24 07:10:34 +01:00
;; rsync the contents of ~/public to web server
(defun rsync-zola-site ()
"Rsync the contents of ~/public to web server."
2022-11-05 20:57:02 +01:00
(interactive)
2022-11-24 07:10:34 +01:00
(shell-command (concat "rsync -aAX ~/public/ jas@raspberrypi.local:/home/jas/public")))
;; keybinds for evil-nerd-commenter
(global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
(global-set-key (kbd "C-c l") 'evilnc-quick-comment-or-uncomment-to-the-line)
(global-set-key (kbd "C-c c") 'evilnc-copy-and-comment-lines)
(global-set-key (kbd "C-c p") 'evilnc-comment-or-uncomment-paragraphs)