Skip to content

Instantly share code, notes, and snippets.

@jegfish
Created February 5, 2024 01:40
Show Gist options
  • Save jegfish/09b71c5bfcd7ec3e801e91995cf3120f to your computer and use it in GitHub Desktop.
Save jegfish/09b71c5bfcd7ec3e801e91995cf3120f to your computer and use it in GitHub Desktop.
;(load "~/.emacs.d/jgf.el")
(load-theme 'modus-vivendi)
;; TODO: Make only explicit copy modify the system clipboard. Maybe
;; can do by binding copy key to a function that does that operation,
;; and setting the config option to not having the kill-ring synced to
;; system clipboard.
;; straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
;; TODO: Setup C-z as a personal prefix key.
;; TODO: Get minor mode that cleans up trailing white space. I think Doom Emacs uses the one that I want.
(use-package devil
:config
(global-devil-mode)
(define-key devil-mode-map (kbd ".") #'devil)
;; TODO: What I really want is for comma to still work, just have period not trigger in minibuffer. I think there is a hook for minibuffer exit. Could define a function that turns on full devil mode, setting up all these configs, and a function that turns on devil-mode minus period.
(add-hook 'minibuffer-mode-hook (lambda () (devil-mode -1)))
(add-to-list 'devil-special-keys `(". ." . ,(devil-key-executor ".")))
(add-to-list 'devil-special-keys `(". <return>" . ,(devil-key-executor ". <return>")))
(add-to-list 'devil-special-keys `(". SPC" . ,(devil-key-executor ". SPC")))
(setq devil-translations
'((", z" . "C-")
(". z" . "M-")
(", ," . ",")
(". ." . ".")
("," . "C-")
("." . "M-")))
)
;; (use-package god-mode
;; :init
;; ;; devil-mode style
;; ;; TODO: repeat-mode or repeat hydras or something so can repeat e.g. movement keys? Though maybe just avoid that sort of thing? Would want to be able to repeat M-d though.
;; ;; TODO: Allow typing comma with ,, or , SPC.
;; (global-set-key (kbd ",") #'god-execute-with-current-bindings)
;; (global-set-key (kbd ".") #'god-execute-with-current-bindings)
;; )
(setq tab-width 4)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(save-place-mode 1)
(setq delete-by-moving-to-trash t)
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; Don't show the default splash screen.
(setq inhibit-startup-message 1)
(setq session-save-file-coding-system 'utf-8)
(setq sentence-end-double-space nil)
(setq column-number-mode t)
(setq-default indent-tabs-mode nil)
(setq-default show-trailing-whitespace t)
;; (setq dired-dwim-target t)
(setq require-final-newline t)
;; Trying out bar cursor, rather than block cursor.
(setq-default cursor-type 'bar)
;; TODO: IDEA: While in Devil mode, switch cursor? Probably a bit much?
(global-set-key (kbd "M-u") 'upcase-dwim)
(global-set-key (kbd "M-l") 'downcase-dwim)
(global-set-key (kbd "M-c") 'capitalize-dwim)
;; Completion
(use-package vertico
:init
(vertico-mode))
;; Order of search terms doesn't matter
(use-package orderless
:after vertico
:init
(setq completion-styles '(orderless basic)
completion-category-defaults nil
;; basic : Allows stuff like completion of SSH servers to connect to.
completion-category-overrides '((file (styles basic partial-completion))))
(defun +vertico-restrict-to-matches ()
(interactive)
(let ((inhibit-read-only t))
(goto-char (point-max))
(insert " ")
(add-text-properties (minibuffer-prompt-end) (point-max)
'(invisible t read-only t cursor-intangible t rear-nonsticky t))))
;; (define-key vertico-map (kbd "S-SPC") #'+vertico-restrict-to-matches)
(bind-key "S-SPC" #'+vertico-restrict-to-matches vertico-map))
(use-package marginalia
:after vertico
:bind (("M-A" . marginalia-cycle)
:map minibuffer-local-map)
:init
(marginalia-mode))
(use-package consult
:config
(bind-key "C-c /" #'consult-ripgrep)
(bind-key "C-x b" #'consult-buffer)
(bind-key "C-x C-b" #'consult-buffer)
)
(use-package visual-fill-column)
(use-package uuidgen
:defer t)
(use-package ace-window
:bind ("M-o" . ace-window)
:init
(setq aw-scope 'frame))
(use-package avy
:config
(setq avy-timeout-seconds 0.1)
(bind-key "C-." 'avy-goto-char-timer))
;; (use-package expand-region)
(use-package magit
:defer t)
;;; Denote
(defun jgf/denote-follow-markdown-link (&optional event)
"Implementation based on `markdown-follow-link-at-point'."
(interactive (list last-command-event))
(save-excursion
(if event (posn-set-point (event-start event)))
(if (markdown-link-p)
(if (string-prefix-p "denote:" (markdown-link-url))
(denote-link-ol-follow (string-remove-prefix "denote:" (markdown-link-url)))
(markdown--browse-url (markdown-link-url)))
(user-error "Point is not at a Markdown link or URL"))))
(use-package denote
:init
(setq denote-directory "~/jeffrey-fisher-files/notes/garden")
(setq denote-file-type 'markdown-yaml)
(setq denote-prompts '(title keywords))
(setq denote-infer-keywords t)
(setq denote-known-keywords '("person" "paper" "video" "umd" "index"
"laterlist" "list" "recipe"
"unread" "inprogress" "wontread" "projectidea"
"emacs" "ocaml" "lisp" "pl" "compilers"
"functionalprogramming"
"robotics" "roboticsatmaryland"))
:bind (("C-c n d" . jgf/denote-daily)
;; ("C-c C-n C-d" . jgf/denote-daily)
("C-c n n" . denote)
;; ("C-c C-n C-n" . denote)
("C-c n f" . denote-open-or-create)
;; ("C-c C-n C-f" . denote-open-or-create)
("C-c n g" . denote-rename-file-using-front-matter)
;; ("C-c C-n C-g" . denote-rename-file-using-front-matter)
("C-c n t" . denote-keywords-add)
;; ("C-c C-n C-t" . denote-keywords-add)
("C-c n T" . denote-keywords-remove)
;; ("C-c C-n C-T" . denote-keywords-remove)
;; Note: You can create links even in non-denote files, and can follow
;; the links with RET.
("C-c n l" . denote-link)
;; ("C-c C-n C-l" . denote-link)
())
:config
(require 'denote-org-dblock)
(defun jgf/denote-daily ()
"Create an entry tagged 'daily' with the date as its title.
If a journal for the current day exists, visit it. If multiple
entries exist, prompt with completion for a choice between them.
Else create a new file."
(interactive)
(let* ((today (format-time-string "%A %e %B %Y"))
(string (denote-sluggify today))
(files (denote-directory-files-matching-regexp string)))
(cond
((> (length files) 1)
(find-file (completing-read "Select file: " files nil :require-match)))
(files
(find-file (car files)))
(t
(denote
today
'("daily")
nil
(concat denote-directory "/daily"))))))
(defun jgf/denote-tomorrow ()
"Create an entry tagged 'daily' with tomorrow's date as its title.
If a journal for tomorrow exists, visit it. If multiple
entries exist, prompt with completion for a choice between them.
Else create a new file."
(interactive)
(let* ((tomorrow (time-add (current-time) 86400))
(title (format-time-string "%A %e %B %Y" tomorrow))
;; (let* ((tomorrow (format-time-string "%A %e %B %Y" (days-to-time (time-to-days (time-add (current-time) 86400)))))
(string (denote-sluggify title))
(files (denote-directory-files-matching-regexp string)))
(cond
((> (length files) 1)
(find-file (completing-read "Select file: " files nil :require-match)))
(files
(find-file (car files)))
(t
(denote
title
'("daily")
nil
(concat denote-directory "/daily")
;; Set time portion of ID to 00:00 to indicate that the entry was
;; created ahead of time. If I happen to create another note at the
;; colliding time, it seems that Denote will complain that a note with
;; that ID already exists, so I will just need to wait a second before
;; trying to create the note again.
(format-time-string "%Y-%m-%d 00:00" tomorrow)
)))))
)
(defun jgf/denote-add-to-library ()
"Create an entry tagged 'unread' in the subdirectory 'library/'."
(interactive)
(denote (denote-title-prompt)
(append '("unread") (denote-keywords-prompt))
nil
(expand-file-name "library/" (denote-directory))))
;;; Language Server Protocol
(use-package eglot)
(use-package markdown-mode
:defer t
:hook (markdown-mode . flyspell-mode)
:config
(add-hook 'markdown-mode-hook (lambda () (visual-line-mode) (visual-fill-column-mode)))
(setq markdown-command "pandoc --mathjax")
(setq markdown-display-remote-images t)
(setq markdown-enable-math t)
(bind-key "C-c C-o" #'jgf/denote-follow-markdown-link 'markdown-mode-map)
)
(use-package bqn-mode)
(use-package racket-mode
:defer t)
(use-package geiser-racket
:defer t)
(use-package haskell-mode
:defer t)
(use-package proof-general)
(use-package company-coq
:after proof-general
:hook (coq-mode . company-coq-mode)
;; Disable prettify-symbols-mode.
:hook (company-coq-mode . (lambda () (prettify-symbols-mode -1)))
:hook (coq-goals-mode . (lambda () (prettify-symbols-mode -1)))
:hook (coq-response-mode . (lambda () (prettify-symbols-mode -1))))
;; Coq installed under 'with-coq' opam switch.
(add-to-list 'exec-path "/home/jeff/.opam/with-coq/bin")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment