[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid duplicates in history
From: |
Juri Linkov |
Subject: |
Re: avoid duplicates in history |
Date: |
Sat, 26 Jun 2004 23:45:41 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Dan Nicolaescu <address@hidden> writes:
> Miles Bader <address@hidden> 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/