From c8217a3a7b3f1ef0c101f040d182c08833d0f38e Mon Sep 17 00:00:00 2001 From: Nathan Moreau Date: Sun, 3 Nov 2019 01:09:43 +0100 Subject: Fix rust-insert-dbg for emacs-version < 25. (#339) --- rust-mode.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust-mode.el b/rust-mode.el index 42b8d82..b381893 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -1805,8 +1805,11 @@ visit the new file." (defun rust-insert-dbg () "Insert the dbg! macro." (cond ((region-active-p) - (insert-parentheses) - (backward-char 1)) + (when (< (mark) (point)) + (exchange-point-and-mark)) + (let ((old-point (point))) + (insert-parentheses) + (goto-char old-point))) (t (insert "(") (forward-sexp) -- cgit v1.2.3