use-package
is ‘require on steroids. It downloads things for me. Yay.
use-package-ensure
is equivalent to :ensure t
on every use-package
use.
It means install package if not already installed.
(require 'use-package-ensure)
(setq use-package-always-ensure t)
Auto-compile packages, and use the newest version available.
(use-package auto-compile
:config (auto-compile-on-save-mode) ;; reduce risk of loading outdated bytecode
(setq load-prefer-newer t))
Okay, so here’s the deal. I went super gung-ho on use-package
based
configuration for awhile. I regret that now. I regret that because it’s simpler
to “learn to write emacs-lisp gud”, and know how to debug that, than to use the
fancy use-package
macro system. Now I only do fancy use-package
stuff
by copy pasting others’ nonsense, and revert to emacs lisp if it’s causing probs.
Basics For Reference
:init - execute stuff before loading. :init (setq my-var t)
:config - execute
stuff after loading. :config (foo-mode t)
:bind - set keybindings. :bind
("C-g" . keyboard-quit)
don’t forget the ‘.’ :bind-keymap - eg projectile, set
a command-map prefix.
Use sensible-defaults.el for some basic settings. This is really good to read from if learning elisp.
sensible-defaults/comment-or-uncomment-blah sensible-defaults/reset-text-size
Save backups to /tmp set default directory when opening a file to home 30x garbage collection limit delete trailing whitespaces on saves treat camelCaseSubWords as separate words always follow symlinks when opening files when saving a file starting with #!, make it executable automatically Don’t assume sentences should have two spaces after periods When saving a file that doesn’t exist, offer to create it and any super-directories necessary Turn on transient mark mode If text is selected and then I type text, replace the text (delete-selection-mode) Append a newline to all saved files Confirm whether to close emacs before closing emacs Suppress the startup message and clear the scratch buffer Tell dired mode to list file sizes in kb and mb etc. Ask y/n instead of yes-or-no Turn on syntax highlighting where possible (font-lock-mode) refresh buffers so they don’t get out of sync with auto-revert-mode Show matching parens (show-paren-mode) Flash screen, not audibell Set line length to 60 play with this number as suits me If clicking on stuff to open in emacs, open in existing emacs window Insert text where the point is, not where the mouse is
M-; comments or uncomments a region C-+-_= are size adjustments
(load-file "~/.emacs.d/sensible-defaults.el")
(sensible-defaults/use-all-settings)
(sensible-defaults/use-all-keybindings)
(sensible-defaults/backup-to-temp-directory)
Also, some of hrs’s. Good to read when learning elisp.
reload, open config, open zsh profile
(defun reload ()
"shorcut to reload init file"
(interactive)
(load-file "~/.emacs.d/init.el"))
(defun cedit ()
"shortcut to edit config.org file"
(interactive)
(find-file "~/.emacs.d/config.org"))
(defun tedit ()
"shortcut to edit org/tktodos.org"
(interactive)
(find-file "~/org/tktodos.org"))
(defun pedit ()
"shortcut to edit .profile"
(interactive)
(find-file "~/.zshrc"))
(defun insert-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "%Y-%m-%d")
((equal prefix '(4)) "%d-%m-%Y")
((equal prefix '(16)) "%A, %d. %B %Y")))
(system-time-locale "us_US"))
(insert (format-time-string format))))
(global-set-key (kbd "C-c d") 'insert-date)
thx. Get a tooltip for thing at point.
(defun describe-in-popup (fn)
(let* ((thing (symbol-at-point))
(description (save-window-excursion
(funcall fn thing) ;; This is the yield point
(switch-to-buffer "*Help*")
(buffer-string))))
(popup-tip description
:point (point)
:around t
:height 30
:scroll-bar t
:margin t)))
(defun describe-thing-in-popup ()
(interactive)
(let* ((thing (symbol-at-point)))
(cond
((fboundp thing) (describe-in-popup 'describe-function))
((boundp thing) (describe-in-popup 'describe-variable)))))
(global-set-key (kbd "C-h C-h") 'describe-thing-in-popup)
rename file, get scratch buffer, kill current buffer no prompt
(defun hrs/rename-file (new-name)
(interactive "FNew name: ")
(let ((filename (buffer-file-name)))
(if filename
(progn
(when (buffer-modified-p)
(save-buffer))
(rename-file filename new-name t)
(kill-buffer (current-buffer))
(find-file new-name)
(message "Renamed '%s' -> '%s'" filename new-name))
(message "Buffer '%s' isn't backed by a file!" (buffer-name)))))
(defun hrs/generate-scratch-buffer ()
"Create and switch to a temporary scratch buffer with a random
name."
(interactive)
(switch-to-buffer (make-temp-name "scratch-")))
(defun hrs/kill-current-buffer ()
"Kill the current buffer without prompting."
(interactive)
(kill-buffer (current-buffer)))
Add entries to alist, sudo find
(defun hrs/add-auto-mode (mode &rest patterns)
"Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
(dolist (pattern patterns)
(add-to-list 'auto-mode-alist (cons pattern mode))))
(defun hrs/find-file-as-sudo ()
(interactive)
(let ((file-name (buffer-file-name)))
(when file-name
(find-alternate-file (concat "/sudo::" file-name)))))
(defun hrs/region-or-word ()
(if mark-active
(buffer-substring-no-properties (region-beginning)
(region-end))
(thing-at-point 'word)))
append to path, insert generated password, display a desktop notification
(defun hrs/append-to-path (path)
"Add a path both to the $PATH variable and to Emacs' exec-path."
(setenv "PATH" (concat (getenv "PATH") ":" path))
(add-to-list 'exec-path path))
(defun hrs/insert-password ()
(interactive)
(shell-command "pwgen 30 -1" t))
(defun hrs/notify-send (title message)
"Display a desktop notification by shelling out to `notify-send'."
(call-process-shell-command
(format "notify-send -t 2000 \"%s\" \"%s\"" title message)))
My lisp and rust block macros
(fset 'tk-org-insert-lisp-block
"#+begin_src emacs-lisp\C-m\C-m#+end_src\C-p")
(global-set-key (kbd "<f2>") 'tk-org-insert-lisp-block)
(fset 'tk-org-insert-rust-block
"#+begin_src rust\C-m\C-m#+end_src\C-p")
(global-set-key (kbd "<f3>") 'tk-org-insert-rust-block)
Return and indent instead of just return
(define-key global-map (kbd "RET") 'newline-and-indent)
(define-key global-map (kbd "<f7>") 'eshell)
(setq make-backup-files nil) ; none of these~
(setq auto-save-default t)
(use-package solarized-theme
:config (load-theme 'solarized-gruvbox-dark t))
;; make src block code look like normal text
(add-hook 'text-mode-hook
(lambda ()
(variable-pitch-mode 1)))
Zoom. Auto resize windows on active buffer switch.
(use-package zoom
:config (zoom-mode t))
(setq subword-mode t)
line numberings. And highlighting current line. and highlighting differences on git tracked files. diff-hl-mode
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(global-linum-mode 1)
(global-hl-line-mode)
(setq electric-pair-mode 1)
(use-package diff-hl)
(global-diff-hl-mode)
Get rid of the annoying parts of the display.
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
(set-window-scroll-bars (minibuffer-window) nil nil) ; minibuffer window has a scroll bar for some reason
lambdas: prettify symbols, column and line number
(global-prettify-symbols-mode t)
(setq column-number-mode t)
(setq line-number-mode t)
Moody is a pretty mode bar minions mode changes what minor are listed in the bar
(use-package moody
:config
(setq x-underline-at-descent-line t)
(moody-replace-mode-line-buffer-identification)
(moody-replace-vc-mode))
(use-package minions)
(minions-mode 1)
emacswiki flyspell ;#+begin_src emacs-lisp (dolist (hook ‘(text-mode-hook)) ; when entering text mode (add-hook hook (lambda () (flyspell-mode 1)))) ; add hook to turn on flyspell ;(add-hook ‘prog-mode-hook ; turn on flyspell in comments of programming modes ; (lambda () ; (flyspell-prog-mode) ; )) (setq flyspell-issue-message-flag nil) ; printing messages for every word slows down perf ;#+end_src Toy with this for awhile, then try out flyspell-correct and ivy interface later Xah has problems and solutions with flyspell if these don’t work.
Want emacs to remember my window setup for stuff. Storing views in registers aren’t persistent across sessions. docs. Note that this can get buggy with treemacs, beware. ; #+begin_src emacs-lisp (use-package workgroups2 :config (setq wg-session-file “~/.emacs.d/workgroups”) (setq wg-emacs-exit-save-behavior ‘save)) ; Options: ‘save ‘ask nil (setq wg-prefix-key (kbd “C-c z”)) (workgroups-mode) ;#+end_src
Ivy and helm do similar stuff, move ya from place to place and complete stuff. Ivy claims to be more minimal. Using oremacs user manual heavily. this link’s much nicer tho New learn: use C-c v/V to store the current set of windows open.
Copy pasted from docs.
(use-package ivy)
(use-package swiper) ; search extension to ivy
(use-package counsel) ;
(ivy-mode 1) ; globally turn on ivy
(setq ivy-use-virtual-buffers t) ; variably sized
(setq ivy-count-format "(%d/%d) ")
(global-set-key (kbd "C-s") 'swiper-isearch)
(global-set-key (kbd "C-r") 'swiper-isearch-backward)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "M-y") 'counsel-yank-pop) ; nicer kill ring
(global-set-key (kbd "C-h f") 'counsel-describe-function)
(global-set-key (kbd "C-h v") 'counsel-describe-variable)
(global-set-key (kbd "C-h l") 'counsel-find-library)
(global-set-key (kbd "C-h i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "C-x b") 'ivy-switch-buffer)
(global-set-key (kbd "C-c v") 'ivy-push-view)
(global-set-key (kbd "C-c V") 'ivy-pop-view)
Ivy views store the set of buffers open in the current frame.
(global-set-key (kbd "C-c k") 'counsel-rg)
(global-set-key (kbd "C-c j") 'counsel-file-jump)
(global-set-key (kbd "C-c r") 'ivy-resume)
;(global-set-key (kbd "C-c b") 'counsel-bookmark) ; weird stuff goin on
(global-set-key (kbd "C-c o") 'counsel-outline)
ivy rich, in combination with ivy descbind (Cc d) and which-key, installed earlier, make it wayyyy easier to discover and remember what my keybinds are.
(use-package ivy-rich
:config (ivy-rich-mode 1))
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line) ; recommended format
(setq ivy-rich-path-style 'abbrev) ; abbreviate paths with ~/
jump to visible text.
(use-package avy)
(global-set-key (kbd "M-t") 'avy-goto-word-1)
Projectile: finding and moving around .git or .projectile controlled project files. Projectile-commander is useful magit-like.
(use-package projectile)
(use-package counsel-projectile)
(counsel-projectile-mode)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
magit. Interface to git. Forge to interface with github. Sorta shitty documentation on forge. Trying this solution. Hoo baby it worked.
(use-package magit)
(use-package forge)
exec-path-from-shell. gives emacs a look at shell environment variables. Most useful on OS X.
ripgrep is the fastest implementation of grep, built on Rust’s regex engine,
binary name rg. Usage: C-c k
. rg.el. Ties in with counsel.
(use-package rg)
(hrs/append-to-path "/usr/local/bin") ; oddly wasn't globally in path, fixing that
Dired-X. Features: Omit uninteresting files, guess and run shell commands, file marking. I use it minimally.
(add-hook 'dired-load-hook
(lambda ()
(load "dired-x")))
dumb-jump. Jump to definition. Usage: in prog-mode, C-M-s | C-M-R
.
Other packages often include something similar, eg, xref, racer. Use this when
those aren’t available.
(use-package dumb-jump)
(global-set-key (kbd "C-M-s") 'dumb-jump-go)
(global-set-key (kbd "C-M-r") 'dumb-jump-back)
(setq dumb-jump-force-searcher 'rg)
(setq dumb-jump-selector 'ivy)
re Builder. Usage: M-x re-builder
, test patterns in buffer.
Set re-builder to “string mode” (default req.s double backslash)
(use-package re-builder)
(setq reb-re-syntax 'string)
For copy-cut-paste things without affecting kill ring.
(use-package simpleclip)
(simpleclip-mode 1)
Confirmed, this is crashing emacs. Sad face.
(use-package which-key)
free-keys. Usage: m-x free-keys
.
(use-package free-keys)
emojify. ;#+begin_src emacs-lisp (use-package emojify :hook (after-init . global-emojify-mode))
This was a pretty good start. Try clocking in and out with Cc Cx Ci/o
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
tell syntax highlighting and tab in source blocks to act naturally. don’t indent newly expanded blocks.
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(setq org-adapt-indentation nil)
;(setq org-pretty-entities nil) ; quick latex-ify in org files; annoying in codesnippets
(setq org-directory "~/org")
(setq org-todo-keywords ; ! = timestamp, @ = create note
'((sequence "TODO(t!)" "NOW(n!)" "WAITING(w)" "|" "DONE(d)" "CANCELED(c)")))
(setq org-log-done 'time) ; log when finished
*
Org download docs - drag images from outside of emacs into emacs buffers
(use-package org-download)
See this for option elements, and this for template escape sequences. Usage: (key description type target template properties) types: entry (org node), item (plain list item at location), checkitem (checkbox item), table-line, plain templates: many targets: file “file”, id “existing id”, file+headline “file” “node”, datetree, clock properties: prepend, empty-lines, clock-in/keep/resume, time-prompt, tree-type, table-line-pos %? = point; %i = initial content %a = location stored from ; %l = literal %x,c = put pastebin, killring head %k title of currently clocked task; K = link to
%^g prompt for tags; G completion all tags all agenda files %^t prompt date, T,u,U %^{PROPMT|default|completion2|...} pick from a sequence of prompts
%t = datestamp; T= time+datestamp; u,U = inactive timestamps - don’t cause item to show up in agenda
(setq org-default-notes-file (concat org-directory "~/org/tktodos.org")) ; capture
(setq org-capture-templates
'(
("z" "Misc todo" entry (file+headline "~/org/misc.org" "Misc")
"* TODO \t %? :MISC:\nAdded: %u:" :empty-lines 1 )
("d" "Dev" entry (file+headline "~/org/dev.org" "Dev")
"* TODO \t %? :DEV:\nAdded: %u" :empty-lines 1 )
("M" "Main Dev" entry (file+headline "~/org/main.org" "Main")
"* TODO [#A] \t %? :MAIN:DEV:\nAdded: %u" :empty-lines 1 )
("R" "Main Rsch" entry (file+headline "~/org/main.org" "Main")
"* TODO [#A] \t %? :MAIN:RSCH:\nAdded: %u" :empty-lines 1 )
("e" "Emacs" entry (file+headline "~/org/emacs.org" "Emacs")
"* TODO \t %? :EMACS:\nAdded: %u" :empty-lines 1 )
("p" "Personal" entry (file+headline "~/org/pers.org" "Pers")
"* TODO \t %? :PERS:\nAdded: %u" :empty-lines 1 )
("r" "Research" entry (file+headline "~/org/rsch.org" "Rsch")
"* TODO \t %? :RSCH:\nAdded: %u" :empty-lines 1 )
("i" "Idea" entry (file "~/org/ideas.org")
"* \t %? :IDEA:\nAdded: %u" )
))
Note, I’ve found org-clock to be pretty clunky to work with. Especially bad if Emacs exits irregularly/crashes. Toggl does better.
(add-hook 'org-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-x C-l") 'org-clock-in-last)
))
manual : if idle, eg did nothing for 15 minutes, emacs can prompt about weird timers and idle time. Usually, respond to prompt with ‘s/k’, or ‘S/K’ to then clock out.
(setq org-clock-idle-time 15) ;prompt after 15 idle minutes.
(setq org-agenda-files '("~/org" ))
; tf not used heavily atm
(setq org-agenda-custom-commands ; options - todo, tags, tags-todo
'(("d" "Dev" tags-todo "DEV")
("e" "Emacs" tags-todo "EMACS")
("p" "Personal" tags-todo "PERS")
("r" "Research" tags-todo "RSCH")
("m" "Research" tags-todo "MAIN")
))
(setq org-agenda-start-on-weekday nil) ; start today
(setq org-tag-alist '(("dev" . d) ("personal" . ?p) ("research" . ?r) ("main" . ?m)))
Currently using Bear over org-roam. May increase usage gradually over time, especially on Linux.
documentation and source. Get used to zettelkastening up some notas.
(use-package org-roam
:hook
(after-init . org-roam-mode)
:custom ; adjust graph dot executable
(org-roam-directory "~/org/roam")
:bind (:map org-roam-mode-map (
("C-c n f" . org-roam-find-file)
("C-c n g" . org-roam-graph))
:map org-mode-map
(("C-c n i" . org-roam-insert))
(("C-c n c" . org-roam-capture))
(("C-c n I" . org-roam-insert-immediate))
))
(use-package company-org-roam)
(setq org-roam-completion-system 'ivy)
(setq org-roam-capture--file-name-default "<%Y-%m%-%d>")
(setq org-roam-capture-templates
;; '(("p" "paper" plain (function org-roam--capture-get-point)
;; "%?"
;; :file-name "paper/${topic}/${subtopic}/${slug}"
;; :head: "#+title: ${title}\n"
;; :unnarrowed t)
'(("w" "web" plain (function org-roam--capture-get-point)
"%?"
:file-name "web/${topic}/${subtopic}/${slug}"
:head "#+title: ${title}\n"
:unnarrowed t
)
))
(setq org-roam-graph-executable "/usr/local/bin/dot")
(use-package graphviz-dot-mode
:config
(setq graphviz-dot-indent-width 4))
;(setq org-roam-graph-viewer "/Applications/Safari.app/Contents/MacOS/safari")
(setq-default tab-width 2)
new: want flycheck keys just kidding, looks like this is something already done for me.
(use-package flycheck
:ensure t
:init (global-flycheck-mode)) ; test
lsp guide.
treemacs.
Try: lsp-treemacs-quick-fix
or x
when at an error list
(setq lsp-keymap-prefix "M-n")
(use-package lsp-mode
:hook (rustic-mode . lsp)
; :hook (sh-mode . lsp)
:hook(go-mode . lsp)
:commands lsp)
;; optionally
(use-package lsp-ui :commands lsp-ui-mode)
(use-package lsp-ivy :commands lsp-ivy-workspa ce-symbol)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(use-package dap-mode) ; debugger - no dap-rust yet
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
rustup component add rls rust-analysis rust-src cargo +nightly install racer cargo install cargo-check cargo install cargo-edit - {add,rm,upgrade} crates from toml cargo install cargo-audit rustup component add rustfmt-preview
Rustic mode. Simple extension of rust-mode. Rust-analyzer. In alpha. Great docs. Requires a little setup.
(use-package rustic) ; many nifty convenience functions. defaults to rust-analyzer > rls
(setq rustic-lsp-server 'rust-analyzer)
(setq lsp-rust-analyzer-server-command '("~/.cargo/bin/rust-analyzer"))
(custom-set-faces
'(rustic-compilation-error ((t (:foreground "Red"))))
'(rustic-compilation-warning ((t (:foreground "Red"))))
'(rustic-compilation-message ((t (:foreground "Red"))))
'(rustic-compilation-info ((t (:foreground "Blue"))))
'(rustic-compilation-line ((t (:foreground "Blue")))))
(use-package rust-mode
:config
(hrs/append-to-path "~/.cargo/bin")
(setq rust-format-on-save t))
(use-package cargo)
(use-package toml-mode)
racer docs. Code auto-completion and find definitions.
; testing, possibly useful on Starchy
;(setenv "RUST_SRC_PATH" "/home/thor/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library")
(use-package racer
:config (setq company-tooltip-align-annotations t)
:hook ((rust-mode . racer-mode)
(rust-mode . rustic-mode)
(add-racer-mode . eldoc-mode) ; shows in echo area the arg list of the fn at point
(racer-mode . company-mode)) ; company autocomplete sometimes slows editor down significantly
:bind (:map rust-mode-map ("TAB" . company-indent-or-complete-common)))
Also, use C-c p to throw a debug println in.
(use-package flycheck-rust) ; runs on save buffer
(with-eval-after-load 'rust-mode
(add-hook 'flycheck-mode-hook 'flycheck-rust-setup))
(add-hook 'rust-mode-hook
(lambda ()
(setq cargo-minor-mode t) ; Cc Cc C(b/r/t)
))
Usage: M-x rust-playground(-exec|rm)? Note ctl-ret is bound in playgrounds for compile
(use-package rust-playground)
(use-package ob-rust)
(use-package go-mode)
(use-package go-errcheck)
(use-package company) ; autocompletes
(use-package company-go)
(setq company-tooltip-limit 20) ; bigger popup window
(setq company-idle-delay .2) ; decrease delay before autocompletion popup shows
(setenv "GOPATH" "/Users/thor/go")
(hrs/append-to-path (concat (getenv "GOPATH") "/bin")) ; user gopath
(hrs/append-to-path "/usr/local/go/bin") ; other shit that we like
formats the file and automatically updates the list of imports.
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
company-go docs. Enable flycheck. run these yourself:
- go get github.com/rogpeppe/godef
- go get -u github.com/nsf/gocode
(add-hook 'go-mode-hook
(lambda ()
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go run ")
)))
(add-hook 'go-mode-hook
(lambda ()
(set (make-local-variable 'company-backends)
'(company-go))
(company-mode)
(flycheck-mode)
(local-set-key (kbd "C-c C-c C-r") 'compile)
))
Integration with godoc via the functions godoc and godoc-at-point. godef-describe (C-c C-d) to describe expressions godef-jump (C-c C-j) and godef-jump-other-window (C-x 4 C-c C-j) to jump to declarations Jump to the argument list (go-goto-arguments - C-c C-f a) Jump to the docstring, create it if it does not exist yet (go-goto-docstring - C-c C-f d). Jump to the function keyword (go-goto-function - C-c C-f f) Jump to the function name (go-goto-function-name - C-c C-f n) Jump to the return values (go-goto-return-values - C-c C-f r) Jump to the method receiver, adding a pair of parentheses if no method receiver exists (go-goto-method-receiver - C-c C-f m).
You should toggle some of these to remember what they actually do.
(use-package paredit)
(use-package rainbow-delimiters)
(setq lispy-mode-hooks
'(emacs-lisp-mode-hook
lisp-mode-hook
scheme-mode-hook))
(dolist (hook lispy-mode-hooks)
(add-hook hook (lambda ()
(setq show-paren-style 'expression)
(paredit-mode)
(rainbow-delimiters-mode))))
If I’m writing in Emacs lisp I’d like to use eldoc-mode
to display documentation.
(use-package eldoc
:config
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode))
(use-package flycheck-package) ; should b called emacs-lisp flycheck
(eval-after-load 'flycheck
'(flycheck-package-setup))
(use-package solidity-mode)
; optionals
(setq solidity-comment-style 'slash) ; 'star by default
; optional keybinds
(define-key solidity-mode-map (kbd "C-c C-g") 'solidity-estimate-gas-at-point)
; provide path to solc and solium binaries ; these are overlapping checkers and can be used simultaneously
; (setq solidity-solc-path "/bin")
; (setq solidity-solium-path "/home/lefteris/.npm-global/bin/solium")
;(use-package 'solidity-flycheck)
;(setq solidity-flycheck-solc-checker-active t)
;(setq solidity-flycheck-solium-checker-active t)
; (setq flycheck-solidity-solc-addstd-contracts t) ; enable to include standard contracts
(use-package company-solidity)
(add-hook 'solidity-mode-hook
(lambda ()
(set (make-local-variable 'company-backends)
(append '((company-solidity company-capf company-dabbrev-code))
company-backends))))
company shell docs autocompletes
(use-package company-shell)
(add-to-list 'company-backends 'company-shell)
stuff for latex. tex mode starts out pretty useful, AuCTeX improves it.
Use Cj
to break and check the previous TeX para. Use Cc Co
to
insert \begin \end block points. Use Cc Ce
to close the innermost block.
Use Cc Cc
or Cc Cb
to run tex. Then Cc Cv
to bring up the pdf. Use Cc ?
to get documentation for symbol at point.
In Plain TeX mode, insert ‘%**start of header’ before the header, and ‘%**end of header’ after it. In LaTeX mode, the header begins with ‘\documentclass’ or ‘\documentstyle’ and ends with ‘\begin{document}’.
The minor mode latex-electric-env-pair-mode automatically inserts these begin
end. The rest is from the the link. AUCTeX is TeX with goodies. Advanced
features, like preview TeX equations within buffers. Use preview-latex
.
; (use-package auctex)
; Error (use-package): ; auctex/:catch: Loading file /Users/thor/.emacs.d/elpa/auctex-12.2.4/auctex.elc failed to provide feature auctex
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode) ; an altern to auto-fill-mode
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'tex-mode-hook
(lambda ()
(latex-electric-env-pair-mode)))
The fat Auctex manual lives here.
- There is no difference between `global-set-key` and `define-key global-map`.
- what is #’<function>? add-hook ‘blah-hook #’<function> = this is a function; which is why we use it when adding hooks.
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 100))
(add-to-list 'default-frame-alist (cons 'width 80)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 60) ; close as I can get to full left half
(frame-char-height)))))))
(set-frame-size-according-to-resolution)
eglot. a language server that does nice things for me in a simple way.
#+begin_src emacs-lisp
(use-package eglot) ;; if weirdness, add this line: ; (add-to-list ‘eglot-server-programs ‘(foo-mode . (“foo-language-server” “–args”))) (add-hook ‘sh-mode-hook ‘eglot-ensure) (add-hook ‘rust-mode-hook ‘eglot-ensure) (add-hook ‘python-mode-hook ‘eglot-ensure) (add-hook ‘go-mode-hook ‘eglot-ensure) (add-hook ‘tex-mode-hook ‘eglot-ensure)
#+end_src
yasnippet docs, snippets sold separately
#+begin_src emacs-lisp
(use-package yasnippet-snippets) (use-package yasnippet :config (yas-reload-all) ; must come after snippet-dirs :hook (‘prog-mode #’yas-minor-mode) :bind (“C-c y” . yas-insert-snippet)) (setq yas-snippet-dirs ‘(“~/.emacs.d/snippets” ;; personal snippets ))
#+end_src
(use-package centaur-tabs :demand ;; don’t defer load, recommended :config (setq centaur-tabs-style “bar” centaur-tabs-height 32 centaur-tabs-set-icons t centaur-tabs-set-modified-marker t centaur-tabs-show-navigation-buttons t centaur-tabs-set-bar ‘left) (centaur-tabs-headline-match) ;; (centaur-tabs-enable-buffer-reordering) ;; (setq centaur-tabs-adjust-buffer-order t) (centaur-tabs-mode t) (setq uniquify-separator “/”) (setq uniquify-buffer-name-style ‘forward))
get xkcd. Turns out this makes it impossible to reload for unknown reasons. (use-package xkcd) (global-set-key (kbd “<f4>”) ‘xkcd)
notmuch emacs docs reminder to download and install notmuch first (use-package notmuch) (autoload ‘notmuch “notmuch” “notmuch mail” t) ;
modify org-todos w ivy, Cc t, Cu Cc t - to change todos ivy-todo is convenient for task setting, it recognizes what project I’m in and puts me in that list. Sortof a lightweight task manager. Testing this out. Decided ivy-todo was inferior to org-agenda (use-package ivy-todo :ensure t :bind (“C-c t” . ivy-todo) :commands ivy-todo :config (setq ivy-todo-file “~/org/ivy-todo.org”) (setq ivy-todo-default-tags ‘(“PROJECT”)))
Note: type C-f while in an Ido frame to turn off Ido’s suggestions. I could extend Ido further to search through “work directories” and other stuff (ido-mode 1) (setq ido-enable-flex-matching t) (setq ido-everywhere t) ; enables ido on C-x C-f ;; tell ido what priority extensions are (setq ido-file-extensions-order ‘(“.org” “.rs” “.go” “.txt” “.emacs” “.xml” “.el” “.ini” “.cfg” “.cnf”))