dotfiles/.doom.d/config.el

172 lines
6.4 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:
(if (eq system-type 'darwin)
(setq doom-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 14)
doom-variable-pitch-font (font-spec :family "Rubik")
doom-unicode-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 14)
doom-big-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 14))
(setq doom-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 28)
doom-variable-pitch-font (font-spec :family "Rubik")
doom-unicode-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 28)
doom-big-font (font-spec :family "JetBrainsMono Nerd Font Mono" :size 28)))
;; 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)))))
;; Set Firefox as default web browser
(if (eq system-type 'darwin)
(setq browse-url-browser-function 'browse-url-default-macosx-browser)
(setq browse-url-browser-function 'browse-host-firefox))
(defun browse-host-firefox (url &rest ignore)
"Browse URL with the host's Firefox using distrobox-exec."
(interactive "sURL: ")
(shell-command (concat "distrobox-host-exec firefox " url)))
;; 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
(setq mastodon-instance-url "https://fosstodon.org"
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))
;; use gemtext2md to convert gmi to md and move to zola reads site directory
(defun gemini-to-zola-reads ()
"Convert gmi to md, send to zola reads site content directory, and open file
to edit frontmatter."
(interactive)
(setq filename-prefix "~/Nextcloud/sites/reads.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"))
(async-shell-command (concat "zola build -o ~/public/html"))))
;; Build zola reads site
(defun build-zola-reads ()
"Build zola reads site."
(interactive)
(let ((default-directory "~/Nextcloud/sites/reads.hyperreal.coffee"))
(async-shell-command (concat "zola build -o ~/public/reads"))))