;;; ravi-init-marks.el --- Handling the mark ;; Copyright (C) 2013 ;; Author: ;; Keywords: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Handling the mark ;;; Code: ;; Show active region (transient-mark-mode 1) (make-variable-buffer-local 'transient-mark-mode) (put 'transient-mark-mode 'permanent-local t) (setq-default transient-mark-mode t) ;; When popping the mark, continue popping until the cursor actually moves ;; Also, if the last command was a copy - skip past all the expand-region cruft. ;; Stolen from Magnar Sveen's emacs.d on github. (defadvice pop-to-mark-command (around ensure-new-position activate) (let ((p (point))) (when (eq last-command 'save-region-or-current-line) ad-do-it ad-do-it ad-do-it) (dotimes (i 10) (when (= p (point)) ad-do-it)))) ;; Allow mark-based navigation even in transient-mark-mode; see ;; http://www.masteringemacs.org/articles/2010/12/22/fixing-mark-commands-transient-mark-mode/ (defun ravi/push-mark-no-activate () "Pushes `point' to `mark-ring' and does not activate the region Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" (interactive) (push-mark (point) t nil) (message "Pushed mark to ring")) (bind-key "C-`" 'ravi/push-mark-no-activate) (defun ravi/jump-to-mark () "Jumps to the local mark, respecting the `mark-ring' order. This is the same as using \\[set-mark-command] with the prefix argument." (interactive) (set-mark-command 1)) (bind-key "M-`" 'ravi/jump-to-mark) ; Prevents C-x C-x from highlighting region (defun ravi/exchange-point-and-mark-no-activate () "Identical to \\[exchange-point-and-mark] but will not activate the region." (interactive) (exchange-point-and-mark) (deactivate-mark nil)) (define-key global-map [remap exchange-point-and-mark] 'ravi/exchange-point-and-mark-no-activate) (use-package browse-kill-ring :config (browse-kill-ring-default-keybindings) :if (equal ravi/use-selection-system 'ido)) ; to do something for selectrum (provide 'ravi-init-marks) ;;; ravi-init-marks.el ends here