Created
November 19, 2010 14:51
-
-
Save baron/706601 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
;;;_ , my-remove-duplicates | |
; This little fellow is great. It removes duplicates from region i.e. | |
; transforms "foo baz foo bar baz" into "foo baz bar". | |
(defun my-remove-duplicates (start end) | |
(interactive "r") | |
(save-excursion | |
(goto-char start) | |
(narrow-to-region start end) | |
(let ((seen nil) (word nil) (s start)) | |
(while (forward-word) | |
(when (setq word (word-at-point)) | |
(if (member word seen) | |
(kill-region s (point)) | |
(setq seen (cons word seen)) )) | |
(setq s (point)))) | |
(widen)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment