diff options
| author | Ravi R Kiran <aine.marina@gmail.com> | 2014-07-05 22:48:24 (GMT) |
|---|---|---|
| committer | Ravi R Kiran <aine.marina@gmail.com> | 2014-07-05 22:48:24 (GMT) |
| commit | 0ecc73c6b9996e2235d43be0d44288fe7aecc9ec (patch) | |
| tree | 2968f80ba5cc8960053dd2e989c13aaa6095cf98 /ravi-init-navigation.el | |
| parent | 1e07f4169095ae9f8e62c7554a9f553076438a41 (diff) | |
| download | dotemacs-0ecc73c6b9996e2235d43be0d44288fe7aecc9ec.zip dotemacs-0ecc73c6b9996e2235d43be0d44288fe7aecc9ec.tar.gz dotemacs-0ecc73c6b9996e2235d43be0d44288fe7aecc9ec.tar.bz2 | |
More isearch goodies from EmacsWiki
Diffstat (limited to 'ravi-init-navigation.el')
| -rw-r--r-- | ravi-init-navigation.el | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 36e823b..391be8b 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -262,6 +262,46 @@ ) ) +;; Delete via isearch +(defun zap-to-isearch (rbeg rend) + "Kill the region between the mark and the closest portion of + the isearch match string. The behaviour is meant to be analogous + to zap-to-char; let's call it zap-to-isearch. The deleted region + does not include the isearch word. This is meant to be bound only + in isearch mode. + + The point of this function is that oftentimes you want to delete + some portion of text, one end of which happens to be an active + isearch word. The observation to make is that if you use isearch + a lot to move the cursor around (as you should, it is much more + efficient than using the arrows), it happens a lot that you could + just delete the active region between the mark and the point, not + include the isearch word." + (interactive "r") + (when (not mark-active) + (error "Mark is not active")) + (let* ((isearch-bounds (list isearch-other-end (point))) + (ismin (apply 'min isearch-bounds)) + (ismax (apply 'max isearch-bounds)) + ) + (if (< (mark) ismin) + (kill-region (mark) ismin) + (if (> (mark) ismax) + (kill-region ismax (mark)) + (error "Internal error in isearch kill function."))) + (isearch-exit) + )) +(bind-key "M-z" 'zap-to-isearch isearch-mode-map) + +;; Exit isearch at the beginning +(defun isearch-exit-other-end (rbeg rend) + "Exit isearch, but at the other end of the search string. + This is useful when followed by an immediate kill." + (interactive "r") + (isearch-exit) + (goto-char isearch-other-end)) +(bind-key "<C-return>" 'isearch-exit-other-end isearch-mode-map) + ;; Search the web (use-package webjump :bind ("C-x g" . webjump) |
