つい最近は、重複が含まれるURLの一覧から重複を除去するためにUNIXのuniqコマンド相当の自作elispを使った。
まずはURL一覧をEmacsにコピーし、
M-% /index.html /する。次に以下の内容をロードした状態でM-x sort-lines、M-x uniqで重複がなくなる。(require 'cl)
(defmacro* narrow-if-needed (&body body)
"transient-mark-modeだった場合はbodyのオペレーションがリージョン内に制限される"
`(lexical-let ((needed (and transient-mark-mode mark-active))
result)
(if needed (narrow-to-region (region-beginning) (region-end)))
(setq result (progn ,@body))
(if needed (widen))
result))
(defun* uniq ()
"uniqコマンドに相当する。transient-mark-modeだった場合はリージョンに対してのみ作用する"
(interactive)
(narrow-if-needed
(beginning-of-buffer)
(while (re-search-forward "\\(.*\n\\)\\1+" nil t)
(replace-match "\\1" nil nil))))