Skip to content

Commit

Permalink
C-g: Deactivate mark if active, otherwise clear all.
Browse files Browse the repository at this point in the history
  • Loading branch information
magnars committed Jan 25, 2012
1 parent 0ef86db commit 89cef77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mark-multiple.el
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
(make-variable-buffer-local 'mm/mirrors)

(defvar mm/keymap (make-sparse-keymap))
(define-key mm/keymap (kbd "C-g") 'mm/clear-all)
(define-key mm/keymap (kbd "C-g") 'mm/deactivate-region-or-clear-all)
(define-key mm/keymap (kbd "C-m") 'mm/clear-all)
(define-key mm/keymap (kbd "<return>") 'mm/clear-all)

Expand Down Expand Up @@ -146,6 +146,13 @@ Point must be within the region."
(overlay-put mirror 'priority 100)
(overlay-put mirror 'face 'mm/mirror-face)))

(defun mm/deactivate-region-or-clear-all ()
"Deactivate mark if active, otherwise clear all."
(interactive)
(if (use-region-p)
(deactivate-mark)
(mm/clear-all)))

(defun mm/clear-all ()
"Remove all marks"
(interactive)
Expand Down Expand Up @@ -252,4 +259,4 @@ Point must be within the region."

(provide 'mark-multiple)

;;; mark-multiple.el ends here
;;; mark-multiple.el ends here

0 comments on commit 89cef77

Please sign in to comment.