branch: elpa/rust-mode
commit c8217a3a7b3f1ef0c101f040d182c08833d0f38e
Author: Nathan Moreau <[email protected]>
Commit: GitHub <[email protected]>

    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)

Reply via email to