diff options
Diffstat (limited to '.emacs.d/lisp/rust-utils.el')
| -rw-r--r-- | .emacs.d/lisp/rust-utils.el | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/.emacs.d/lisp/rust-utils.el b/.emacs.d/lisp/rust-utils.el index cb55172..d93bd0a 100644 --- a/.emacs.d/lisp/rust-utils.el +++ b/.emacs.d/lisp/rust-utils.el | |||
| @@ -41,22 +41,22 @@ visit the new file." | |||
| 41 | if not. Move cursor to the end of macro." | 41 | if not. Move cursor to the end of macro." |
| 42 | (when (rust-in-str) | 42 | (when (rust-in-str) |
| 43 | (up-list -1 t t)) | 43 | (up-list -1 t t)) |
| 44 | (setq safe-to-forward t) | 44 | (let ((safe-to-forward t)) |
| 45 | (save-excursion | 45 | (save-excursion |
| 46 | (condition-case nil | 46 | (condition-case nil |
| 47 | (forward-sexp) | 47 | (forward-sexp) |
| 48 | (error (setq safe-to-forward nil) | 48 | (error (setq safe-to-forward nil) |
| 49 | nil))) | 49 | nil))) |
| 50 | (cond | 50 | (cond |
| 51 | ((not safe-to-forward) | 51 | ((not safe-to-forward) |
| 52 | (rust-insert-dbg-alone)) | 52 | (rust-insert-dbg-alone)) |
| 53 | (t | 53 | (t |
| 54 | (insert "(") | 54 | (insert "(") |
| 55 | (forward-sexp) | 55 | (forward-sexp) |
| 56 | (insert ")") | 56 | (insert ")") |
| 57 | (backward-sexp) | 57 | (backward-sexp) |
| 58 | (insert "dbg!") | 58 | (insert "dbg!") |
| 59 | (forward-sexp)))) | 59 | (forward-sexp))))) |
| 60 | 60 | ||
| 61 | (defun rust-insert-dbg-region () | 61 | (defun rust-insert-dbg-region () |
| 62 | "Insert the dbg! macro around a region. Move cursor to the end of macro." | 62 | "Insert the dbg! macro around a region. Move cursor to the end of macro." |
| @@ -77,9 +77,9 @@ if not. Move cursor to the end of macro." | |||
| 77 | (defun rust-dbg-wrap-or-unwrap () | 77 | (defun rust-dbg-wrap-or-unwrap () |
| 78 | "Either remove or add the dbg! macro." | 78 | "Either remove or add the dbg! macro." |
| 79 | (interactive) | 79 | (interactive) |
| 80 | 80 | ||
| 81 | (cond | 81 | (cond |
| 82 | 82 | ||
| 83 | ;; region | 83 | ;; region |
| 84 | ((region-active-p) | 84 | ((region-active-p) |
| 85 | (rust-insert-dbg-region)) | 85 | (rust-insert-dbg-region)) |
| @@ -106,7 +106,7 @@ if not. Move cursor to the end of macro." | |||
| 106 | (delete-pair)) | 106 | (delete-pair)) |
| 107 | (t (rust-insert-dbg-sexp))))) | 107 | (t (rust-insert-dbg-sexp))))) |
| 108 | ) | 108 | ) |
| 109 | ) | 109 | ) |
| 110 | 110 | ||
| 111 | (defun rust-toggle-mutability () | 111 | (defun rust-toggle-mutability () |
| 112 | "Toggles the mutability of the variable defined on the current line" | 112 | "Toggles the mutability of the variable defined on the current line" |
