Get rid of lambdas and scope defuns
This commit is contained in:
parent
d46069050c
commit
ac288e5ad0
93
config.el
93
config.el
@ -102,12 +102,14 @@
|
||||
(advice-remove 'newline-and-indent
|
||||
#'+default--newline-indent-and-continue-comments-a)
|
||||
|
||||
;; Add some extra whitespace highlights to doom's opinion.
|
||||
(advice-add 'doom-highlight-non-default-indentation-h
|
||||
:after
|
||||
(lambda () (when (bound-and-true-p whitespace-mode)
|
||||
;; Doom already uses whitespace-mode to highlight unexpected indentation. Add
|
||||
;; some extras by defining an advice function.
|
||||
(defadvice! +doom-highlight-unwanted-space-h nil
|
||||
"Add some extra whitespace highlights to doom's opinion"
|
||||
:after #'doom-highlight-non-default-indentation-h
|
||||
(when (bound-and-true-p whitespace-mode)
|
||||
(appendq! whitespace-style '(trailing lines-tail empty))
|
||||
(whitespace-mode +1))))
|
||||
(whitespace-mode +1)))
|
||||
|
||||
;; I actually like it when Emacs recenters the screen while scrolling. This may
|
||||
;; be an issue in large files. When that becomes an issue add an exception here.
|
||||
@ -119,16 +121,15 @@
|
||||
|
||||
;; Fix git-gutter advice for magit.
|
||||
(after! (:all git-gutter magit)
|
||||
;; Define a function that updates all visible buffers.
|
||||
(defun +vc-gutter-update-visible-buffers-h (&rest _)
|
||||
;; Update all visible buffers when (un)staging in the magit buffer.
|
||||
(defadvice! +vc-gutter-update-visible-buffers-h (&rest _)
|
||||
"Update vc-gutter in all visible buffers."
|
||||
:after #'magit-stage
|
||||
:after #'magit-unstage
|
||||
(save-excursion
|
||||
(dolist (buffer (doom-visible-buffers) nil)
|
||||
(with-current-buffer buffer
|
||||
(+vc-gutter-update-h)))))
|
||||
|
||||
;; And add this as new advice to the magit functions.
|
||||
(advice-add 'magit-stage :after #'+vc-gutter-update-visible-buffers-h)
|
||||
(advice-add 'magit-unstage :after #'+vc-gutter-update-visible-buffers-h))
|
||||
(+vc-gutter-update-h))))))
|
||||
|
||||
;; Disable hl-line-mode everywhere.
|
||||
(after! hl-line (setq global-hl-line-modes nil))
|
||||
@ -163,7 +164,8 @@
|
||||
;; The only thing I actually missed from helm.
|
||||
(map! (:when (featurep! :completion vertico)
|
||||
:map vertico-map
|
||||
"C-l" (lambda ()
|
||||
"C-l" (defun +vertico-directory-delete-one-word ()
|
||||
"Delete one directory or word before point."
|
||||
(interactive)
|
||||
(vertico-directory-delete-word 1))))
|
||||
|
||||
@ -191,20 +193,19 @@
|
||||
;; A nicer interface for ripgrep. Note that since doom required rg we don't
|
||||
;; consider the case if it's not installed.
|
||||
(use-package! deadgrep
|
||||
:bind (("C-x C-g" . deadgrep))
|
||||
:init
|
||||
(setq deadgrep-project-root-function
|
||||
(lambda ()
|
||||
(defun +deadgrep-project-root ()
|
||||
"Provide a base directory for deadgrep."
|
||||
(read-directory-name "Base directory: " nil default-directory t)))
|
||||
:bind
|
||||
(("C-x C-g" . deadgrep))
|
||||
(:map deadgrep-mode-map
|
||||
("C-o" . +deadgrep-open-result-other-window)
|
||||
("<RET>" . deadgrep-visit-result-other-window))
|
||||
:config
|
||||
(defun +deadgrep-open-result-other-window ()
|
||||
(map! (:map deadgrep-mode-map
|
||||
"C-o" (defun +deadgrep-open-result-other-window ()
|
||||
"Open the result in other window without changing to it."
|
||||
(interactive)
|
||||
(save-selected-window (deadgrep-visit-result-other-window))))
|
||||
(save-selected-window (deadgrep-visit-result-other-window)))
|
||||
"<RET>" #'deadgrep-visit-result-other-window)))
|
||||
|
||||
;; Duplicate things.
|
||||
(use-package! duplicate-thing
|
||||
@ -239,8 +240,10 @@
|
||||
|
||||
;; Highlight lines that are too long in whitespace mode. We set this with a hook
|
||||
;; after local variables as fill-column is often set through dir-locals.
|
||||
(add-hook 'hack-local-variables-hook
|
||||
(lambda () (setq-local whitespace-line-column fill-column)))
|
||||
(add-hook! 'hack-local-variables-hook
|
||||
(defun +update-whitespace-line-column ()
|
||||
"Change `whitespace-line-column' to that of `fill-column'."
|
||||
(setq-local whitespace-line-column fill-column)))
|
||||
|
||||
;; CamelCase as separate words.
|
||||
(global-subword-mode +1)
|
||||
@ -254,14 +257,32 @@
|
||||
(defalias #'end-of-visual-line #'end-of-line)
|
||||
(defalias #'beginning-of-visual-line #'beginning-of-line)
|
||||
|
||||
(defun +indent-region-or-buffer ()
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Global keybindings.
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(map!
|
||||
"C-M-\\" (defun indent-region-or-buffer ()
|
||||
"Indent a region if selected, otherwise the whole buffer."
|
||||
(interactive)
|
||||
(if (region-active-p)
|
||||
(indent-region (region-beginning) (region-end))
|
||||
(indent-region (point-min) (point-max))))
|
||||
|
||||
(defun +unfill-paragraph (&optional region)
|
||||
"C-x k" #'kill-current-buffer
|
||||
|
||||
"C-<" (defun scroll-down-one ()
|
||||
"Scroll text (but not the point) of selected window downward one line."
|
||||
(interactive)
|
||||
(let ((scroll-preserve-screen-position nil)) (scroll-down 1)))
|
||||
|
||||
"C->" (defun scroll-up-one ()
|
||||
"Scroll text (but not the point) of selected window upward one line."
|
||||
(interactive)
|
||||
(let ((scroll-preserve-screen-position nil)) (scroll-up 1)))
|
||||
|
||||
"M-Q" (defun unfill-paragraph (&optional region)
|
||||
"Takes a multi-line paragraph and makes it into a single line of text."
|
||||
(interactive (progn (barf-if-buffer-read-only) '(t)))
|
||||
(let ((fill-column (point-max))
|
||||
@ -269,28 +290,8 @@
|
||||
(emacs-lisp-docstring-fill-column t))
|
||||
(fill-paragraph nil region)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Global keybindings.
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(map!
|
||||
;; For functions defined above.
|
||||
"M-Q" #'+unfill-paragraph
|
||||
"C-M-\\" #'+indent-region-or-buffer
|
||||
;; Create binding before dired is loaded.
|
||||
"C-x C-j" #'dired-jump
|
||||
;; More convenient window switching.
|
||||
"M-o" #'other-window
|
||||
"C-x o" #'other-popup
|
||||
;; Kill current buffer without prompting.
|
||||
:desc "kill-buffer"
|
||||
"C-x k" (lambda ()
|
||||
(interactive)
|
||||
(let (kill-buffer-query-functions) (kill-buffer)))
|
||||
;; Scroll up/down, but keep point in place.
|
||||
"C-<" (lambda()
|
||||
(interactive)
|
||||
(let ((scroll-preserve-screen-position nil)) (scroll-down 1)))
|
||||
"C->" (lambda()
|
||||
(interactive)
|
||||
(let ((scroll-preserve-screen-position nil)) (scroll-up 1))))
|
||||
"C-x o" #'other-popup)
|
||||
|
Loading…
Reference in New Issue
Block a user