unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: avoid duplicates in history
Date: Sat, 26 Jun 2004 23:45:41 +0300	[thread overview]
Message-ID: <87hdsyqc96.fsf@mail.jurta.org> (raw)
In-Reply-To: <200406041629.i54GTDGK020998@scanner2.ics.uci.edu> (Dan Nicolaescu's message of "Fri, 04 Jun 2004 09:29:14 -0700")

Dan Nicolaescu <dann@ics.uci.edu> writes:
> Miles Bader <miles@lsi.nec.co.jp> 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/

  parent reply	other threads:[~2004-06-26 20:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-01 17:00 avoid duplicates in history Dan Nicolaescu
2004-06-04  3:08 ` Juri Linkov
2004-06-04  3:20   ` Miles Bader
2004-06-04 16:29     ` Dan Nicolaescu
2004-06-04 19:32       ` Juri Linkov
2004-06-04 21:27         ` Dan Nicolaescu
2004-06-04 22:09           ` Juri Linkov
2004-06-05 22:50         ` Richard Stallman
2004-06-07  8:53           ` Stefan Monnier
2004-09-02  0:37             ` removing duplicate from history by default [was Re: avoid duplicates in history] Dan Nicolaescu
2004-09-02 19:02               ` Richard Stallman
2004-09-03 23:05                 ` removing duplicate from history by default Juri Linkov
2004-09-05 17:58                   ` Dan Nicolaescu
2004-09-07  3:43                     ` Richard Stallman
2004-06-05 13:48       ` avoid duplicates in history Richard Stallman
2004-06-26 20:45       ` Juri Linkov [this message]
2004-06-28  2:23         ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hdsyqc96.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).