[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sat, 04 Dec 2010 13:08:28 +0100
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
On Fri, 3 Dec 2010 18:41:12 -0800 Tak Ota <address@hidden> wrote:
> 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.
> ;; uniq
> (defun uniq ()
> "Omit duplicated lines."
> (goto-char (point-min))
> (while (not (= (point) (point-max)))
> (let* ((start (point))
> (str (format "^%s"
> (buffer-substring start
> (progn (forward-line 1)
> (while (re-search-forward str nil t)
> (delete-region (match-beginning 0) (match-end 0))))))))
Would it be faster to avoid nested while-loops?
(defun uniq ()
"Omit duplicated lines."
(while (not (eobp))
(let* ((beg (line-beginning-position))
(line (buffer-substring beg end)))
(if (member line lines)
(delete-region beg (1+ end))
(push line lines)
- uniq, Tak Ota, 2010/12/03
- Re: uniq,
Stephen Berman <=