emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

uniq


From: Tak Ota
Subject: uniq
Date: Fri, 3 Dec 2010 18:41:12 -0800

Do we have something equivalent to the next command?  I know the name
is bad as it is not same as UNIQ(1).  It works better because sorting
is not required.

-Tak

;;
;; uniq
;;
(defun uniq ()
  "Omit duplicated lines."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (not (= (point) (point-max)))
      (let* ((start (point))
             (str (format "^%s"
                          (regexp-quote
                           (buffer-substring start
                                             (progn (forward-line 1) 
(point)))))))
        (save-excursion
          (while (re-search-forward str nil t)
            (delete-region (match-beginning 0) (match-end 0))))))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]