* avoid duplicates in history @ 2004-06-01 17:00 Dan Nicolaescu 2004-06-04 3:08 ` Juri Linkov 0 siblings, 1 reply; 17+ messages in thread From: Dan Nicolaescu @ 2004-06-01 17:00 UTC (permalink / raw) One feature of tcsh that I miss in emacs is "histdup=erase". When histdup is set that way when a command is entered in history all previous occurrences of the same command will be erased. bash3 will also implement this feature, it will be called "erasedups". Here is an implementation of this feature for Emacs. If this is acceptable, I will provide a complete patch with documentation. Feedback would be appreciated. Is the history-erasedups name ok? Thanks. *** minibuf.c 27 May 2004 23:22:35 -0700 1.266 --- minibuf.c 01 Jun 2004 09:47:22 -0700 *************** *** 61,66 **** --- 61,71 ---- Lisp_Object Qhistory_length, Vhistory_length; + /* No duplicates in history. */ + + int history_erasedups; + + /* Fread_minibuffer leaves the input here as a string. */ Lisp_Object last_minibuf_string; *************** *** 742,748 **** { Lisp_Object length; ! histval = Fcons (histstring, histval); Fset (Vminibuffer_history_variable, histval); /* Truncate if requested. */ --- 747,754 ---- { Lisp_Object length; ! if (history_erasedups) Fdelete (histstring, histval); ! histval = Fcons (histstring, histval); Fset (Vminibuffer_history_variable, histval); /* Truncate if requested. */ *************** *** 2631,2636 **** --- 2637,2647 ---- property of a history variable overrides this default. */); XSETFASTINT (Vhistory_length, 30); + DEFVAR_BOOL ("history-erasedups", &history_erasedups, + doc: /* *Non-nil means delete duplicates in history. + */); + history_erasedups = 0; + DEFVAR_LISP ("completion-auto-help", &Vcompletion_auto_help, doc: /* *Non-nil means automatically provide help for invalid completion input. */); Vcompletion_auto_help = Qt; ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 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 0 siblings, 1 reply; 17+ messages in thread From: Juri Linkov @ 2004-06-04 3:08 UTC (permalink / raw) Cc: emacs-devel Dan Nicolaescu <dann@ics.uci.edu> writes: > Feedback would be appreciated. I think this is a useful feature. > Is the history-erasedups name ok? There are similar variables `comint-input-ignoredups' and `eshell-hist-ignoredups', so it could be rather named as `history-ignoredups'. OTOH, by functionality it is very like `delete-dups' so the name `history-deletedups' is no worse. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 3:08 ` Juri Linkov @ 2004-06-04 3:20 ` Miles Bader 2004-06-04 16:29 ` Dan Nicolaescu 0 siblings, 1 reply; 17+ messages in thread From: Miles Bader @ 2004-06-04 3:20 UTC (permalink / raw) Cc: Dan Nicolaescu, emacs-devel Juri Linkov <juri@jurta.org> writes: > Dan Nicolaescu <dann@ics.uci.edu> writes: >> Feedback would be appreciated. > > I think this is a useful feature. > >> Is the history-erasedups name ok? > > There are similar variables `comint-input-ignoredups' and > `eshell-hist-ignoredups', so it could be rather named as > `history-ignoredups'. > > OTOH, by functionality it is very like `delete-dups' so the name > `history-deletedups' is no worse. Yes it is, it runs two words together for no reason. Just use `history-delete-duplicates'. -Miles -- Occam's razor split hairs so well, I bought the whole argument! ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 3:20 ` Miles Bader @ 2004-06-04 16:29 ` Dan Nicolaescu 2004-06-04 19:32 ` Juri Linkov ` (2 more replies) 0 siblings, 3 replies; 17+ messages in thread From: Dan Nicolaescu @ 2004-06-04 16:29 UTC (permalink / raw) Cc: emacs-devel 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). --dan ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 16:29 ` Dan Nicolaescu @ 2004-06-04 19:32 ` Juri Linkov 2004-06-04 21:27 ` Dan Nicolaescu 2004-06-05 22:50 ` Richard Stallman 2004-06-05 13:48 ` avoid duplicates in history Richard Stallman 2004-06-26 20:45 ` Juri Linkov 2 siblings, 2 replies; 17+ messages in thread From: Juri Linkov @ 2004-06-04 19:32 UTC (permalink / raw) Cc: emacs-devel, Miles Bader Dan Nicolaescu <dann@ics.uci.edu> writes: > How about the default? Should this be turned on by default? It seems reasonable to turn it on by default. > (It would be nice to have a decision about this, so I can write the > final docs and patch). When you'll write the final patch, please don't forget to make this option customizable by adding it to cus-start.el somewhere near `history-length'. And please consider the situation where your patch doesn't work. There is the following condition in `read_minibuf': /* Don't duplicate the most recent entry in the history. */ && NILP (Fequal (histstring, Fcar (histval))))) which prevents removing all duplicate elements from the history with your patch. This condition is redundant when `history-delete-duplicates' is t. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 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 1 sibling, 1 reply; 17+ messages in thread From: Dan Nicolaescu @ 2004-06-04 21:27 UTC (permalink / raw) Cc: emacs-devel, Miles Bader Juri Linkov <juri@jurta.org> writes: > Dan Nicolaescu <dann@ics.uci.edu> writes: > When you'll write the final patch, please don't forget to make this > option customizable by adding it to cus-start.el somewhere near > `history-length'. Thanks, will do, I didn't know about that. > And please consider the situation where your patch doesn't work. > There is the following condition in `read_minibuf': > > /* Don't duplicate the most recent entry in the history. */ > && NILP (Fequal (histstring, Fcar (histval))))) > > which prevents removing all duplicate elements from the history > with your patch. > > This condition is redundant when `history-delete-duplicates' is t. I believe this is fine, that condition just avoids adding consecutive identical entries, there's no need to do anything when that condition is false. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 21:27 ` Dan Nicolaescu @ 2004-06-04 22:09 ` Juri Linkov 0 siblings, 0 replies; 17+ messages in thread From: Juri Linkov @ 2004-06-04 22:09 UTC (permalink / raw) Cc: emacs-devel Dan Nicolaescu <dann@ics.uci.edu> writes: > Juri Linkov <juri@jurta.org> writes: > > This condition is redundant when `history-delete-duplicates' is t. > > I believe this is fine, that condition just avoids adding consecutive > identical entries, there's no need to do anything when that condition > is false. It can't delete duplicates if the history contains several of them. This is possible when the value of `history-delete-duplicates' is changed during the Emacs session. But when it is set in .emacs, your patch will guarantee that no duplicates are added to the history. So for the case when the value `history-delete-duplicates' isn't changed during the Emacs session, your patch is ok. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 19:32 ` Juri Linkov 2004-06-04 21:27 ` Dan Nicolaescu @ 2004-06-05 22:50 ` Richard Stallman 2004-06-07 8:53 ` Stefan Monnier 1 sibling, 1 reply; 17+ messages in thread From: Richard Stallman @ 2004-06-05 22:50 UTC (permalink / raw) Cc: miles, dann, emacs-devel > How about the default? Should this be turned on by default? It seems reasonable to turn it on by default. Absolutely not! It would be a great surprise, and it would mean you could not look around at your error messages without changing other buffers on the screen. This is a useful feature, but only when people ask for it. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 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 0 siblings, 1 reply; 17+ messages in thread From: Stefan Monnier @ 2004-06-07 8:53 UTC (permalink / raw) Cc: Juri Linkov, dann, emacs-devel, miles >> How about the default? Should this be turned on by default? > It seems reasonable to turn it on by default. > Absolutely not! It would be a great surprise, and it would mean > you could not look around at your error messages without changing > other buffers on the screen. Huh? I don't understand why removing duplicates from the history would ever have any such effect. Could you explain what use case you're thinking of ? Stefan ^ permalink raw reply [flat|nested] 17+ messages in thread
* removing duplicate from history by default [was Re: avoid duplicates in history] 2004-06-07 8:53 ` Stefan Monnier @ 2004-09-02 0:37 ` Dan Nicolaescu 2004-09-02 19:02 ` Richard Stallman 0 siblings, 1 reply; 17+ messages in thread From: Dan Nicolaescu @ 2004-09-02 0:37 UTC (permalink / raw) Cc: Juri Linkov, miles, Stefan Monnier, emacs-devel Let's reopen the discussion started with the message here: http://lists.gnu.org/archive/html/emacs-devel/2004-06/msg00021.html I would like to prepare a patch that can be checked in. There was one question left, if removing duplicates from history should be turned on by default. IMHO duplicates should be removed from history by default, most users are more interested in the unique data present in history. If an exact sequence of events is desired M-x list-command-history can do that. [I reformated the last message from Stephan in that thread to make it clear who said what]: Dan> How about the default? Should this be turned on by default? Juri> It seems reasonable to turn it on by default. RMS> Absolutely not! It would be a great surprise, and it would mean RMS> you could not look around at your error messages without changing RMS> other buffers on the screen. Stephan> Huh? I don't understand why removing duplicates from the history Stephan> would ever have any such effect. Stephan> Could you explain what use case you're thinking of ? Thanks --dan ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: removing duplicate from history by default [was Re: avoid duplicates in history] 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 0 siblings, 1 reply; 17+ messages in thread From: Richard Stallman @ 2004-09-02 19:02 UTC (permalink / raw) Cc: juri, miles, monnier, emacs-devel Let's reopen the discussion started with the message here: http://lists.gnu.org/archive/html/emacs-devel/2004-06/msg00021.html No, please let's not. What we need to do now is fix the problems that prevent a release. Please let's not take up other changes which are not necessary now. In order to make a new release, we need to check the manual for errors. Luc Teirlinck has done a lot of work on this, but hardly anyone else has. Could you check one chapter of the Lisp manual now? ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: removing duplicate from history by default 2004-09-02 19:02 ` Richard Stallman @ 2004-09-03 23:05 ` Juri Linkov 2004-09-05 17:58 ` Dan Nicolaescu 0 siblings, 1 reply; 17+ messages in thread From: Juri Linkov @ 2004-09-03 23:05 UTC (permalink / raw) Cc: dann, emacs-devel Richard Stallman <rms@gnu.org> writes: > Let's reopen the discussion started with the message here: > > http://lists.gnu.org/archive/html/emacs-devel/2004-06/msg00021.html > > No, please let's not. What we need to do now is fix the problems > that prevent a release. Please let's not take up other changes > which are not necessary now. Concentrating on making the next release is undoubtedly the top priority, but the proposed change is so small (but still very useful), that it's better to install it now than to raise the same question again in the future. Dan Nicolaescu <dann@godzilla.ics.uci.edu> writes: > There was one question left, if removing duplicates from history > should be turned on by default. Let's not turn it on by default. Even shells don't set a variable to remove duplicates by default, isn't? And so this change will not change the current Emacs behavior. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: removing duplicate from history by default 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 0 siblings, 1 reply; 17+ messages in thread From: Dan Nicolaescu @ 2004-09-05 17:58 UTC (permalink / raw) Cc: emacs-devel Juri Linkov <juri@jurta.org> writes: > Richard Stallman <rms@gnu.org> writes: >> Let's reopen the discussion started with the message here: >> >> http://lists.gnu.org/archive/html/emacs-devel/2004-06/msg00021.html >> >> No, please let's not. What we need to do now is fix the problems >> that prevent a release. Please let's not take up other changes >> which are not necessary now. > > Concentrating on making the next release is undoubtedly the top priority, > but the proposed change is so small (but still very useful), that it's > better to install it now than to raise the same question again in the futur\ e. Agreed, the code changes are minimal: 1 line of code added + glue code to declare a lisp variable. Plus the code already exists, I have used it for a few months with no problems. > Dan Nicolaescu <dann@godzilla.ics.uci.edu> writes: > >> There was one question left, if removing duplicates from history >> should be turned on by default. > > Let's not turn it on by default. Even shells don't set a variable to > remove duplicates by default, isn't? Right. > And so this change will not change the current Emacs behavior. Sure, a complete patch is attached. Please install it if it's OK. 2004-09-05 Dan Nicolaescu <dann@ics.uci.edu> * minibuf.c (history_delete_duplicates): New variable. (read_minibuf): Use it. (syms_of_minibuf): Create the corresponding lisp variable. Index: NEWS =================================================================== RCS file: /cvsroot/emacs/emacs/etc/NEWS,v retrieving revision 1.1019 diff -c -3 -p -c -r1.1019 NEWS *** NEWS 2 Sep 2004 16:39:19 -0000 1.1019 --- NEWS 5 Sep 2004 17:54:45 -0000 *************** from the file name or buffer contents. *** 1792,1797 **** --- 1798,1807 ---- This option can be disabled, to avoid the normal behavior of isearch which puts calls to `isearch-resume' in the command history. + ** New user option `history-delete-duplicate'. + If set to t when adding a new history entry, all previous identical + entries are deleted. + --- ** Lisp mode now uses font-lock-doc-face for the docstrings. Index: minibuf.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/minibuf.c,v retrieving revision 1.271 diff -c -3 -p -c -r1.271 minibuf.c *** minibuf.c 14 Aug 2004 12:46:46 -0000 1.271 --- minibuf.c 5 Sep 2004 17:40:26 -0000 *************** Lisp_Object Vcompletion_auto_help; *** 61,66 **** --- 61,71 ---- Lisp_Object Qhistory_length, Vhistory_length; + /* No duplicates in history. */ + + int history_delete_duplicates; + + /* Fread_minibuffer leaves the input here as a string. */ Lisp_Object last_minibuf_string; *************** read_minibuf (map, initial, prompt, back *** 749,755 **** { Lisp_Object length; ! histval = Fcons (histstring, histval); Fset (Vminibuffer_history_variable, histval); /* Truncate if requested. */ --- 754,761 ---- { Lisp_Object length; ! if (history_delete_duplicates) Fdelete (histstring, histval); ! histval = Fcons (histstring, histval); Fset (Vminibuffer_history_variable, histval); /* Truncate if requested. */ *************** just after a new element is inserted. S *** 2668,2673 **** --- 2674,2685 ---- property of a history variable overrides this default. */); XSETFASTINT (Vhistory_length, 30); + DEFVAR_BOOL ("history-delete-duplicates", &history_delete_duplicates, + doc: /* *Non-nil means delete duplicates in history. + If set to t when adding a new history entry, all previous identical + entries are deleted. */); + history_delete_duplicates = 0; + DEFVAR_LISP ("completion-auto-help", &Vcompletion_auto_help, doc: /* *Non-nil means automatically provide help for invalid completion input. */); Vcompletion_auto_help = Qt; ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: removing duplicate from history by default 2004-09-05 17:58 ` Dan Nicolaescu @ 2004-09-07 3:43 ` Richard Stallman 0 siblings, 0 replies; 17+ messages in thread From: Richard Stallman @ 2004-09-07 3:43 UTC (permalink / raw) Cc: juri, emacs-devel I won't object to this simple change. Someone please install it; let's not spend more time discussing it. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 16:29 ` Dan Nicolaescu 2004-06-04 19:32 ` Juri Linkov @ 2004-06-05 13:48 ` Richard Stallman 2004-06-26 20:45 ` Juri Linkov 2 siblings, 0 replies; 17+ messages in thread From: Richard Stallman @ 2004-06-05 13:48 UTC (permalink / raw) Cc: emacs-devel, miles > 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? Please do not change the default. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-04 16:29 ` Dan Nicolaescu 2004-06-04 19:32 ` Juri Linkov 2004-06-05 13:48 ` avoid duplicates in history Richard Stallman @ 2004-06-26 20:45 ` Juri Linkov 2004-06-28 2:23 ` Richard Stallman 2 siblings, 1 reply; 17+ messages in thread From: Juri Linkov @ 2004-06-26 20:45 UTC (permalink / raw) Cc: emacs-devel 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/ ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: avoid duplicates in history 2004-06-26 20:45 ` Juri Linkov @ 2004-06-28 2:23 ` Richard Stallman 0 siblings, 0 replies; 17+ messages in thread From: Richard Stallman @ 2004-06-28 2:23 UTC (permalink / raw) Cc: dann, emacs-devel 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. I think that is too obscure to be included in Emacs; the code is short, but the cost in conceptual complexity is too great. So please don't install it. Those who would like it can put it in their .emacs files. ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2004-09-07 3:43 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2004-06-28 2:23 ` Richard Stallman
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.