From b09b6ab15e45a3cb096e9dca9171c305235c5d60 Mon Sep 17 00:00:00 2001 From: opfez Date: Sat, 17 Jul 2021 19:35:14 +0200 Subject: [PATCH] add org-roam stuff, add email --- custom.el | 38 ++++++++++++++++++++++++++++++++++++-- init.el | 17 +++++++++++++++++ packages.el | 10 +++++++++- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/custom.el b/custom.el index 6963b9d..a956ec9 100644 --- a/custom.el +++ b/custom.el @@ -131,14 +131,48 @@ (sleep-for 1) (sly-connect "localhost" 4005)) +(defmacro fez/save-buffer-excursion (&rest body) + (declare (indent defun)) + (let ((original-buffer (gensym))) + `(let ((,original-buffer (current-buffer))) + ,@body + (switch-to-buffer ,original-buffer)))) + +(defun fez/goto-first-occurrence (str) + (goto-char (point-min)) + (search-forward-regexp str) + (beginning-of-thing 'symbol)) + +;; https://emacs.stackexchange.com/a/33709 +(defmacro with-keybinding (map key command &rest body) + `(let* ((map ,map) + (key ,key) + (newcommand ,command) + (prevbinding (lookup-key map key))) + (unwind-protect + (progn + (define-key map key newcommand) + ,@body) + (define-key map key prevbinding)))) + +(defun fez/org-roam-new-note () + "Creates a new org-roam note, and adds an entry to that note in my index.org file." + (interactive) + (let ((category (read-string "Category: "))) + (find-file (concat org-roam-directory "/index.org")) + (fez/goto-first-occurrence (concat "^\* " category)) + (end-of-line) + (newline) + (org-cycle) + (with-keybinding selectrum-minibuffer-map (kbd "SPC") (lambda () (interactive (insert-char ?-))) + (org-roam-insert)))) + ;; Eshell convinience commands. (defalias 'open 'find-file-other-window) (defalias 'clean 'eshell/clear-scrollback) ;;; Keybinds - - ;; C-x C-z and C-z are normally mapped to suspend-frame, an absolutely useless function. ;; Unbind them before making the keybind useful. (global-unset-key (kbd "C-x C-z")) diff --git a/init.el b/init.el index e78cae1..3d7b8f5 100644 --- a/init.el +++ b/init.el @@ -45,6 +45,23 @@ (?\" . ?\"))) (electric-pair-mode t) +(setq-default rmail-display-summary t) + +(setq + send-mail-function 'smtpmail-send-it + rmail-preserve-inbox 1 + rmail-delete-after-output 1 + rmail-mail-new-frame 1 + rmail-mime-prefer-html nil + rmail-file-name "~/mail/inbox" + rmail-primary-inbox-list '("~/mail/inboxes/disroot") + rmail-default-file "~/mbox/archive" + rmail-secondary-file-directory "~/mail" + message-default-headers "Fcc: ~/mail/sent" + user-full-name "opfez" + user-mail-address "opfez@disroot.org" + message-signature "") + ;; C configuration (setq c-default-style "linux" c-basic-offset 4) diff --git a/packages.el b/packages.el index c2b4dbe..c0395f7 100644 --- a/packages.el +++ b/packages.el @@ -169,7 +169,8 @@ :ensure t :bind ("C-c o i" . org-roam-jump-to-index) - :config + ("C-c o n" . fez/org-roam-new-note) + :init (setq org-roam-directory "~/Documents/org-roam")) ;; better shell-command @@ -178,6 +179,13 @@ :config (global-set-key (kbd "M-!") 'shell-command+)) +;; Jump to definitions without tags +(use-package dumb-jump + :ensure t + :init + (add-hook 'xref-backend-functions 'dumb-jump-xref-activate) + (setq xref-show-definitions-function 'xref-show-definitions-completing-read)) + ;; Snippets (use-package yasnippet :ensure t