Created
April 30, 2015 02:21
-
-
Save johnmastro/508fb22a2b4e1ce754e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; An attempt at this Emacs SX question: | |
;; https://emacs.stackexchange.com/questions/10359/delete-portion-of-isearch-string-that-does-not-match-or-last-char-if-complete-m | |
(defun isearch-delete-something () | |
"Delete non-matching text or the last character." | |
;; Mostly copied from `isearch-del-char' and Drew's answer on the page above | |
(interactive) | |
(if (= 0 (length isearch-string)) | |
(ding) | |
(setq isearch-string | |
(substring isearch-string | |
0 | |
(or (isearch-fail-pos) (1- (length isearch-string))))) | |
(setq isearch-message | |
(mapconcat #'isearch-text-char-description isearch-string ""))) | |
(if isearch-other-end (goto-char isearch-other-end)) | |
(isearch-search) | |
(isearch-push-state) | |
(isearch-update)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment