From unknown Sat Jun 21 02:54:37 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#13032 <13032@debbugs.gnu.org> To: bug#13032 <13032@debbugs.gnu.org> Subject: Status: 24.3.50; Request: Provide a `delete-duplicate-lines' command Reply-To: bug#13032 <13032@debbugs.gnu.org> Date: Sat, 21 Jun 2025 09:54:37 +0000 retitle 13032 24.3.50; Request: Provide a `delete-duplicate-lines' command reassign 13032 emacs submitter 13032 Dani Moncayo severity 13032 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 14:25:25 2012 Received: (at submit) by debbugs.gnu.org; 29 Nov 2012 19:25:25 +0000 Received: from localhost ([127.0.0.1]:45563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Te9jf-0000WF-HL for submit@debbugs.gnu.org; Thu, 29 Nov 2012 14:25:24 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33380) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Te9je-0000W9-4u for submit@debbugs.gnu.org; Thu, 29 Nov 2012 14:25:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Te9hf-0005Dz-US for submit@debbugs.gnu.org; Thu, 29 Nov 2012 14:23:20 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:37633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te9hf-0005Dv-R6 for submit@debbugs.gnu.org; Thu, 29 Nov 2012 14:23:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te9he-0001lm-TI for bug-gnu-emacs@gnu.org; Thu, 29 Nov 2012 14:23:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Te9hd-0005Dd-Ps for bug-gnu-emacs@gnu.org; Thu, 29 Nov 2012 14:23:18 -0500 Received: from mail-ob0-f169.google.com ([209.85.214.169]:63401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te9hd-0005DW-Jj for bug-gnu-emacs@gnu.org; Thu, 29 Nov 2012 14:23:17 -0500 Received: by mail-ob0-f169.google.com with SMTP id lz20so15502486obb.0 for ; Thu, 29 Nov 2012 11:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=cZAcsF//HcFblNwPAAlDJTpbKJmneC8ZAV0f2FV+BSI=; b=NL5KKrhcXsaPWS7ROIy9YIamgeLcdJNSLPBVEFxJYG9Hp00BJzGGpWb9EdHmsEh87E LifmWJXD4g7yLkC4W1cFGDaJuFR/cJ8a50POT5sHpg3/g29acQPBiEbPTl2fIYFXjxvL 4hYuD1pEVG6hDyAaXkDtXrwu/DO/9suIB+DYytSQjgK3MRMaCMj9zKAO+PbC+Csa0CWt jxflVI6Rmf5qnS1DvObn0x/S3UG3/BwIMgL57zpUVTpTHSXSKCYVKhWq8xy96YIcyPQV b/f4vwRSPTJ13qp3MImPPKVhd/tjRO8yvENs18kjWjk+a6Q6yGzp8B+EpFmjWjidSCcl +xtg== MIME-Version: 1.0 Received: by 10.182.116.6 with SMTP id js6mr8793058obb.82.1354216997043; Thu, 29 Nov 2012 11:23:17 -0800 (PST) Received: by 10.60.64.170 with HTTP; Thu, 29 Nov 2012 11:23:16 -0800 (PST) Date: Thu, 29 Nov 2012 20:23:16 +0100 Message-ID: Subject: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) Severity: wishlist Recent versions of MS-Excel and also LibreOffice's Calc have a feature that I find very useful: the ability of remove duplicate lines from a given list (range). I think it would be worth to add such a feature to Emacs. That is: provide a function `delete-duplicate-lines' (or some such) that removes all duplicate lines in the active region and prints in the echo area a message like "Duplicate lines removed: ". TIA. PS: There has been some discussion about this in this thread: http://lists.gnu.org/archive/html/help-gnu-emacs/2012-11/msg00417.html. Jambunathan K provided a possible implementation, but it lacks the message in the echo area (which I think is important). In GNU Emacs 24.3.50.1 (i386-mingw-nt6.1.7601) of 2012-11-28 on MS-W7-DANI Bzr revision: 111021 jay.p.belanger@gmail.com-20121128045113-o6xvwncuryx8al3u Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --with-gcc (4.7) --no-opt --enable-checking --cflags -Ic:/emacs/libs/libXpm-3.5.10/include -Ic:/emacs/libs/libXpm-3.5.10/src -Ic:/emacs/libs/libpng-1.2.37-lib/include -Ic:/emacs/libs/zlib-1.2.5 -Ic:/emacs/libs/giflib-4.1.4-1-lib/include -Ic:/emacs/libs/jpeg-6b-4-lib/include -Ic:/emacs/libs/tiff-3.8.2-1-lib/include -Ic:/emacs/libs/libxml2-2.7.8-w32-bin/include/libxml2 -Ic:/emacs/libs/gnutls-3.0.9-w32-bin/include -Ic:/emacs/libs/libiconv-1.9.2-1-lib/include' Important settings: value of $LANG: ENU locale-coding-system: cp1252 default enable-multibyte-characters: t -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 15:52:34 2012 Received: (at 13032) by debbugs.gnu.org; 29 Nov 2012 20:52:34 +0000 Received: from localhost ([127.0.0.1]:45643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeB61-0002ca-UA for submit@debbugs.gnu.org; Thu, 29 Nov 2012 15:52:34 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:54965) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeB60-0002cT-Dr for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 15:52:33 -0500 Received: by mail-ee0-f44.google.com with SMTP id b47so9293952eek.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 12:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=FbVh9AvUvK34Imscu51Hh8l1llrrQG1oKoRbNt7VTDw=; b=Bhm/Op8TfSCBJ5jYP5hBnAuBgZMtqCYrv0Qusc9yudNevmyRDeAbsI9ojIAMwzC+QG gi7/I7yFufeTeOVEW1CH1V3IbxfVFJVbRJB40v1I9rjLk9pdVUqo87tWKaqFMgpFmhRP 1W5V+4f3I/M3lJH5yV6L3E5wL9oM68M9n0Nw7mZsMZo9T+pDE3xzAco+AQ3zl7lSEhkB Qj0lZGjsYw5a2Vl5bH+nTMeFyJn3aAaWqA/HC0B0McAajvYzA0Mjj5C6pXz2mNPKzOVk jC7y7lSt5SKcQ0KTz02vAruKsTUvVGv+4dLseSgMl3JzV7n9Eq0O08HzLmXkOQuYHwub gsGg== Received: by 10.14.203.2 with SMTP id e2mr85906453eeo.20.1354222228753; Thu, 29 Nov 2012 12:50:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.4.209 with HTTP; Thu, 29 Nov 2012 12:49:47 -0800 (PST) In-Reply-To: References: From: Juanma Barranquero Date: Thu, 29 Nov 2012 21:49:47 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command To: Dani Moncayo Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) On Thu, Nov 29, 2012 at 8:23 PM, Dani Moncayo wrote: > Severity: wishlist > That is: provide a function `delete-duplicate-lines' (or some such) > that removes all duplicate lines in the active region and prints in > the echo area a message like "Duplicate lines removed: ". Perhaps you can work from this (not very well tested): (defun delete-duplicate-lines (beg end) "Delete consecutive duplicate lines in region BEG..END." (interactive "r") (save-excursion (save-restriction (narrow-to-region beg end) (goto-char beg) (let ((kill-whole-line t) (last (buffer-substring (line-beginning-position) (line-end-position))) (removed 0) current) (forward-line 1) (while (and (< (point) (or end 1)) (not (eobp))) (setq current (buffer-substring (line-beginning-position) (line-end-position))) (if (string= last current) (progn (kill-line) (setq removed (1+ removed))) (setq last current) (forward-line 1))) (message "Duplicate lines removed: %d" removed))))) From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 16:46:00 2012 Received: (at 13032) by debbugs.gnu.org; 29 Nov 2012 21:46:00 +0000 Received: from localhost ([127.0.0.1]:45659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeBvj-0003uL-Ji for submit@debbugs.gnu.org; Thu, 29 Nov 2012 16:46:00 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:33168) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeBvh-0003uE-KN for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 16:45:58 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so14507695oag.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 13:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=esoqLSLHRG9zJdKcU58pfVIa18QOTSKcl5eqdmhULYg=; b=iCYlJt5p14MXqHZJA8QXr+s2DycGZvUMIUjQtYrSASonagFbisGNIqpxL4tRZxjwjZ NLy7yzhpPi9jWie2WCUm83opa1BMarYm8KYp9pcE94lFunmBYWd7niMqrnypEj8xQXos 2DAuFLe9gTqyqz2k9YLqWsuZEMKgUms0yWPp9CrSmMK2fYgbxvDx1RzoDna8ojznujR6 dOA7SwUEPFmGcrfm8Dur5wPxoOMcbcEVoU9cataHkTmjZUnrXUq+IYRJTAHEQJtz0tkh hszwfMGkr4mtG73wjGJG6j9vcjsAqAKHQNjv86k7/ILZzQzEGeA7+OIxZgq7Sqc3s/i6 iCjg== MIME-Version: 1.0 Received: by 10.182.130.38 with SMTP id ob6mr9271434obb.100.1354225433913; Thu, 29 Nov 2012 13:43:53 -0800 (PST) Received: by 10.60.64.170 with HTTP; Thu, 29 Nov 2012 13:43:53 -0800 (PST) In-Reply-To: References: Date: Thu, 29 Nov 2012 22:43:53 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juanma Barranquero Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) > Perhaps you can work from this (not very well tested): Thank you Juanma. I've given it a quick try and it seems to work. I've only seen a minor detail that I don't like: when the command does nothing (because there are no consecutive duplicate lines), the region remains active. But this is a general problem in Emacs which I've already complained about (bug #10056). IMO, the mark should be deactivated after every command that operates on the active region, without regard to whether the buffer was changed or not. There could be some exception, but this should be the general principle. I'll put your version in my init file for now, while the maintainers decide whether it is appropriate to add this command to Emacs or not. Thanks. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 17:47:49 2012 Received: (at 13032) by debbugs.gnu.org; 29 Nov 2012 22:47:49 +0000 Received: from localhost ([127.0.0.1]:45684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeCtY-0005Jo-Nb for submit@debbugs.gnu.org; Thu, 29 Nov 2012 17:47:49 -0500 Received: from mail-ea0-f172.google.com ([209.85.215.172]:48448) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeCtW-0005Jg-UI for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 17:47:47 -0500 Received: by mail-ea0-f172.google.com with SMTP id a1so5686881eaa.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 14:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PHVQXZCpQEOLPhXRlvZTLEggAiOYBZz6L9VFxe15cj0=; b=H59C+UumRCXC/X8ZzpE/2Qn2RLr6yTJEb0WzJgKt8CFHV5nMKyvJBBIK80YtG+Fp8S hD6Re3P2vdjedXHzh1kGFZ90fFmaBoBdsfPrH1fLZzqjf+h8i5R0Rrd6Guo+1XrSJeLa Nime20AqIIrYrogI6YH+pnFIiv83Jyq4kuwoesq8Axv9KCigaXzyVyXafNBekr22jZOz winE4OMETWLh9sktIussZq50p34b68gSfJx1Cg4+scRRCzXxFXGEpc2JttbwoTUEfdDM K75c7ETnvwXnw4LkHRP4EIBQFRloitQj74dPDNhBDtQsKLZM/0kQ8UMYGLBlGtjql8d8 EYPQ== Received: by 10.14.207.6 with SMTP id m6mr43856577eeo.10.1354229142798; Thu, 29 Nov 2012 14:45:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.4.209 with HTTP; Thu, 29 Nov 2012 14:45:02 -0800 (PST) In-Reply-To: References: From: Juanma Barranquero Date: Thu, 29 Nov 2012 23:45:02 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command To: Dani Moncayo Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) > I've only seen a minor detail that I don't like: when the command does > nothing (because there are no consecutive duplicate lines), the region > remains active. Add a call to deactivate-mark at the end. Juanma From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 19:41:32 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 00:41:32 +0000 Received: from localhost ([127.0.0.1]:45728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEfc-0000Mb-3I for submit@debbugs.gnu.org; Thu, 29 Nov 2012 19:41:32 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:33366 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEfX-0000MM-Sm for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 19:41:28 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 3335046FA010; Thu, 29 Nov 2012 16:39:23 -0800 (PST) From: Juri Linkov To: Dani Moncayo Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: Date: Fri, 30 Nov 2012 02:31:21 +0200 In-Reply-To: (Dani Moncayo's message of "Thu, 29 Nov 2012 20:23:16 +0100") Message-ID: <87obig2ap2.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) > That is: provide a function `delete-duplicate-lines' (or some such) > that removes all duplicate lines in the active region and prints in > the echo area a message like "Duplicate lines removed: ". This is what I currently use to delete duplicate lines: C-u M-| awk -- '!a[$0]++' RET Do you intend to create a Lisp function with the same result? From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 19:49:02 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 00:49:02 +0000 Received: from localhost ([127.0.0.1]:45735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEmr-0000XJ-SJ for submit@debbugs.gnu.org; Thu, 29 Nov 2012 19:49:02 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:63992) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEmp-0000X4-7J for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 19:48:59 -0500 Received: by mail-ee0-f44.google.com with SMTP id b47so9394701eek.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 16:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=BeivA8zp3Pz46OPLP5XNYpxYze9YxPUjnhHaJpW0hYE=; b=PikIinsEQTtybxmMmBy6gvc45FhUwhl77xgYvhQAuMQjaVJ+h4KnPiwHpYzTvU1RfW 7dAdBZtU0X4Mlj0N9rgfSj9pp/Xtos9gmOQjOSl6Tye51B58YBbhngmra/LEtFmJhg2f ccISmEoKvT2wbnk27DdwikZxmEgqziU8pnWMCSAF0nPdeMlck3q/yjlRtMI6l+Ww4IyS ILG5Pypv9m32Z2qI7zI4i8o8y4R/KrJqcqSElOr6DkF6SYyuSmSETmbLK92OU/xlurSo XGMhjyMaVG/E8AYRauKn3Tu9dnIOQlchojRbdZnAdVp4loDF2fUzP7ZU3snIwUp+Y+1f ox/A== Received: by 10.14.207.6 with SMTP id m6mr44892708eeo.10.1354236416097; Thu, 29 Nov 2012 16:46:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.4.209 with HTTP; Thu, 29 Nov 2012 16:46:15 -0800 (PST) In-Reply-To: <87obig2ap2.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> From: Juanma Barranquero Date: Fri, 30 Nov 2012 01:46:15 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command To: Juri Linkov Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org, Dani Moncayo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) On Fri, Nov 30, 2012 at 1:31 AM, Juri Linkov wrote: > C-u M-| awk -- '!a[$0]++' RET Isn't C-u M-| uniq RET shorter and easier to type? From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 19:53:11 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 00:53:11 +0000 Received: from localhost ([127.0.0.1]:45740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEqs-0000dO-Jd for submit@debbugs.gnu.org; Thu, 29 Nov 2012 19:53:10 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:47521) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEqr-0000dI-8w for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 19:53:09 -0500 Received: by mail-ee0-f44.google.com with SMTP id b47so9395987eek.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 16:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=qbMEOSpreXq5rOcvR52utiYIRpjIuTG6SaFEeI30vI8=; b=Oj7HgWGoGrBl2tCQIGwoQtk+rmE3gR5gFVHteVAdN1Og/ckR0Eef/knYOhvZPAxnSt rqIjgjGvyxvyNswBVMIKWCxfl6j5Bboh0ayZsha4jIZz7twcU72otxl6EWS3qZ2xk+Q7 3YIs6d2kadesjnG/Uw3O9eg5RbET/uMU6PIaWIddYBbyV0ENnGh8ot1E5bbdkQhNVOAN ma8g5Bg5HEEOQdK7Yr0gPMMQbNjSoB2xSfK/aRTrv4B4ITt6Swhig7lWLgoWiyMjfx/+ qbnFdwi238sTr3nzcEPAGzCYyjSO/pWQsnrnA3f1bSK+6pyJk36WB/iuLEh1yezoubiL pcFg== Received: by 10.14.207.6 with SMTP id m6mr44929813eeo.10.1354236666224; Thu, 29 Nov 2012 16:51:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.4.209 with HTTP; Thu, 29 Nov 2012 16:50:25 -0800 (PST) In-Reply-To: References: <87obig2ap2.fsf@mail.jurta.org> From: Juanma Barranquero Date: Fri, 30 Nov 2012 01:50:25 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command To: Juri Linkov Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org, Dani Moncayo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) (FWIW, yes, I'm aware that your awk script and uniq don't do the same thing, but I think what Dani requested was in fact removing consecutive duplicates...) From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 20:01:54 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 01:01:54 +0000 Received: from localhost ([127.0.0.1]:45748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEzJ-0000pt-PU for submit@debbugs.gnu.org; Thu, 29 Nov 2012 20:01:54 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:44489 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeEzH-0000pl-Q3 for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 20:01:52 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 6E42A46FA010; Thu, 29 Nov 2012 16:59:47 -0800 (PST) From: Juri Linkov To: Juanma Barranquero Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> Date: Fri, 30 Nov 2012 02:57:53 +0200 In-Reply-To: (Juanma Barranquero's message of "Fri, 30 Nov 2012 01:50:25 +0100") Message-ID: <877gp33o1a.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org, Dani Moncayo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) > (FWIW, yes, I'm aware that your awk script and uniq don't do the same > thing, but I think what Dani requested was in fact removing > consecutive duplicates...) I wonder why only consecutive duplicates? The existing functions `delete-duplicates' and `delete-dups' that operate on lists don't delete just consecutive duplicates. They delete all duplicates. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 20:05:23 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 01:05:23 +0000 Received: from localhost ([127.0.0.1]:45763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeF2g-0000v7-P9 for submit@debbugs.gnu.org; Thu, 29 Nov 2012 20:05:23 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:33109) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeF2d-0000uz-F8 for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 20:05:21 -0500 Received: by mail-ee0-f44.google.com with SMTP id b47so9399592eek.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 17:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=qB/vWp4rFcvhkO33tEo0cvupcBMh8D/6R8tZLKVoylw=; b=Dnu6Ii3cSftwAy7d5zKV46SLzjlWXFofGXUEc6eTTaIoUxcxXnhiNCW+5tqP6TmcPS z6jTVQu0E0xYKXGqFAb9deOCG5QqW6MKh36pbITzH2UHqJchJRyrnhHZz9fvr13/SsJK BP0TnnFiSwj/D9fn6t7GqucOhk2IyOBiwtdvSMbZc593nuriE+S0sIxNHDt6RyYmKZpT kI6E3Ly/2YgYEahuxC4NOE9BOwoHP08nDQNOL0mUnD44li2IhKPDssWtDLgFe2sl8efP xLNT1ClbrUS2nhVE1N7hcf/ehU3DfpkcGPYq/77kV4nA78fiojqGXJ4vhmGCs+r1zYYI Eb3g== Received: by 10.14.207.6 with SMTP id m6mr45039089eeo.10.1354237396320; Thu, 29 Nov 2012 17:03:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.4.209 with HTTP; Thu, 29 Nov 2012 17:02:36 -0800 (PST) In-Reply-To: <877gp33o1a.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <877gp33o1a.fsf@mail.jurta.org> From: Juanma Barranquero Date: Fri, 30 Nov 2012 02:02:36 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command To: Juri Linkov Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org, Dani Moncayo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) On Fri, Nov 30, 2012 at 1:57 AM, Juri Linkov wrote: > I wonder why only consecutive duplicates? The existing functions > `delete-duplicates' and `delete-dups' that operate on lists > don't delete just consecutive duplicates. They delete all duplicates. Yes. Dani has not said what's his use case. Juanma From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 29 20:40:09 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 01:40:09 +0000 Received: from localhost ([127.0.0.1]:45809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeFaK-0001lZ-6K for submit@debbugs.gnu.org; Thu, 29 Nov 2012 20:40:08 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:39573 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeFaG-0001l1-D4 for 13032@debbugs.gnu.org; Thu, 29 Nov 2012 20:40:05 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 0062746FA010; Thu, 29 Nov 2012 17:37:59 -0800 (PST) From: Juri Linkov To: Juanma Barranquero Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> Date: Fri, 30 Nov 2012 03:12:05 +0200 In-Reply-To: (Juanma Barranquero's message of "Fri, 30 Nov 2012 01:46:15 +0100") Message-ID: <874nk728ci.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org, Dani Moncayo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) >> C-u M-| awk -- '!a[$0]++' RET > > Isn't > > C-u M-| uniq RET > > shorter and easier to type? I use `uniq' only on files where lines are sorted. OTOH, something like '!a[$0]++' that is not limited to consecutive duplicates is better for files where lines are not sorted such as log files, etc. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 30 02:53:43 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 07:53:44 +0000 Received: from localhost ([127.0.0.1]:46088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeLPr-0003lN-8B for submit@debbugs.gnu.org; Fri, 30 Nov 2012 02:53:43 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:39469) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeLPo-0003lB-V5 for 13032@debbugs.gnu.org; Fri, 30 Nov 2012 02:53:41 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so159579oag.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 23:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8iq73qeMy+OF4XC650FXaSecXnDIFrmKwVWMv2fYvYU=; b=ubcJ0BC1dj5w5dEkVsE3oa+Ju1WcZY+wBeJIA7cfgTaEGQC2uDbllL7IFcQ8UVfGeR gs50VjXhw63Azw0NFIPOevnIFiTzYYF73hbkSqhjJw17d5uOgQMYfa9JfaTS7mjEafih nulgdfYMdoPaACh19s9J1oKQ2DCimiCdeVBgNGuP+tqu+2Ljn4rk8bCWqf1qsYVGMm+o SyUO37XKL74PC0EWDJrjqSLQ67oO9iiZ96wukDaIK0HOYe4zA/aoefSownSjmhyePe6D 4qIV15xwUhXFjZiNVglaXZPpGCysq3KKXt2qTnvqTvpOoVwb1i0uzf1Hy29toWeMttqY +1TA== MIME-Version: 1.0 Received: by 10.182.116.6 with SMTP id js6mr283327obb.82.1354261894133; Thu, 29 Nov 2012 23:51:34 -0800 (PST) Received: by 10.60.64.170 with HTTP; Thu, 29 Nov 2012 23:51:34 -0800 (PST) In-Reply-To: <874nk728ci.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> Date: Fri, 30 Nov 2012 08:51:34 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) >>> C-u M-| awk -- '!a[$0]++' RET >> >> Isn't >> >> C-u M-| uniq RET >> >> shorter and easier to type? > > I use `uniq' only on files where lines are sorted. OTOH, something like > '!a[$0]++' that is not limited to consecutive duplicates is better for > files where lines are not sorted such as log files, etc. My use cases usually involves compacting a collection of lines gathered from several places. So the compacting operation is normally coupled with a sort operation. Thus, the command provided by Juanma is good enough for these use cases (I first do a `sort-lines' and then a `delete-duplicate-lines'). But I agree that it would be even better if `delete-duplicate-lines' did TRT even when the lines are not sorted. (I've just tested this feature in MS-Excel, and it is so: it doesn't requires that the lines are previously sorted) Thank you. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 30 02:53:47 2012 Received: (at 13032) by debbugs.gnu.org; 30 Nov 2012 07:53:47 +0000 Received: from localhost ([127.0.0.1]:46091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeLPu-0003la-VV for submit@debbugs.gnu.org; Fri, 30 Nov 2012 02:53:47 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:39469) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TeLPt-0003lB-3O for 13032@debbugs.gnu.org; Fri, 30 Nov 2012 02:53:45 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so159579oag.3 for <13032@debbugs.gnu.org>; Thu, 29 Nov 2012 23:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/Ea7Ckvw9uQf4AXPDbvH+Xa5fE2nL+1qRmGg6oIwads=; b=s1fwzbcN/J8GjRmnhbggb+DK4KO4hqWaNiXzhM4fsdGl1j4BcIS46x1AcBOzi4K+T+ aANJH/yO+ihk9hrwk5Z8bvL3/RZtjIWCFc5SZNNgE+jSMCgZrbWgmPXLntosnk6XNtK+ Nix24r4YkFL1ttbl0QjznS89F6Q8MUNTO9h161ZBkPF6uzLOltCnZdZP5qjQlE0urS5R 6fQ2Vq79JOr25osQ/Z/TLPkW3AJ88nLXvIPCtgyXF9zYkrVKzyugfxa/Ur1Nb5fbreck NJsMySqTTN6tv13Rn1FJMcVDLMlNbF4VbbYtT+o26/KpEDbufLs/pAjLy8MeBJMA/sH6 gtVQ== MIME-Version: 1.0 Received: by 10.60.20.1 with SMTP id j1mr316975oee.46.1354261900732; Thu, 29 Nov 2012 23:51:40 -0800 (PST) Received: by 10.60.64.170 with HTTP; Thu, 29 Nov 2012 23:51:40 -0800 (PST) In-Reply-To: <87obig2ap2.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> Date: Fri, 30 Nov 2012 08:51:40 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) > This is what I currently use to delete duplicate lines: > > C-u M-| awk -- '!a[$0]++' RET > > Do you intend to create a Lisp function with the same result? I don't know awk, but I've tried that command and seems to do what I want: remove all duplicate lines in the region. Although it don't inform about the number of lines deleted, which is important to me. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 30 19:41:42 2012 Received: (at 13032) by debbugs.gnu.org; 1 Dec 2012 00:41:42 +0000 Received: from localhost ([127.0.0.1]:47601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Teb9J-0005Jz-O9 for submit@debbugs.gnu.org; Fri, 30 Nov 2012 19:41:42 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:38343 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Teb9F-0005Jl-VP for 13032@debbugs.gnu.org; Fri, 30 Nov 2012 19:41:39 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 96F14451E17F; Fri, 30 Nov 2012 16:39:28 -0800 (PST) From: Juri Linkov To: Dani Moncayo Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> Date: Sat, 01 Dec 2012 02:34:41 +0200 In-Reply-To: (Dani Moncayo's message of "Fri, 30 Nov 2012 08:51:34 +0100") Message-ID: <874nk63aps.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) >>>> C-u M-| awk -- '!a[$0]++' RET > > But I agree that it would be even better if `delete-duplicate-lines' > did TRT even when the lines are not sorted. (I've just tested this > feature in MS-Excel, and it is so: it doesn't requires that the lines > are previously sorted) Actually I use a slightly different command: C-u M-| tac | awk -- '!a[$0]++' | tac RET because I need to keep the last duplicate line instead of the first. `tac' reverses the lines, removes the duplicates keeping the first duplicate, and another `tac' reverses lines back thus keeping the last duplicate. So for `delete-duplicate-lines' to be useful in this case it could support also the reverse search that keeps the last duplicate. You can see this limitation described in docstrings of various functions at http://emacswiki.org/emacs/DuplicateLines as "keeping first occurrence", so these functions are of no help. Adding an argument to keep either the first/last duplicate and an argument to delete only adjacent lines, and using the algorithm like in awk, and using the calling interface like in `flush-lines', necessitates the following small function that can be called with the arg `C-u' to keep the last duplicate line, and `C-u C-u' to delete only adjacent lines: (defun delete-duplicate-lines (rstart rend &optional reverse adjacent interactive) "Delete duplicate lines in the region between RSTART and REND. If REVERSE is nil, search and delete duplicates forward keeping the first occurrence of duplicate lines. If REVERSE is non-nil, search and delete duplicates backward keeping the last occurrence of duplicate lines. If ADJACENT is non-nil, delete repeated lines only if they are adjacent." (interactive (progn (barf-if-buffer-read-only) (list (region-beginning) (region-end) (equal current-prefix-arg '(4)) (equal current-prefix-arg '(16)) t))) (let ((lines (unless adjacent (make-hash-table :weakness 'key :test 'equal))) line prev-line (count 0) (rstart (copy-marker rstart)) (rend (copy-marker rend))) (save-excursion (goto-char (if reverse rend rstart)) (if (and reverse (bolp)) (forward-char -1)) (while (if reverse (and (> (point) rstart) (not (bobp))) (and (< (point) rend) (not (eobp)))) (setq line (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (if (if adjacent (equal line prev-line) (gethash line lines)) (progn (delete-region (progn (forward-line 0) (point)) (progn (forward-line 1) (point))) (if reverse (forward-line -1)) (setq count (1+ count))) (if adjacent (setq prev-line line) (puthash line t lines)) (forward-line (if reverse -1 1))))) (set-marker rstart nil) (set-marker rend nil) (when interactive (message "Deleted %d %sduplicate line%s%s" count (if adjacent "adjacent " "") (if (= count 1) "" "s") (if reverse " backward " ""))) count)) From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 01 04:11:03 2012 Received: (at 13032) by debbugs.gnu.org; 1 Dec 2012 09:11:03 +0000 Received: from localhost ([127.0.0.1]:47928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tej6E-0002tU-GD for submit@debbugs.gnu.org; Sat, 01 Dec 2012 04:11:03 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:50135) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tej6C-0002t6-73 for 13032@debbugs.gnu.org; Sat, 01 Dec 2012 04:11:01 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so1229407oag.3 for <13032@debbugs.gnu.org>; Sat, 01 Dec 2012 01:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jRS4/xa8z4rupURuUdxcedACWcyS67xy/D9+Z66FGcs=; b=UxHH/gWPw7+PIJr4zzTADGXFToedwdzmjIEG6y7f7XHqbdjRGv6ZXlcDVoAURBDe3Z PFOXjkSn82sZ4ln7xpf3vgVmWkz3s5/XSBXE2n5u25I8g1kCmRFNgnbCkLIhTp6ppsUg mgU7SNpIu9/MW7oZY3flVElAmmfHPb8vjTtnwyZaDk2U0vKPuz8+11o5NhQxqPU0szZ0 gTQIW6zFM+tyVFWHHcDBfWWZi7fLBCSOuleuIXeyUuihr9dgyEmqtNr1rzlV71ScRcCK TIMbCCawBkA3pooyZVFJhCwbfk+SrW0eeniXQ63bU1ppo6QJ5at5ZJnwwkbX6t2wrvn0 Ih4w== MIME-Version: 1.0 Received: by 10.60.31.205 with SMTP id c13mr3269746oei.135.1354352929332; Sat, 01 Dec 2012 01:08:49 -0800 (PST) Received: by 10.60.64.170 with HTTP; Sat, 1 Dec 2012 01:08:49 -0800 (PST) In-Reply-To: <874nk63aps.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> Date: Sat, 1 Dec 2012 10:08:49 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) > (defun delete-duplicate-lines (rstart rend &optional reverse adjacent interactive) > "Delete duplicate lines in the region between RSTART and REND. > If REVERSE is nil, search and delete duplicates forward keeping the first > occurrence of duplicate lines. If REVERSE is non-nil, search and delete > duplicates backward keeping the last occurrence of duplicate lines. > If ADJACENT is non-nil, delete repeated lines only if they are adjacent." Looks pretty fine to me. Your version is more general and versatile. Some comments: * Why is needed the INTERACTIVE command? I mean, Cannot that info (whether the function has been called interactively) be retrieved using some Lips primitive? * In case the INTERACTIVE command is indeed necessary, it should be explained in the docstring, no? * I think that the docstring should explain also the return value (number of duplicate lines deleted). Thank you Juri. I hope Stefan or Chong add this feature to Emacs. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 01 04:24:16 2012 Received: (at 13032) by debbugs.gnu.org; 1 Dec 2012 09:24:16 +0000 Received: from localhost ([127.0.0.1]:47940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TejJ1-0003D5-VX for submit@debbugs.gnu.org; Sat, 01 Dec 2012 04:24:16 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:57896) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TejIz-0003Cx-3K for 13032@debbugs.gnu.org; Sat, 01 Dec 2012 04:24:14 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so1236803oag.3 for <13032@debbugs.gnu.org>; Sat, 01 Dec 2012 01:22:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=V7oUipg333p4C5LjAGMpc43+17epyxsEWl5t7P/WDjQ=; b=CgTm0kVxXW2YNf56P1aTa4yXD3kqeiLEQROeLax6Xg/v5kyOfkmJEdGH9IhDtUvmS7 uyfTsMKenM7VhTdRtzQgEvEGy+VZ0vsq3C1LaEOuv7MTOh7Xa9AHnyFngTMIINnvyEyQ xUmtywCXsEhLEatAHs4/v3DpIW9uA5Kd2O/sBbtYIQYuNLIJWaVufYGoJNa02on7VtMB ccYdMiBaSi+57q20umfW5Z1oemX1F969joI9z3NU+THnozKHeWhGL/dAKg4ZTU+8v8Q6 fjJMoT8AL/+CKpmYKleJXkyQ4SMoRqs72SI4woiilpjQ7m+QwLxpQL/3cdtVpCnmoNEp ft8Q== MIME-Version: 1.0 Received: by 10.60.24.97 with SMTP id t1mr625513oef.6.1354353720433; Sat, 01 Dec 2012 01:22:00 -0800 (PST) Received: by 10.60.64.170 with HTTP; Sat, 1 Dec 2012 01:22:00 -0800 (PST) In-Reply-To: References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> Date: Sat, 1 Dec 2012 10:22:00 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) >> (defun delete-duplicate-lines (rstart rend &optional reverse adjacent interactive) >> "Delete duplicate lines in the region between RSTART and REND. >> If REVERSE is nil, search and delete duplicates forward keeping the first >> occurrence of duplicate lines. If REVERSE is non-nil, search and delete >> duplicates backward keeping the last occurrence of duplicate lines. >> If ADJACENT is non-nil, delete repeated lines only if they are adjacent." > > Looks pretty fine to me. Your version is more general and versatile. > > Some comments: > * Why is needed the INTERACTIVE command? I mean, Cannot that info > (whether the function has been called interactively) be retrieved > using some Lips primitive? > * In case the INTERACTIVE command is indeed necessary, it should be > explained in the docstring, no? > * I think that the docstring should explain also the return value > (number of duplicate lines deleted). Sorry, replace "command" by "argument" in the above paragraph. Another comment: * I'm thinking that the ADJACENT argument is kinda unnecessary. I can't think of a use-case where someone wants to remove only the _adjacent_ duplicate lines but not the ones which aren't adjacent. So, I think that both the interface and the implementation could be simplified by removing that argument. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 01 19:49:54 2012 Received: (at 13032) by debbugs.gnu.org; 2 Dec 2012 00:49:54 +0000 Received: from localhost ([127.0.0.1]:48922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Texkn-0001nD-G2 for submit@debbugs.gnu.org; Sat, 01 Dec 2012 19:49:53 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:58079 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Texkk-0001n2-U1 for 13032@debbugs.gnu.org; Sat, 01 Dec 2012 19:49:52 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id AB43B451E1D5; Sat, 1 Dec 2012 16:47:35 -0800 (PST) From: Juri Linkov To: Dani Moncayo Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> Date: Sun, 02 Dec 2012 02:45:44 +0200 In-Reply-To: (Dani Moncayo's message of "Sat, 1 Dec 2012 10:08:49 +0100") Message-ID: <87mwxxfhd3.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > * I'm thinking that the ADJACENT argument is kinda unnecessary. I > can't think of a use-case where someone wants to remove only the > _adjacent_ duplicate lines but not the ones which aren't adjacent. > So, I think that both the interface and the implementation could be > simplified by removing that argument. The ADJACENT argument is an optimization that doesn't require additional memory (to store previous lines in the cache). This is necessary when the user needs to delete duplicate lines in a large sorted file. > * Why is needed the INTERACTIVE argument? I mean, Cannot that info > (whether the function has been called interactively) be retrieved > using some Lips primitive? There is called-interactively-p but as I understood, it is unreliable. This is why other similar commands like `flush-lines', `keep-lines', `how-many' use the INTERACTIVE argument. They use it for two purposes: to decide whether the active region should be used, and to decide whether the message should be displayed when called interactively. > * In case the INTERACTIVE argument is indeed necessary, it should be > explained in the docstring, no? Yes, below I copied this part from the docstring of `how-many'. > * I think that the docstring should explain also the return value > (number of duplicate lines deleted). Coincidentally, the return value will be explained in the same part of the docstring. The remaining problem is to decide where to put this command? The file replace.el is unsuitable because unlike `flush-lines' and unlike `how-many', `delete-duplicate-lines' doesn't use regexps. It seems the right place is sort.el because it also contains a related command `reverse-region'. This patch puts `delete-duplicate-lines' after `reverse-region' at the end of sort.el: === modified file 'lisp/sort.el' --- lisp/sort.el 2012-08-03 08:15:24 +0000 +++ lisp/sort.el 2012-12-02 00:44:42 +0000 @@ -562,6 +562,59 @@ (defun reverse-region (beg end) (setq ll (cdr ll))) (insert (car ll))))) +;;;###autoload +(defun delete-duplicate-lines (rstart rend &optional reverse adjacent interactive) + "Delete duplicate lines in the region between RSTART and REND. + +If REVERSE is nil, search and delete duplicates forward keeping the first +occurrence of duplicate lines. If REVERSE is non-nil (when called +interactively with C-u prefix), search and delete duplicates backward +keeping the last occurrence of duplicate lines. + +If ADJACENT is non-nil (when called interactively with two C-u prefixes), +delete repeated lines only if they are adjacent. + +When called from Lisp and INTERACTIVE is omitted or nil, return the number +of deleted duplicate lines, do not print it; if INTERACTIVE is t, the +function behaves in all respects as if it had been called interactively." + (interactive + (progn + (barf-if-buffer-read-only) + (list (region-beginning) (region-end) + (equal current-prefix-arg '(4)) + (equal current-prefix-arg '(16)) + t))) + (let ((lines (unless adjacent (make-hash-table :weakness 'key :test 'equal))) + line prev-line + (count 0) + (rstart (copy-marker rstart)) + (rend (copy-marker rend))) + (save-excursion + (goto-char (if reverse rend rstart)) + (if (and reverse (bolp)) (forward-char -1)) + (while (if reverse + (and (> (point) rstart) (not (bobp))) + (and (< (point) rend) (not (eobp)))) + (setq line (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + (if (if adjacent (equal line prev-line) (gethash line lines)) + (progn + (delete-region (progn (forward-line 0) (point)) + (progn (forward-line 1) (point))) + (if reverse (forward-line -1)) + (setq count (1+ count))) + (if adjacent (setq prev-line line) (puthash line t lines)) + (forward-line (if reverse -1 1))))) + (set-marker rstart nil) + (set-marker rend nil) + (when interactive + (message "Deleted %d %sduplicate line%s%s" + count + (if adjacent "adjacent " "") + (if (= count 1) "" "s") + (if reverse " backward " ""))) + count)) + (provide 'sort) ;;; sort.el ends here From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 02 04:16:17 2012 Received: (at 13032) by debbugs.gnu.org; 2 Dec 2012 09:16:17 +0000 Received: from localhost ([127.0.0.1]:49297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tf5eq-0000vq-DV for submit@debbugs.gnu.org; Sun, 02 Dec 2012 04:16:17 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:62960) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tf5en-0000vi-Ku for 13032@debbugs.gnu.org; Sun, 02 Dec 2012 04:16:14 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so1755441oag.3 for <13032@debbugs.gnu.org>; Sun, 02 Dec 2012 01:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=hPGG47J6RjmVUnn7BaB1vjFXCmh4ipjgfVsAT08QX3M=; b=yWA0+Lbd+vCRi6KHxBGjynh2LY5wn6gWYQh7x7O9ZByrEy5YYRBQ59EONiEUZ4C1sx IsSvMvUyyf8oTlN/0OnQyFDEPYmdFoV9W1FKhWFcT3ZnlNzCGJaJYlKkEh+kSdwUheQ2 fsfgjrVGhY5FrKJHQVZlBzQB1nyHB90iKpPbw+YASjRrD2+O0qS3BhsEWQi7KXHss8RK 18lkgQI/ugB+uTGR1Vg4Tksy0/An9Ss+GnR5u8S3AV0c5oqFMEw5UmFs9g79OO9Fx9CA hHzoUTFZQ52Vy86NZ7Wh/CpLbyGsid/rSlLiRfcfVuMshY2fZUwXUW+hoWxncPZ14Uj8 n5Cg== MIME-Version: 1.0 Received: by 10.182.78.137 with SMTP id b9mr1739217obx.94.1354439636065; Sun, 02 Dec 2012 01:13:56 -0800 (PST) Received: by 10.60.64.170 with HTTP; Sun, 2 Dec 2012 01:13:55 -0800 (PST) In-Reply-To: <87mwxxfhd3.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> Date: Sun, 2 Dec 2012 10:13:55 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: Juanma Barranquero , 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) >> * I'm thinking that the ADJACENT argument is kinda unnecessary. I >> can't think of a use-case where someone wants to remove only the >> _adjacent_ duplicate lines but not the ones which aren't adjacent. >> So, I think that both the interface and the implementation could be >> simplified by removing that argument. > > The ADJACENT argument is an optimization that doesn't require > additional memory (to store previous lines in the cache). > This is necessary when the user needs to delete duplicate lines > in a large sorted file. Ah, good point. I guess that the optimization is twofold: in memory and also in performance. Then, IMO this should be explained in the docstring, so that users know that they should use this feature when running this command over a large chunk of lines. Thank you. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 18:52:29 2012 Received: (at 13032-done) by debbugs.gnu.org; 3 Dec 2012 23:52:29 +0000 Received: from localhost ([127.0.0.1]:52111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TffoL-0005rg-0b for submit@debbugs.gnu.org; Mon, 03 Dec 2012 18:52:29 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:42625 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TffoH-0005rY-Qn for 13032-done@debbugs.gnu.org; Mon, 03 Dec 2012 18:52:26 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7D4AE46FA010; Mon, 3 Dec 2012 15:49:59 -0800 (PST) From: Juri Linkov To: Dani Moncayo Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> Date: Tue, 04 Dec 2012 01:49:29 +0200 In-Reply-To: (Dani Moncayo's message of "Sun, 2 Dec 2012 10:13:55 +0100") Message-ID: <87lidek86u.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032-done Cc: Juanma Barranquero , 13032-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) >> The ADJACENT argument is an optimization that doesn't require >> additional memory (to store previous lines in the cache). >> This is necessary when the user needs to delete duplicate lines >> in a large sorted file. > > Ah, good point. I guess that the optimization is twofold: in memory > and also in performance. Then, IMO this should be explained in the > docstring, so that users know that they should use this feature when > running this command over a large chunk of lines. Thanks for the suggestion, I added this as well. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 19:11:05 2012 Received: (at 13032) by debbugs.gnu.org; 4 Dec 2012 00:11:05 +0000 Received: from localhost ([127.0.0.1]:52142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfg6L-0006J1-5u for submit@debbugs.gnu.org; Mon, 03 Dec 2012 19:11:05 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:52020 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfg6J-0006Is-DD for 13032@debbugs.gnu.org; Mon, 03 Dec 2012 19:11:03 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 6EA2DAAB4B9C; Mon, 3 Dec 2012 16:08:37 -0800 (PST) From: Juri Linkov To: 13032@debbugs.gnu.org Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> <87lidek86u.fsf@mail.jurta.org> Date: Tue, 04 Dec 2012 02:05:03 +0200 In-Reply-To: <87lidek86u.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 04 Dec 2012 01:49:29 +0200") Message-ID: <87txs2iswg.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: dmoncayo@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) >>> The ADJACENT argument is an optimization that doesn't require >>> additional memory (to store previous lines in the cache). >>> This is necessary when the user needs to delete duplicate lines >>> in a large sorted file. >> >> Ah, good point. I guess that the optimization is twofold: in memory >> and also in performance. Then, IMO this should be explained in the >> docstring, so that users know that they should use this feature when >> running this command over a large chunk of lines. > > Thanks for the suggestion, I added this as well. It just occurred to me that we could also add an alias `uniq' that will call the command `delete-duplicate-lines' with non-nil ADJACENT arg. We already have aliases like `mkdir' for `make-directory', so the command `uniq' would be handy too. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 02:07:21 2012 Received: (at submit) by debbugs.gnu.org; 4 Dec 2012 07:07:21 +0000 Received: from localhost ([127.0.0.1]:52392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfmbA-0008Hc-Uc for submit@debbugs.gnu.org; Tue, 04 Dec 2012 02:07:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54932) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfmb8-0008HV-4g for submit@debbugs.gnu.org; Tue, 04 Dec 2012 02:07:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfmYf-0001UC-Gr for submit@debbugs.gnu.org; Tue, 04 Dec 2012 02:04:51 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:41799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfmYf-0001Tz-D0 for submit@debbugs.gnu.org; Tue, 04 Dec 2012 02:04:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfmYY-0003HD-UK for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2012 02:04:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfmYT-0001Pl-ON for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2012 02:04:38 -0500 Received: from plane.gmane.org ([80.91.229.3]:59366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfmYT-0001PO-Ii for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2012 02:04:33 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TfmYa-0006Wq-Gf for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2012 08:04:40 +0100 Received: from lbe83-2-78-243-104-167.fbx.proxad.net ([78.243.104.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Dec 2012 08:04:40 +0100 Received: from thierry.volpiatto by lbe83-2-78-243-104-167.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Dec 2012 08:04:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Thierry Volpiatto Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Date: Tue, 04 Dec 2012 08:04:13 +0100 Organization: Emacs Helm Lines: 40 Message-ID: <87obia9u36.fsf@gmail.com> References: <87obig2ap2.fsf@mail.jurta.org> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lbe83-2-78-243-104-167.fbx.proxad.net User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:pIPs9cu0k1GuE0L2gtwhsM/wuIw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) Hi, just for info, here a simple and fast version. Dani Moncayo writes: >> This is what I currently use to delete duplicate lines: >> >> C-u M-| awk -- '!a[$0]++' RET >> >> Do you intend to create a Lisp function with the same result? > > I don't know awk, but I've tried that command and seems to do what I > want: remove all duplicate lines in the region. Although it don't > inform about the number of lines deleted, which is important to me. --8<---------------cut here---------------start------------->8--- (defun delete-duplicate-lines (beg end) "Delete duplicate lines in region." (interactive "r") (save-excursion (save-restriction (narrow-to-region beg end) (let ((lines (helm-fast-remove-dups (split-string (buffer-string) "\n" t) :test 'equal))) (delete-region (point-min) (point-max)) (loop for l in lines do (insert (concat l "\n"))))))) --8<---------------cut here---------------end--------------->8--- helm-fast-remove-dups is a function in helm: https://github.com/emacs-helm/helm/blob/master/helm-utils.el line 342 For the number of lines removed it is easy to modify the function to do so. -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 04:16:15 2012 Received: (at 13032) by debbugs.gnu.org; 4 Dec 2012 09:16:15 +0000 Received: from localhost ([127.0.0.1]:52457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfobv-0002lL-IR for submit@debbugs.gnu.org; Tue, 04 Dec 2012 04:16:15 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:46653) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfobt-0002lE-O5 for 13032@debbugs.gnu.org; Tue, 04 Dec 2012 04:16:14 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so3583478oag.3 for <13032@debbugs.gnu.org>; Tue, 04 Dec 2012 01:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RPVWWqKiOaRtgh5cbNLld2UOH3NdXxXc9dKocGn5ZgI=; b=th8Iu2hOEUlvTOLKFg+oxYQhHLgVfKzmnQ2cVtMBo7Arg4jcdhdsDOgYVy9XlumbSB AxARz5uPbB3r3Z+cFWeHKYPSR/9jpb1JPNsufSCANGkT1hM2MrCyCNVbdIiRlAsoxz/d A+5q6fkIpqOtR091of2ZLE3nE0o1rcj9bJJiak/za/VgFdSsSkoEyt6hbdP7M/UC2M+A IjHgMY8DNucAJmh7urcd/a3Vaz0YyicBYTLGfAPapmJO4M9B8pmghcP/WE8BYja/R6+r ccWNVsxt0JQp4ST30t0PBba5/wH6nueyAmJqt53IPBdAIP/HXy4hj0CEr1AXsIxAIe7j wV/A== MIME-Version: 1.0 Received: by 10.60.32.210 with SMTP id l18mr10602489oei.99.1354612423903; Tue, 04 Dec 2012 01:13:43 -0800 (PST) Received: by 10.60.64.170 with HTTP; Tue, 4 Dec 2012 01:13:43 -0800 (PST) In-Reply-To: <87txs2iswg.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> <87lidek86u.fsf@mail.jurta.org> <87txs2iswg.fsf@mail.jurta.org> Date: Tue, 4 Dec 2012 10:13:43 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) > It just occurred to me that we could also add an alias `uniq' that will > call the command `delete-duplicate-lines' with non-nil ADJACENT arg. > > We already have aliases like `mkdir' for `make-directory', > so the command `uniq' would be handy too. Fine with me. BTW, I've just noticed that the command doesn't deactivate the mark when there is no duplicate lines in the region. Could that be fixed? Thank you. -- Dani Moncayo From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 09:49:05 2012 Received: (at 13032) by debbugs.gnu.org; 4 Dec 2012 14:49:05 +0000 Received: from localhost ([127.0.0.1]:52617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfto1-0002yJ-2b for submit@debbugs.gnu.org; Tue, 04 Dec 2012 09:49:05 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:13863) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tftnz-0002yB-17 for 13032@debbugs.gnu.org; Tue, 04 Dec 2012 09:49:03 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09soXOY/2dsb2JhbABEsEiDSYEIghYBBVYjEAs0EhQYDSSIIboJkEQDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="209044779" Received: from 108-161-115-152.dsl.teksavvy.com (HELO pastel.home) ([108.161.115.152]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 04 Dec 2012 09:46:34 -0500 Received: by pastel.home (Postfix, from userid 20848) id C5AEF58EB0; Tue, 4 Dec 2012 09:46:33 -0500 (EST) From: Stefan Monnier To: Thierry Volpiatto Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Message-ID: References: <87obig2ap2.fsf@mail.jurta.org> <87obia9u36.fsf@gmail.com> Date: Tue, 04 Dec 2012 09:46:33 -0500 In-Reply-To: <87obia9u36.fsf@gmail.com> (Thierry Volpiatto's message of "Tue, 04 Dec 2012 08:04:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) > (let ((lines (helm-fast-remove-dups > (split-string (buffer-string) "\n" t) > :test 'equal))) > (delete-region (point-min) (point-max)) > (loop for l in lines do (insert (concat l "\n"))))))) The inconvenient with this version is that any overlays/markers will be lost, and the buffer will be marked as modified even if there were no duplicate lines. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 10:05:02 2012 Received: (at 13032) by debbugs.gnu.org; 4 Dec 2012 15:05:02 +0000 Received: from localhost ([127.0.0.1]:53299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfu3Q-0003V3-3K for submit@debbugs.gnu.org; Tue, 04 Dec 2012 10:05:02 -0500 Received: from mail-wi0-f176.google.com ([209.85.212.176]:52674) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tfu3M-0003Uv-Ng for 13032@debbugs.gnu.org; Tue, 04 Dec 2012 10:04:58 -0500 Received: by mail-wi0-f176.google.com with SMTP id hm6so744714wib.15 for <13032@debbugs.gnu.org>; Tue, 04 Dec 2012 07:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=kznr9csd/XTS0olOQGBfQndOktCBzULBT4KJLyRcxtk=; b=yF87KYkmfzDlDYOE/EwJSMhTDMQ3N7Aki4WATgpyKK6p/Ha0vdzi3NdycHgsOJxQAK 13DmmSx+fWULb3wSBNFTF2jwAQhV1Jx8WIucJYjLJwsTqjJoESLB2OV+QmC/BnZIgmfn 6gd6614crd3lgWYEuexkM4vsu1Uilx7r/xE0g6tMugdGvooatomrbQ5fVur9KmYPkIOV hxIMjBqPgEqIKSST6Z4ucf9phfUNqLsalhVcg+CFKTcPGp8/CeOL/ri2ZqfWUA5US+q5 rMSKo5EKDzmI23g+vqLR5XdmXs1JV+tFhCMqD/CsU0+k17V4xJBFVINgl9HUGyvuUfKM HI1A== Received: by 10.216.28.213 with SMTP id g63mr4878842wea.66.1354633346398; Tue, 04 Dec 2012 07:02:26 -0800 (PST) Received: from dell-14z (lbe83-2-78-243-104-167.fbx.proxad.net. [78.243.104.167]) by mx.google.com with ESMTPS id s12sm15370005wik.11.2012.12.04.07.02.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Dec 2012 07:02:25 -0800 (PST) From: Thierry Volpiatto To: Stefan Monnier Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: Emacs Helm References: <87obig2ap2.fsf@mail.jurta.org> <87obia9u36.fsf@gmail.com> Date: Tue, 04 Dec 2012 16:02:17 +0100 In-Reply-To: (Stefan Monnier's message of "Tue, 04 Dec 2012 09:46:33 -0500") Message-ID: <87txs16eti.fsf@gmail.com> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Stefan Monnier writes: >> (let ((lines (helm-fast-remove-dups >> (split-string (buffer-string) "\n" t) >> :test 'equal))) >> (delete-region (point-min) (point-max)) >> (loop for l in lines do (insert (concat l "\n"))))))) > > The inconvenient with this version is that any overlays/markers will > be lost, and the buffer will be marked as modified even if there were no > duplicate lines. Ok, was just for info on a fast alternative without such enhancements. -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 19:08:48 2012 Received: (at 13032) by debbugs.gnu.org; 5 Dec 2012 00:08:48 +0000 Received: from localhost ([127.0.0.1]:53826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tg2Xf-0000Ov-Te for submit@debbugs.gnu.org; Tue, 04 Dec 2012 19:08:48 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:47944 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tg2Xd-0000Oo-Nu for 13032@debbugs.gnu.org; Tue, 04 Dec 2012 19:08:46 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 9DBF9451E1CF; Tue, 4 Dec 2012 16:08:31 -0800 (PST) From: Juri Linkov To: Dani Moncayo Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command Organization: JURTA References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> <87lidek86u.fsf@mail.jurta.org> <87txs2iswg.fsf@mail.jurta.org> Date: Wed, 05 Dec 2012 01:51:47 +0200 In-Reply-To: (Dani Moncayo's message of "Tue, 4 Dec 2012 10:13:43 +0100") Message-ID: <87txs1pfn8.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) >> It just occurred to me that we could also add an alias `uniq' that will >> call the command `delete-duplicate-lines' with non-nil ADJACENT arg. >> >> We already have aliases like `mkdir' for `make-directory', >> so the command `uniq' would be handy too. > > Fine with me. But the problem is that `uniq' might be confused with a similarly named feature `uniquify' that uniquifies buffer names. > BTW, I've just noticed that the command doesn't deactivate the mark > when there is no duplicate lines in the region. Could that be fixed? This problem is not specific to `delete-duplicate-lines'. All similar functions like e.g. `delete-matching-lines', `delete-non-matching-lines' and `delete-blank-lines' behave the same way. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 05 03:08:16 2012 Received: (at 13032) by debbugs.gnu.org; 5 Dec 2012 08:08:16 +0000 Received: from localhost ([127.0.0.1]:54208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgA1g-0006Gi-2h for submit@debbugs.gnu.org; Wed, 05 Dec 2012 03:08:16 -0500 Received: from mail-ob0-f172.google.com ([209.85.214.172]:49958) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgA1e-0006GZ-AJ for 13032@debbugs.gnu.org; Wed, 05 Dec 2012 03:08:15 -0500 Received: by mail-ob0-f172.google.com with SMTP id za17so4537341obc.3 for <13032@debbugs.gnu.org>; Wed, 05 Dec 2012 00:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NR0FmSzKkOCQE3qiFiM+1Mp5yTX3B99Uu5DSnDZlSJw=; b=T5J2M1DZyXYg9XriwBEu1t/ccbRtknJcA/QCmi09TQWX7z6fhvjp7hSfpHK61ALOO/ aG5j7ZQFrzNlX3eOxpVsxu5eP5GYCE1yPYFH1qs+s/d7+IQvNOkIhQ2DPW71kAJbPwWt J3LZzgM4TEMHh51bKrfeqA8poiJ9KtfL1ks/s5UjQlB6EcGRtVgaUPAkChjNWzJUD6dw vEGktmSdrvrls+TYxXc1p58zw1LDhEjtUyeN/MW3gymUcxSrDFuFjJOzuPR01U88QqwV 9HabkIin4szxgozTxjn2rfParVQ4cISu0qDnavwQ4GZnuWuj+o8gWPDYDbBLXNp0rhwB 5DzQ== MIME-Version: 1.0 Received: by 10.182.92.70 with SMTP id ck6mr9925136obb.46.1354694887848; Wed, 05 Dec 2012 00:08:07 -0800 (PST) Received: by 10.60.11.39 with HTTP; Wed, 5 Dec 2012 00:08:07 -0800 (PST) In-Reply-To: <87txs1pfn8.fsf@mail.jurta.org> References: <87obig2ap2.fsf@mail.jurta.org> <874nk728ci.fsf@mail.jurta.org> <874nk63aps.fsf@mail.jurta.org> <87mwxxfhd3.fsf@mail.jurta.org> <87lidek86u.fsf@mail.jurta.org> <87txs2iswg.fsf@mail.jurta.org> <87txs1pfn8.fsf@mail.jurta.org> Date: Wed, 5 Dec 2012 09:08:07 +0100 Message-ID: Subject: Re: bug#13032: 24.3.50; Request: Provide a `delete-duplicate-lines' command From: Dani Moncayo To: Juri Linkov Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13032 Cc: 13032@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.1 (/) >>> It just occurred to me that we could also add an alias `uniq' that will >>> call the command `delete-duplicate-lines' with non-nil ADJACENT arg. >>> >>> We already have aliases like `mkdir' for `make-directory', >>> so the command `uniq' would be handy too. >> >> Fine with me. > > But the problem is that `uniq' might be confused with a similarly named > feature `uniquify' that uniquifies buffer names. Indeed. That is the problem of using such ambiguous names. FWIW, I have no particular interest in this `uniq' alias. >> BTW, I've just noticed that the command doesn't deactivate the mark >> when there is no duplicate lines in the region. Could that be fixed? > > This problem is not specific to `delete-duplicate-lines'. > All similar functions like e.g. `delete-matching-lines', > `delete-non-matching-lines' and `delete-blank-lines' > behave the same way. Indeed. I filed bug #10056 because of this kind of problem. I've included these cases in that bug report. Thank you. -- Dani Moncayo From unknown Sat Jun 21 02:54:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 02 Jan 2013 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator