diff options
author | Case Duckworth | 2022-07-07 23:09:06 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-07 23:09:06 -0500 |
commit | 7cbaa82c48741e20a96106904e4cccc676723f47 (patch) | |
tree | 57f1f66874511127b0c05135235166e5deb25f81 /lisp | |
parent | bleh (diff) | |
download | emacs-7cbaa82c48741e20a96106904e4cccc676723f47.tar.gz emacs-7cbaa82c48741e20a96106904e4cccc676723f47.zip |
Add goto-matching-paren
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+emacs.el | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index d6071a3..322e8a9 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el | |||
@@ -119,7 +119,7 @@ Do this only if the buffer is not visiting a file." | |||
119 | sentence-end-double-space t | 119 | sentence-end-double-space t |
120 | set-mark-command-repeat-pop t | 120 | set-mark-command-repeat-pop t |
121 | show-paren-delay 0 | 121 | show-paren-delay 0 |
122 | show-paren-style 'mixed | 122 | show-paren-style 'parenthesis |
123 | show-paren-when-point-in-periphery t | 123 | show-paren-when-point-in-periphery t |
124 | show-paren-when-point-inside-paren t | 124 | show-paren-when-point-inside-paren t |
125 | ;;show-trailing-whitespace t | 125 | ;;show-trailing-whitespace t |
@@ -286,7 +286,7 @@ ARG is passed to `backward-kill-word'." | |||
286 | (interactive "P") | 286 | (interactive "P") |
287 | (+backward-kill-word-wrapper #'backward-kill-word arg)) | 287 | (+backward-kill-word-wrapper #'backward-kill-word arg)) |
288 | 288 | ||
289 | ;; ... and advice | 289 | ;;; ... and advice |
290 | 290 | ||
291 | ;; Indent the region after a yank. | 291 | ;; Indent the region after a yank. |
292 | (defun +yank@indent (&rest _) | 292 | (defun +yank@indent (&rest _) |
@@ -302,23 +302,34 @@ ARG is passed to `backward-kill-word'." | |||
302 | "Predicate for `save-some-buffers-default-predicate'. | 302 | "Predicate for `save-some-buffers-default-predicate'. |
303 | It returns nil with remote files." | 303 | It returns nil with remote files." |
304 | (not (file-remote-p (buffer-file-name)))) | 304 | (not (file-remote-p (buffer-file-name)))) |
305 | |||
306 | ;; https://www.wwwtech.de/articles/2013/may/emacs:-jump-to-matching-paren-beginning-of-block | ||
307 | (defun +goto-matching-paren (&optional arg) | ||
308 | "Go to the matching paren, similar to vi's %." | ||
309 | (interactive "p") | ||
310 | (or arg (setq arg 1)) | ||
311 | (cond | ||
312 | ;; Check for "outside of bracket" positions | ||
313 | ((looking-at "[\[\(\{]") (forward-sexp arg)) | ||
314 | ((looking-back "[\]\)\}]" 1) (backward-sexp arg)) | ||
315 | ;; Otherwise, move from inside the bracket | ||
316 | ((looking-at "[\]\)\}]") (forward-char) (backward-sexp arg)) | ||
317 | ((looking-back "[\[\(\{]" 1) (backward-char) (forward-sexp arg)) | ||
318 | (t (up-list arg t t)))) | ||
319 | |||
305 | 320 | ||
306 | ;;; Bindings | 321 | ;;; Bindings |
307 | 322 | ||
308 | ;; I need to place these bindings under `+key-mode-map' so that they aren't | 323 | (define-key (current-global-map) (kbd "C-x C-c") #'+save-buffers-quit) |
309 | ;; shadowed by other maps. There might be a better way to do this. | 324 | (define-key (current-global-map) (kbd "M-SPC") #'+cycle-spacing) |
310 | (require '+key) | 325 | (define-key (current-global-map) (kbd "M-/") #'hippie-expand) |
311 | 326 | (define-key (current-global-map) (kbd "M-=") #'count-words) | |
312 | (dolist (binding '(("C-x C-c" . +save-buffers-quit) | 327 | (define-key (current-global-map) (kbd "C-x C-b") #'ibuffer) |
313 | ("M-SPC" . +cycle-spacing) | 328 | (define-key (current-global-map) (kbd "C-s") #'isearch-forward-regexp) |
314 | ("M-/" . hippie-expand) | 329 | (define-key (current-global-map) (kbd "C-r") #'isearch-backward-regexp) |
315 | ("M-=" . count-words) | 330 | (define-key (current-global-map) (kbd "C-M-s") #'isearch-forward) |
316 | ("C-x C-b" . ibuffer) | 331 | (define-key (current-global-map) (kbd "C-M-r") #'isearch-backward) |
317 | ("C-s" . isearch-forward-regexp) | 332 | (define-key (current-global-map) (kbd "C-M--") #'+goto-matching-paren) |
318 | ("C-r" . isearch-backward-regexp) | ||
319 | ("C-M-s" . isearch-forward) | ||
320 | ("C-M-r" . isearch-backward))) | ||
321 | (define-key (current-global-map) (kbd (car binding)) (cdr binding))) | ||
322 | 333 | ||
323 | 334 | ||
324 | ;;; Required libraries | 335 | ;;; Required libraries |