158 lines
6.7 KiB
EmacsLisp
158 lines
6.7 KiB
EmacsLisp
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
|
|
|
|
;; Place your private configuration here! Remember, you do not need to run 'doom
|
|
;; sync' after modifying this file!
|
|
|
|
|
|
;; Some functionality uses this to identify you, e.g. GPG configuration, email
|
|
;; clients, file templates and snippets.
|
|
(setq user-full-name "Willem van den Ende"
|
|
user-mail-address "redacted@example.invalid")
|
|
|
|
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
|
|
;; are the three important ones:
|
|
;;
|
|
;; + `doom-font'
|
|
;; + `doom-variable-pitch-font'
|
|
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
|
|
;; presentations or streaming.
|
|
;;
|
|
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
|
|
;; font string. You generally only need these two:
|
|
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
|
|
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
|
|
|
|
;; There are two ways to load a theme. Both assume the theme is installed and
|
|
;; available. You can either set `doom-theme' or manually load a theme with the
|
|
;; `load-theme' function. This is the default:
|
|
(setq doom-theme 'doom-one)
|
|
|
|
;; org-roam customizations
|
|
;; 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 "~/MyDocuments/qwan/essays/willem")
|
|
(setq org-roam-directory "~/MyDocuments/qwan/essays/willem")
|
|
|
|
;; fix pdflatex for pdf export
|
|
(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))
|
|
|
|
;; html export configuration, assuming use in a CMS or static site gerator that
|
|
;; takes care of the layout
|
|
;; https://stackoverflow.com/questions/47508315/emacs-org-mode-export-to-html-without-syntax-highlighting
|
|
(setq org-html-htmlize-output-type `nil)
|
|
(setq org-html-preamble `nil)
|
|
(setq org-html-postamble `nil)
|
|
|
|
;; make screenshot and paste
|
|
;; https://zzamboni.org/post/how-to-insert-screenshots-in-org-documents-on-macos/
|
|
|
|
|
|
;; 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 t)
|
|
|
|
|
|
;; Here are some additional functions/macros that could help you configure Doom:
|
|
;;
|
|
;; - `load!' for loading external *.el files relative to this one
|
|
;; - `use-package!' for configuring packages
|
|
;; - `after!' for running code after a package has loaded
|
|
;; - `add-load-path!' for adding directories to the `load-path', relative to
|
|
;; this file. Emacs searches the `load-path' when you load packages with
|
|
;; `require' or `use-package'.
|
|
;; - `map!' for binding new keys
|
|
;;
|
|
;; To get information about any of these functions/macros, move the cursor over
|
|
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
|
|
;; This will open documentation for it, including demos of how they are used.
|
|
;;
|
|
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
|
|
;; they are implemented.
|
|
;;
|
|
|
|
|
|
(setq evil-move-cursor-back nil)
|
|
|
|
;;
|
|
;; from https://github.com/org-roam/org-roam-server/issues/115
|
|
;; but modified the open to browse-url-button-open-url
|
|
(use-package org-roam-server
|
|
:config
|
|
(setq org-roam-server-host "127.0.0.1"
|
|
org-roam-server-port 8427
|
|
org-roam-server-authenticate nil
|
|
org-roam-server-export-inline-images t
|
|
org-roam-server-serve-files nil
|
|
org-roam-server-served-file-extensions '("pdf" "mp4" "ogv")
|
|
org-roam-server-network-poll t
|
|
org-roam-server-network-arrows nil
|
|
org-roam-server-network-label-truncate t
|
|
org-roam-server-network-label-truncate-length 60
|
|
org-roam-server-network-label-wrap-length 20))
|
|
|
|
(defun org-roam-server-open ()
|
|
"Ensure the server is active, then open the roam graph."
|
|
(interactive)
|
|
(org-roam-server-mode 1)
|
|
(browse-url-button-open-url (format "http://localhost:%d" org-roam-server-port)))
|
|
|
|
(after! org-roam
|
|
(org-roam-server-mode))
|
|
|
|
;; two functions from:
|
|
;; https://zzamboni.org/post/my-emacs-configuration-with-commentary/#reformatting-an-org-buffer
|
|
(defun zz/org-reformat-buffer ()
|
|
(interactive)
|
|
(when (y-or-n-p "Really format current buffer? ")
|
|
(let ((document (org-element-interpret-data (org-element-parse-buffer))))
|
|
(erase-buffer)
|
|
(insert document)
|
|
(goto-char (point-min)))))
|
|
|
|
(defun afs/org-remove-link ()
|
|
"Replace an org link by its description or if empty its address"
|
|
(interactive)
|
|
(if (org-in-regexp org-link-bracket-re 1)
|
|
(let ((remove (list (match-beginning 0) (match-end 0)))
|
|
(description (if (match-end 3)
|
|
(org-match-string-no-properties 3)
|
|
(org-match-string-no-properties 1))))
|
|
(apply 'delete-region remove)
|
|
(insert description))))
|
|
|
|
(defun qwan/org-replace-link-by-link-description ()
|
|
"Remove the link part of an org-mode link at point and keep
|
|
only the description"
|
|
(interactive)
|
|
(let ((elem (org-element-context)))
|
|
(if (eq (car elem) 'link)
|
|
(let* ((content-begin (org-element-property :contents-begin elem))
|
|
(content-end (org-element-property :contents-end elem))
|
|
(link-begin (org-element-property :begin elem))
|
|
(link-end (org-element-property :end elem)))
|
|
(if (and content-begin content-end)
|
|
(let ((content (buffer-substring-no-properties content-begin content-end)))
|
|
(delete-region link-begin (- link-end 1))
|
|
(insert content)))))))
|
|
(bind-key "C-c r" 'qwan/org-replace-link-by-link-description)
|
|
|
|
(defun org-roam-replace-file-link-by-website-or-description ()
|
|
"If a linked org-roam file has a website as key, use that as the link target instead of the filename. Otherwise, remove the link, and leave just
|
|
the description. This may destroy existing links, or change their targets so use in a copy of buffers you hold dearly as notes"
|
|
(interactive)
|
|
(let ((elem (org-element-context)))
|
|
(if (eq (car elem) 'link)
|
|
(let* ((content-begin (org-element-property :contents-begin elem))
|
|
(content-end (org-element-property :contents-end elem))
|
|
(target-type (org-element-property :type elem))
|
|
(target-path (org-element-property :path elem))
|
|
(link-begin (org-element-property :begin elem))
|
|
(link-end (org-element-property :end elem)))
|
|
(if (and content-begin content-end (string-equal target-type "file") target-path link-begin link-end)
|
|
(let ((new-link (org-roam-description-file-to-org-url
|
|
(buffer-substring-no-properties content-begin content-end)
|
|
target-path)))
|
|
(delete-region link-begin (- link-end 1))
|
|
(insert new-link)
|
|
))))))
|