diff options
Diffstat (limited to 'lisp/ravi-init-marks.el')
| -rw-r--r-- | lisp/ravi-init-marks.el | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lisp/ravi-init-marks.el b/lisp/ravi-init-marks.el new file mode 100644 index 0000000..803b2cb --- /dev/null +++ b/lisp/ravi-init-marks.el @@ -0,0 +1,78 @@ +;;; ravi-init-marks.el --- Handling the mark + +;; Copyright (C) 2013 + +;; Author: <ravi@nero.lan> +;; 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 <http://www.gnu.org/licenses/>. + +;;; 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) + :ensure t + :if (not ravi/use-helm-instead-of-ido) + ) + +(provide 'ravi-init-marks) +;;; ravi-init-marks.el ends here |
