From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: avoid duplicates in history Date: Sat, 26 Jun 2004 23:45:41 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87hdsyqc96.fsf@mail.jurta.org> References: <200406011700.i51H0MGK001165@scanner2.ics.uci.edu> <87llj4gguw.fsf@mail.jurta.org> <200406041629.i54GTDGK020998@scanner2.ics.uci.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1088283208 13402 80.91.224.253 (26 Jun 2004 20:53:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 26 Jun 2004 20:53:28 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Jun 26 22:53:17 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BeKAm-0000O9-00 for ; Sat, 26 Jun 2004 22:53:16 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BeKAm-0001oh-00 for ; Sat, 26 Jun 2004 22:53:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BeKCI-0007Ls-Kx for emacs-devel@quimby.gnus.org; Sat, 26 Jun 2004 16:54:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BeKC7-0007Jf-Dz for emacs-devel@gnu.org; Sat, 26 Jun 2004 16:54:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BeKC4-0007J8-Lw for emacs-devel@gnu.org; Sat, 26 Jun 2004 16:54:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BeKC4-0007J5-In for emacs-devel@gnu.org; Sat, 26 Jun 2004 16:54:36 -0400 Original-Received: from [66.33.219.19] (helo=spoon.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BeKAQ-00085U-4d for emacs-devel@gnu.org; Sat, 26 Jun 2004 16:52:57 -0400 Original-Received: from mail.jurta.org (80-235-41-6-dsl.mus.estpak.ee [80.235.41.6]) by spoon.dreamhost.com (Postfix) with ESMTP id 8CD1D13D84B; Sat, 26 Jun 2004 13:52:39 -0700 (PDT) Original-To: Dan Nicolaescu In-Reply-To: <200406041629.i54GTDGK020998@scanner2.ics.uci.edu> (Dan Nicolaescu's message of "Fri, 04 Jun 2004 09:29:14 -0700") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25269 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25269 Dan Nicolaescu writes: > Miles Bader writes: > > Yes it is, it runs two words together for no reason. Just use > > `history-delete-duplicates'. > > How about the default? Should this be turned on by default? > > I even got some suggestions that deleting duplicates should be the > only way to do it. > > (It would be nice to have a decision about this, so I can write the > final docs and patch). This is a good feature even without turning it on by default. I think it should be installed after renaming to history-delete-duplicates and updating the Emacs manual and NEWS. Meanwhile, I'd like to propose a related feature. It would be useful to be able to delete some old history elements from the history list. I think a good key binding for this command in the minibuffer is M-k. Index: lisp/simple.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v retrieving revision 1.648 diff -u -r1.648 simple.el --- lisp/simple.el 13 Jun 2004 22:00:17 -0000 1.648 +++ lisp/simple.el 26 Jun 2004 20:16:59 -0000 @@ -1106,6 +1183,24 @@ (interactive "p") (next-complete-history-element (- n))) +(defun delete-history-element () + "Delete the current minibuffer history element from the history. +After deleting the element the history position is changed either +to the the previous history element, or to the next history element +if the deleted element was the last in the history list." + (interactive) + (cond + ((= minibuffer-history-position 1) + (set minibuffer-history-variable + (cdr (symbol-value minibuffer-history-variable)))) + ((> minibuffer-history-position 1) + (setcdr (nthcdr (- minibuffer-history-position 2) + (symbol-value minibuffer-history-variable)) + (nthcdr minibuffer-history-position + (symbol-value minibuffer-history-variable))))) + (condition-case nil (next-history-element 1) (error nil)) + (condition-case nil (previous-history-element 1) (error nil))) + ;; For compatibility with the old subr of the same name. (defun minibuffer-prompt-width () "Return the display width of the minibuffer prompt. Index: lisp/bindings.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v retrieving revision 1.132 diff -u -r1.132 bindings.el --- lisp/bindings.el 12 Jun 2004 10:15:11 -0000 1.132 +++ lisp/bindings.el 26 Jun 2004 20:20:37 -0000 @@ -658,7 +658,8 @@ (define-key map [prior] 'previous-history-element) (define-key map [up] 'previous-history-element) (define-key map "\es" 'next-matching-history-element) - (define-key map "\er" 'previous-matching-history-element)) + (define-key map "\er" 'previous-matching-history-element) + (define-key map "\ek" 'delete-history-element)) (define-key global-map "\C-u" 'universal-argument) (let ((i ?0)) -- Juri Linkov http://www.jurta.org/emacs/