Skip to content

Commit

Permalink
emacs: better error display
Browse files Browse the repository at this point in the history
  • Loading branch information
tiborpilz committed Apr 19, 2024
1 parent 97384cf commit df453dc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
18 changes: 16 additions & 2 deletions home/config/doom/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
user-mail-address "[email protected]")

(setq doom-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'light)
doom-big-font (font-spec :family "FiraCode Nerd Font" :size 28 :weight 'normal)
doom-unicode-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'normal)
doom-big-font (font-spec :family "FiraCode Nerd Font" :size 28 :weight 'light)
doom-unicode-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'light)
doom-variable-pitch-font (font-spec :family "DejaVu Serif" :size 16 :weight 'normal))

(setq display-line-numbers-type 'relative)
Expand All @@ -14,6 +14,8 @@

(setq frame-title-format "%b - Emacs")

(setenv "PASSWORD_STORE_DIR" "~/.local/share/password-store")

(defun add-hooks (hook-list function)
"Add FUNCTION to all hooks in HOOK-LIST."
(dolist (hook hook-list)
Expand Down Expand Up @@ -580,6 +582,18 @@ for what debugger to use. If the prefix ARG is set, prompt anyway."

(spacious-padding-mode 1)

(when (featurep! :checkers syntax +childframe)
(defun flycheck-posframe-monitor-post-command ()
(when (not (flycheck-posframe-check-position))
(posframe-hide flycheck-posframe-buffer)))

(defun fix-flycheck-posframe-not-hide-immediately ()
(cond (flycheck-posframe-mode
(add-hook 'post-command-hook 'flycheck-posframe-monitor-post-command nil t))
((not flycheck-posframe-mode)
(remove-hook 'post-command-hook 'flycheck-posframe-monitor-post-command t))))
(add-hook! flycheck-posframe-mode #'fix-flycheck-posframe-not-hide-immediately))

;; (define-key ivy-minibuffer-map (kbd "TAB") 'ivy-partial)
;; (define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)

Expand Down
38 changes: 36 additions & 2 deletions home/config/doom/config.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Set Name and mail adress
** Font settings
#+begin_src elisp
(setq doom-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'light)
doom-big-font (font-spec :family "FiraCode Nerd Font" :size 28 :weight 'normal)
doom-unicode-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'normal)
doom-big-font (font-spec :family "FiraCode Nerd Font" :size 28 :weight 'light)
doom-unicode-font (font-spec :family "FiraCode Nerd Font" :size 14 :weight 'light)
doom-variable-pitch-font (font-spec :family "DejaVu Serif" :size 16 :weight 'normal))
#+end_src

Expand Down Expand Up @@ -47,6 +47,15 @@ I'm setting the title to be just "Emacs"
#+begin_src elisp
(setq frame-title-format "%b - Emacs")
#+end_src
** TODO Password Store location
I'm using ~pass~ (synced to my Bitwarden via a custom utility) to store/retrieve
secrets. Instead of the default location, my password storage lives at
~$HOME/.local/share/password-store~.

I need to set the env variable ~$PASSWORD_STORE_DIR~ to this location.
#+begin_src elisp
(setenv "PASSWORD_STORE_DIR" "~/.local/share/password-store")
#+end_src
* Utils
For efficiently writing my config, I need some utils.
** Add-Hooks
Expand Down Expand Up @@ -283,6 +292,12 @@ loaded or in a different repo.
(add-hook 'after-save-hook #'org-babel-tangle-config)))
#+end_src

*** Typescript
To execute typescript code blocks, I'm using the ~ob-typescript~ package.

#+begin_src elisp :tangle packages.el
(package! ob-typescript)
#+end_src
** Import/Export
*** View exported file
#+begin_src elisp
Expand Down Expand Up @@ -1473,6 +1488,25 @@ Now that everything's set up, I'm enabling the mode.

(The actual values obviously need to be tweaked though)

*** Better Error DIsplay
The posframe that flycheck-posframe is using for error display seems to linger
for a while, and does not disappear until you stop moving the cursor.

This snippet makes it disappear instantly:

#+begin_src elisp
(when (featurep! :checkers syntax +childframe)
(defun flycheck-posframe-monitor-post-command ()
(when (not (flycheck-posframe-check-position))
(posframe-hide flycheck-posframe-buffer)))

(defun fix-flycheck-posframe-not-hide-immediately ()
(cond (flycheck-posframe-mode
(add-hook 'post-command-hook 'flycheck-posframe-monitor-post-command nil t))
((not flycheck-posframe-mode)
(remove-hook 'post-command-hook 'flycheck-posframe-monitor-post-command t))))
(add-hook! flycheck-posframe-mode #'fix-flycheck-posframe-not-hide-immediately))
#+end_src
** Ivy
Ivy is a package that provides a completion framework for Emacs. It is
particularly useful for commands that require a lot of input, such as ~M-x~ or
Expand Down
2 changes: 1 addition & 1 deletion home/config/doom/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
vterm ; the best terminal emulation in Emacs

:checkers
syntax ; tasing you for every semicolon you forget
(syntax +childframe) ; tasing you for every semicolon you forget
;;(spell +flyspell) ; tasing you for misspelling mispelling
;;grammar ; tasing grammar mistake every you make

Expand Down
2 changes: 2 additions & 0 deletions home/config/doom/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

(package! org-modern)

(package! ob-typescript)

(package! org-fragtog)

(unpin! org-roam)
Expand Down
2 changes: 2 additions & 0 deletions home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ with mylib;
# Bun is a Node alternative
unstable.bun

esbuild

# Latex stuff TODO: move to a module
# texlive.combined.scheme-full
# GNU roff - typesetting, pdf converting stuff
Expand Down

0 comments on commit df453dc

Please sign in to comment.