Skip to content

Commit a2e18ae

Browse files
author
Patrick Thomson
committed
Bump.
1 parent aa952eb commit a2e18ae

File tree

2 files changed

+91
-86
lines changed

2 files changed

+91
-86
lines changed

init.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
(scroll-bar-mode -1)
1111
(tooltip-mode -1))
1212

13+
(when (eq system-type 'darwin)
14+
(setq ns-auto-hide-menu-bar t))
15+
1316
(require 'package)
1417
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
1518
(add-to-list 'package-archives '("ublt" . "https://elpa.ubolonton.org/packages/") t)
16-
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
1719
(setq package-native-compile t)
1820
(setq use-package-always-ensure t)
1921
(unless (package-installed-p 'use-package)

readme.org

Lines changed: 88 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ This configuration assumes you're running Emacs 28, the latest version (though I
1818

1919
The most up-to-date version of this document is located [[https://github.com/patrickt/emacs][on GitHub]]. A better-rendered version can be found [[https://blog.sumtypeofway.com/posts/emacs-config.html][on my blog]], but might not be as current as the first version.
2020

21-
** TODOs
22-
23-
- Make a popper function that gives Magit a bit more breathing room
24-
- Disable ~C-c g~ in org-src modes
25-
2621
* Configuration: start!
2722

2823
** Preliminaries
@@ -58,18 +53,11 @@ Since subsequent packages like ~libgit~ may depend on executables like ~cmake~,
5853

5954
#+begin_src emacs-lisp
6055
;; exec-path-from shell was misbehaving, this hack seems to mollify it
61-
(defvar fish-location "/usr/local/bin/fish")
62-
6356
(use-package exec-path-from-shell
6457
:init
6558
(exec-path-from-shell-initialize))
6659
#+end_src
6760

68-
I'm experimenting with ~package-quickstart~ to speed up startup.
69-
70-
#+begin_src emacs-lisp
71-
;; (advice-add 'package-install :after #'package-quickstart-refresh)
72-
#+end_src
7361

7462
With this auxiliary package for ~use-package~, we can instruct Emacs that a given package depends on the presence of a system tool. It will even install this tool with the system's recommended package manager.
7563

@@ -273,11 +261,6 @@ The out-of-the-box treatment of whitespace is unfortunate, but fixable.
273261
(deactivate-mark))
274262

275263
(bind-key "C-c I" #'pt/indent-just-yanked)
276-
277-
(use-package auto-indent-mode
278-
:disabled ;; fucks with vertico
279-
:custom (auto-indent-start-org-indent nil)
280-
:config (auto-indent-mode))
281264
#+end_src
282265

283266
Emacs instances started outside the terminal do not pick up ssh-agent information unless we use keychain-environment.
@@ -361,24 +344,27 @@ I almost never want to quit if readme.org is in a bad state. This warns me shoul
361344
My RSI hurts a lot.
362345

363346
#+begin_src emacs-lisp
364-
(type-break-mode)
347+
(setq type-break-file-name nil)
348+
(type-break-mode)
365349
#+end_src
366350

367351
** Visuals
368352

369353
It's a mystery why Emacs doesn't allow colors by default in its compilation buffer, but ~fancy-compilation~ addresses that (and ensures the background color is set to something dark so that programs that make assumptions about)
370354

371355
#+begin_src emacs-lisp
372-
(use-package fancy-compilation)
356+
(use-package fancy-compilation :config (fancy-compilation-mode))
373357
#+end_src
374358

375359
Emacs looks a lot better when it has a modern monospaced font and VSCode-esque icons, as well as smooth scrolling.
376360

377361
#+begin_src emacs-lisp
378-
(ignore-errors (set-frame-font "Menlo-13"))
362+
(set-face-attribute 'default nil :font "Menlo-13")
379363
(set-face-attribute 'variable-pitch nil :font "SF Mono-12")
380364

381-
(use-package all-the-icons)
365+
(let ((installed (package-installed-p 'all-the-icons)))
366+
(use-package all-the-icons)
367+
(unless installed (all-the-icons-install-fonts)))
382368

383369
(use-package all-the-icons-dired
384370
:after all-the-icons
@@ -399,14 +385,17 @@ Window chrome both wastes space and looks unappealing. (This is actually pasted
399385
(scroll-bar-mode -1)
400386
(tooltip-mode -1)
401387
(pixel-scroll-mode))
388+
389+
(when (eq system-type 'darwin)
390+
(setq ns-auto-hide-menu-bar t))
402391
#+end_src
403392

404393
I use the [[https://github.com/hlissner/emacs-doom-themes][Doom Emacs themes]], which are gorgeous. I sometimes also use Modus Vivendi, the excellent new theme that now ships with Emacs.
405394

406395
#+begin_src emacs-lisp
407396
(use-package doom-themes
408397
:config
409-
(let ((chosen-theme 'doom-sourcerer))
398+
(let ((chosen-theme 'doom-material-dark))
410399
(doom-themes-visual-bell-config)
411400
(doom-themes-org-config)
412401
(setq doom-challenger-deep-brighter-comments t
@@ -453,19 +442,11 @@ The default modeline is pretty uninspiring, and ~mood-line~ is very minimal and
453442
(mood-line-mode))
454443
#+end_src
455444

456-
I find it useful to have a slightly more apparent indicator of which buffer is active at the moment.
457-
458-
#+begin_src emacs-lisp
459-
(use-package dimmer
460-
:disabled
461-
:custom (dimmer-fraction 0.3)
462-
:config (dimmer-mode))
463-
#+end_src
464-
465445
Highlighting the closing/opening pair associated with a given parenthesis is essential. Furthermore, parentheses should be delimited by color. I may be colorblind, but it's good enough, usually.
466446

467447
#+begin_src emacs-lisp
468448
(use-package rainbow-delimiters
449+
:disabled
469450
:hook ((prog-mode . rainbow-delimiters-mode)))
470451
#+end_src
471452

@@ -507,33 +488,18 @@ For some reason ~centaur-tabs~ has stopped working. I'm keeping the config aroun
507488

508489
#+begin_src emacs-lisp
509490
(use-package centaur-tabs
510-
:disabled
511491
:config
512492
(centaur-tabs-mode t)
513493
:custom
514-
(centaur-tabs-set-icons nil)
494+
(centaur-tabs-set-icons t)
515495
(centaur-tabs-show-new-tab-button nil)
516496
(centaur-tabs-set-close-button nil)
517497
(centaur-tabs-enable-ido-completion nil)
498+
(centaur-tabs-gray-out-icons t)
518499

519500
:bind
520501
(("s-{" . #'centaur-tabs-backward)
521502
("s-}" . #'centaur-tabs-forward)))
522-
523-
(use-package tab-line
524-
:disabled
525-
:after dash
526-
:config
527-
(setq tab-line-separator " | ")
528-
(setq tab-line-tabs-function 'tab-line-tabs-mode-buffers)
529-
;;(setq tab-line-exclude-modes '(completion-list-mode help-mode git-commit-mode))
530-
(global-tab-line-mode t)
531-
:custom
532-
(tab-line-new-button-show nil)
533-
(tab-line-close-button-show nil)
534-
:bind
535-
(("s-}" . #'tab-line-switch-to-next-tab)
536-
("s-{" . #'tab-line-switch-to-prev-tab)))
537503
#+end_src
538504

539505
** Text manipulation
@@ -576,7 +542,8 @@ Emacs's keybinding for ~comment-dwim~ is ~M-;~, which is not convenient to type
576542
("C-c j j" . #'avy-goto-line)
577543
("C-c j h" . #'avy-kill-region)
578544
("C-c j w" . #'avy-copy-line)
579-
("C-c v v" . #'avy-goto-char)))
545+
("C-z" . #'avy-goto-char)
546+
("C-c v" . #'avy-goto-char)))
580547

581548
(use-package avy-zap
582549
:bind (("C-c z" . #'avy-zap-to-char)
@@ -601,7 +568,7 @@ I'm trying to learn how to take advantage of ~smartparens~, but it already provi
601568
("<left>" . #'sp-backward-sexp)
602569
("<right>" . #'sp-forward-sexp)
603570
("C-c C-(" . #'sp-up-sexp)
604-
("C-c v w" . #'sp-copy-sexp)
571+
("C-c j s" . #'sp-copy-sexp)
605572
("C-c C-)" . #'sp-down-sexp))
606573
:config
607574
(require 'smartparens-config)
@@ -763,15 +730,8 @@ It's genuinely shocking that there's no "duplicate whatever's marked" command bu
763730
Vim comes with support for incrementing and decrementing numbers at point. Shame that Emacs doesn't. But fixable.
764731

765732
#+begin_src emacs-lisp
766-
(defun increment-number-at-point ()
767-
"Increment the number at point. Taken from EmacsWiki."
768-
(interactive)
769-
(skip-chars-backward "0-9")
770-
(or (looking-at "[0-9]+")
771-
(error "No number at point"))
772-
(replace-match (number-to-string (1+ (string-to-number (match-string 0))))))
773-
774-
(bind-key "C-c a 1" #'increment-number-at-point)
733+
(use-package evil-numbers
734+
:bind ("C-c a 1" . #'evil-numbers/inc-at-pt))
775735
#+end_src
776736

777737
We need to support reading large blobs of data for LSP's sake.
@@ -834,6 +794,7 @@ I almost always want to default to a two-buffer setup.
834794
"Remove auxiliary buffers."
835795
(interactive)
836796
(ignore-errors (exit-recursive-edit))
797+
(ignore-errors (ctrlf-cancel))
837798
(popper-close-latest)
838799
(call-interactively #'keyboard-quit))
839800

@@ -1009,6 +970,7 @@ Even though my whole-ass blogging workflow is built around org-mode, I still can
1009970
("C-c o :" . #'org-roam-buffer-toggle))
1010971
:custom
1011972
(org-roam-directory (expand-file-name "~/Dropbox/txt/roam"))
973+
(org-roam-completion-everywhere t)
1012974
(org-roam-v2-ack t)
1013975
:config
1014976
(org-roam-db-autosync-mode))
@@ -1037,7 +999,7 @@ Magit is one of the top three reasons anyone should use Emacs. What a brilliant
1037999
(use-package magit
10381000
:diminish magit-auto-revert-mode
10391001
:diminish auto-revert-mode
1040-
:bind (("C-c g" . #'magit-status-quick))
1002+
:bind (("C-c g" . #'magit-status))
10411003
:custom
10421004
(magit-repository-directories '(("~/src" . 1)))
10431005
(magit-list-refs-sortby "-creatordate")
@@ -1052,10 +1014,6 @@ Magit also allows integration with GitHub and other such forges (though I hate t
10521014
#+begin_src emacs-lisp
10531015
(use-package forge
10541016
:after magit)
1055-
1056-
;; hack to eliminate weirdness
1057-
(unless (boundp 'bug-reference-auto-setup-functions)
1058-
(defvar bug-reference-auto-setup-functions '()))
10591017
#+end_src
10601018

10611019
I'm trying out this git-status-in-the-fringe package, which looks fairly visually appealing.
@@ -1136,8 +1094,10 @@ I prefer the built-in ~project.el~ to ~projectile~, but because ~projectile~ cac
11361094
(defun pt/find-file-dwim ()
11371095
(interactive)
11381096
(if (and buffer-file-name (file-remote-p buffer-file-name))
1139-
(unless projectile-mode (projectile-mode t))
1140-
(projectile-find-file)
1097+
(progn
1098+
(projectile-mode t)
1099+
(projectile-find-file)
1100+
)
11411101
(project-find-file)))
11421102
:bind (("C-c f" . #'pt/find-file-dwim)))
11431103

@@ -1186,7 +1146,7 @@ My journey through the various Emacs completion facilities has been long and twi
11861146

11871147
(use-package consult
11881148
:bind (("C-c i" . #'consult-imenu)
1189-
("C-c b" . #'consult-buffer)
1149+
("C-c b" . #'consult-project-buffer)
11901150
("C-x b" . #'consult-buffer)
11911151
("C-c r" . #'consult-recent-file)
11921152
("C-c B" . #'consult-bookmark)
@@ -1299,6 +1259,7 @@ Built-in ~xref~ and ~eldoc~ are powerful packages, though we pin them to GNU ELP
12991259
#+begin_src emacs-lisp
13001260
(use-package xref
13011261
:pin gnu :ensure t
1262+
:custom (xref-auto-jump-to-first-xref t)
13021263
:bind (("s-r" . #'xref-find-references)
13031264
("C-<down-mouse-1>" . #'xref-find-definitions)
13041265
("C-S-<down-mouse-1>" . #'xref-find-references)
@@ -1525,25 +1486,66 @@ Rust is one of my favorite languages in the world.
15251486

15261487
I occasionally write Go, generally as a glue language to munge things together. I find certain aspects of its creators' philosophies to be repellent, but a language is more than its creators, and it's hard to argue with the success it's found in industry or the degree to which people find it easy to pick up.
15271488

1489+
Amusingly enough, the built-in ~go-remove-unused-imports~ function is useless to put in a save hook, because it requires that the file be saved first, and… yeah, you can imagine how that goes. Cheers to Rob Figueiredo, who wrote a function that uses the ~goimports~ tool like a normal tool would instead of the monstrosity that is ~go-remove-unused-imports~, which searches the current flymake buffer with a regex. 🙄
1490+
15281491
#+begin_src emacs-lisp
1529-
(use-package go-mode
1530-
:defer t
1531-
:config
1532-
(add-hook 'before-save-hook #'gofmt-before-save))
1533-
1534-
(use-package go-snippets :defer t)
1535-
1536-
(defun fix-messed-up-gofmt-path ()
1537-
(interactive)
1538-
(setq gofmt-command (string-trim (shell-command-to-string "which gofmt"))))
1539-
1540-
;; Note to self: there's a really helpful set of movement commands
1541-
;; under C-c C-f in go mode.
1542-
(use-package gotest
1543-
:bind (:map go-mode-map
1544-
("C-c a t" . #'go-test-current-test)
1545-
("C-c a T" . #'go-test-current-file)
1546-
("C-c a i" . #'go-import-add)))
1492+
(use-package go-mode
1493+
:defer t
1494+
:config
1495+
(defun robfig/goimports ()
1496+
"Formats the current buffer according to the goimports tool."
1497+
1498+
(interactive)
1499+
(let ((tmpfile (make-temp-file "gofmt" nil ".go"))
1500+
(patchbuf (get-buffer-create "*Gofmt patch*"))
1501+
(errbuf (get-buffer-create "*Gofmt Errors*"))
1502+
(coding-system-for-read 'utf-8)
1503+
(coding-system-for-write 'utf-8))
1504+
1505+
(with-current-buffer errbuf
1506+
(setq buffer-read-only nil)
1507+
(erase-buffer))
1508+
(with-current-buffer patchbuf
1509+
(erase-buffer))
1510+
1511+
(write-region nil nil tmpfile)
1512+
1513+
;; We're using errbuf for the mixed stdout and stderr output. This
1514+
;; is not an issue because gofmt -w does not produce any stdout
1515+
;; output in case of success.
1516+
(if (zerop (call-process "goimports" nil errbuf nil "-w" tmpfile))
1517+
(if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile))
1518+
(progn
1519+
(kill-buffer errbuf)
1520+
(message "Buffer is already gofmted"))
1521+
(go--apply-rcs-patch patchbuf)
1522+
(kill-buffer errbuf)
1523+
(message "Applied gofmt"))
1524+
(message "Could not apply gofmt. Check errors for details")
1525+
(gofmt--process-errors (buffer-file-name) tmpfile errbuf))
1526+
1527+
(kill-buffer patchbuf)
1528+
(delete-file tmpfile)))
1529+
1530+
(defun pt/go-specific-save-hook ()
1531+
(when (eq major-mode 'go-mode)
1532+
(gofmt-before-save)
1533+
(robfig/goimports)))
1534+
(add-hook 'before-save-hook #'pt/go-specific-save-hook))
1535+
1536+
(use-package go-snippets :defer t)
1537+
1538+
(defun fix-messed-up-gofmt-path ()
1539+
(interactive)
1540+
(setq gofmt-command (string-trim (shell-command-to-string "which gofmt"))))
1541+
1542+
;; Note to self: there's a really helpful set of movement commands
1543+
;; under C-c C-f in go mode.
1544+
(use-package gotest
1545+
:bind (:map go-mode-map
1546+
("C-c a t" . #'go-test-current-test)
1547+
("C-c a T" . #'go-test-current-file)
1548+
("C-c a i" . #'go-import-add)))
15471549
#+end_src
15481550

15491551
Elm is a good language.
@@ -1745,6 +1747,7 @@ By default, the list of recent files gets cluttered up with the contents of down
17451747
(recentf-exclude (-concat recentf-exclude '("\\elpa"
17461748
"private/tmp" ; to avoid custom files
17471749
"txt/roam"
1750+
"type-break"
17481751
)))
17491752
(recentf-max-saved-items 50)
17501753
(recentf-max-menu-items 30)

0 commit comments

Comments
 (0)