Created
January 11, 2020 23:42
-
-
Save ryanwwest/d9438ff9c2ae5d93a67212ef6bc16c1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- | |
;; Place your private configuration here! Remember, you do not need to run 'doom | |
;; refresh' after modifying this file! | |
;; These are used for a number of things, particularly for GPG configuration, | |
;; some email clients, file templates and snippets. | |
(setq user-full-name "Ryan West" | |
user-mail-address "ryanwest6@gmail.com") | |
;; 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' | |
;; | |
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd | |
;; font string. You generally only need these two: | |
;; test | |
(setq doom-font (font-spec :family "monospace" :size 14)) | |
;; doom-variable-pitch-font (font-spec :family "sans")) | |
;; 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. These are the defaults. | |
(setq doom-theme 'doom-one) | |
;; If you intend to use org, it is recommended you change this! | |
(setq org-directory "~/org/") | |
;; If you want to change the style of line numbers, change this to `relative' or | |
;; `nil' to disable it: | |
(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', where Emacs | |
;; looks 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 g k'). | |
;; This will open documentation for it, including demos of how they are used. | |
;; | |
;; You can also try 'gd' (or 'C-c g d') to jump to their definition and see how | |
;; they are implemented. | |
(defun my-org-screenshot () | |
"Take a screenshot into a time stamped unique-named file in the | |
same directory as the org-buffer and insert a link to this file." | |
(interactive) | |
(org-display-inline-images) | |
(setq filename | |
(concat | |
(make-temp-name | |
(concat "media/" | |
(format-time-string "%Y%m%d_%H%M%S_")) ) ".png")) | |
(unless (file-exists-p (file-name-directory filename)) | |
(make-directory (file-name-directory filename))) | |
; take screenshot | |
(if (eq system-type 'darwin) | |
(call-process "screencapture" nil nil nil "-i" filename)) | |
(if (eq system-type 'gnu/linux) | |
(call-process "import" nil nil nil filename)) | |
; insert into file if correctly taken | |
(if (file-exists-p filename) | |
(insert (concat "[[file:" filename "]]")))) | |
;; wordwrap | |
(add-hook 'text-mode-hook 'turn-on-visual-line-mode) | |
;; initial major mode will be org mode for scratch buffer | |
(setq initial-major-mode 'org-mode) | |
(general-define-key | |
:prefix "SPC" | |
:non-normal-prefix "C-SPC" | |
:states '(normal visual motion emacs) | |
:keymaps 'override | |
"os" '(shell :wk "shell") | |
"d" '(nil :wk "deft") | |
"dd" '(deft :wk "deft") | |
"dD" '(zetteldeft-deft-new-search :wk "new search") | |
"dR" '(deft-refresh :wk "refresh") | |
"ds" '(zetteldeft-search-at-point :wk "search at point") | |
"dc" '(zetteldeft-search-current-id :wk "search current id") | |
"df" '(zetteldeft-follow-link :wk "follow link") | |
"dF" '(zetteldeft-avy-file-search-ace-window :wk "avy file other window") | |
"dl" '(zetteldeft-avy-link-search :wk "avy link search") | |
"dt" '(zetteldeft-avy-tag-search :wk "avy tag search") | |
"dT" '(zetteldeft-tag-buffer :wk "tag list") | |
"di" '(zetteldeft-find-file-id-insert :wk "insert id") | |
"dI" '(zetteldeft-find-file-full-title-insert :wk "insert full title") | |
"do" '(zetteldeft-find-file :wk "find file") | |
"dn" '(zetteldeft-new-file :wk "new file") | |
"dN" '(zetteldeft-new-file-and-link :wk "new file & link") | |
"dr" '(zetteldeft-file-rename :wk "rename") | |
"dx" '(zetteldeft-count-words :wk "count words") | |
"dp" '(my-org-screenshot :wk "take screenshot") | |
"dL" '(zetteldeft-org-search-insert :wk "output files with tag") | |
"j" '(nil :wk "custom") | |
"jw" '(add-word-to-dictionary :wk "add to dictionary") | |
"jd" '(define-word-at-point :wk "define word under cursor") | |
"jD" '(define-word :wk "define word")) | |
;; lighten comment color (also deft summary color) | |
(set-face-foreground 'font-lock-comment-face "#AAAAAA") | |
;; (tool-bar-mode 0) | |
;; (set-frame-size nil 100 50) ;; Pick values matching your screen. | |
;; display images by default for org-mode | |
(setq org-startup-with-inline-images t) | |
(setq org-image-actual-width (- (window-pixel-width) 60)) | |
;; scratch buffer org mode | |
(setq doom-scratch-buffer-major-mode 'org-mode) | |
;; TODO make this command open the file link under the cursor if in org-mode | |
;; open files externally this way | |
(defun xah-open-in-external-app (&optional @fname) | |
"Open the current file or dired marked files in external app. | |
The app is chosen from your OS's preference. | |
When called in emacs lisp, if @fname is given, open that. | |
URL `http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html' | |
Version 2019-11-04" | |
(interactive) | |
(let* ( | |
($file-list | |
(if @fname | |
(progn (list @fname)) | |
(if (string-equal major-mode "dired-mode") | |
(dired-get-marked-files) | |
(list (buffer-file-name))))) | |
($do-it-p (if (<= (length $file-list) 5) | |
t | |
(y-or-n-p "Open more than 5 files? ")))) | |
(when $do-it-p | |
(cond | |
((string-equal system-type "windows-nt") | |
(mapc | |
(lambda ($fpath) | |
(w32-shell-execute "open" $fpath)) $file-list)) | |
((string-equal system-type "darwin") | |
(mapc | |
(lambda ($fpath) | |
(shell-command | |
(concat "open " (shell-quote-argument $fpath)))) $file-list)) | |
((string-equal system-type "gnu/linux") | |
(mapc | |
(lambda ($fpath) (let ((process-connection-type nil)) | |
(start-process "" nil "xdg-open" $fpath))) $file-list)))))) | |
;; (setq shell-command-switch "-ic") | |
(defun ml/bash () | |
"Start a terminal emulator in a new window." | |
(interactive) | |
(split-window-sensibly) | |
(other-window 1) | |
(ansi-term (executable-find "bash"))) | |
;; enable word-wrap (almost) everywhere | |
;; (+global-word-wrap-mode +1) | |
;; flyspell (spellchecker) - add word to dictionary | |
(defun add-word-to-dictionary () | |
(interactive) | |
(let ((current-location (point)) | |
(word (flyspell-get-word))) | |
(when (consp word) | |
(flyspell-do-correct 'save nil (car word) current-location (cadr word) (caddr word) current-location)))) | |
;; change org buffer name to title ?! | |
(defun org+-buffer-name-to-title () | |
"Rename buffer to value of #+TITLE:." | |
(interactive) | |
(save-excursion | |
(goto-char (point-min)) | |
(when (re-search-forward "^[[:space:]]*#\\+TITLE:[[:space:]]*\\(.*?\\)[[:space:]]*$" nil t) | |
(rename-buffer (match-string 1))))) | |
(add-hook 'org-mode-hook #'org+-buffer-name-to-title) | |
;; TODO fix this | |
;; smartparens remove _, / from going on both sides | |
;; (after! org (sp-pair "_" nil :actions :rem)) | |
;; (after! org (sp-pair "/" nil :actions :rem)) | |
;; (after! org (sp-local-pair "_" nil :actions :rem)) | |
;; (after! org (sp-local-pair "/" nil :actions :rem)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment