From: storm@cua.dk (Kim F. Storm)
Cc: Drew Adams <drew.adams@oracle.com>, emacs-devel@gnu.org
Subject: Re: should search ring contain duplicates?
Date: Fri, 05 May 2006 00:44:09 +0200 [thread overview]
Message-ID: <m3y7xhv29y.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <m3k691g75s.fsf@kfs-l.imdomain.dk> (Kim F. Storm's message of "Thu, 04 May 2006 17:07:43 +0200")
storm@cua.dk (Kim F. Storm) writes:
> There are many places where this would be useful!
For example:
Index: lisp/subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.505
diff -c -r1.505 subr.el
*** lisp/subr.el 29 Apr 2006 13:56:19 -0000 1.505
--- lisp/subr.el 4 May 2006 22:44:11 -0000
***************
*** 1122,1127 ****
--- 1124,1155 ----
(if (and oa ob)
(< oa ob)
oa)))))))
+
+ (defun add-to-history (history-var newelt &optional maxelt keep-dups)
+ "Add NEWELT to the history list stored in the variable HISTORY-VAR.
+ Return the new history list.
+ If MAXELT is non-nil, it specifies the maximum length of the history.
+ Otherwise, the maximum history length is the value of the `history-length'
+ property on symbol HISTORY-VAR, if set, or the value of the `history-length'
+ variable.
+ Remove duplicates of NEWELT unless `history-delete-duplicates' is nil
+ or KEEP-DUPS is non-nil."
+ (unless maxelt
+ (setq maxelt (or (get history-var 'history-length)
+ history-length)))
+ (let ((history (symbol-value history-var))
+ tail)
+ (if (and history-delete-duplicates (not keep-dups))
+ (setq history (delete newelt history)))
+ (setq history (cons newelt history))
+ (when (integerp maxelt)
+ (if (= 0 maxelt)
+ (setq history nil)
+ (setq tail (nthcdr (1- maxelt) history))
+ (when (consp tail)
+ (setcdr tail nil))))
+ (set history-var history)))
+
\f
;;;; Mode hooks.
Index: lisp/ediff.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ediff.el,v
retrieving revision 1.78
diff -c -r1.78 ediff.el
*** lisp/ediff.el 19 Feb 2006 03:16:44 -0000 1.78
--- lisp/ediff.el 4 May 2006 22:41:46 -0000
***************
*** 210,221 ****
ediff-last-dir-B
(file-name-directory f)))
(progn
! (setq file-name-history
! (cons (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B))
! file-name-history))
(ediff-get-default-file-name f 1)))
)))
(ediff-files-internal file-A
--- 210,220 ----
ediff-last-dir-B
(file-name-directory f)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B)))
(ediff-get-default-file-name f 1)))
)))
(ediff-files-internal file-A
***************
*** 246,270 ****
ediff-last-dir-B
(file-name-directory f)))
(progn
! (setq file-name-history
! (cons
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B))
! file-name-history))
(ediff-get-default-file-name f 1))))
(ediff-read-file-name "File C to compare"
(setq dir-C (if ediff-use-last-dir
ediff-last-dir-C
(file-name-directory ff)))
(progn
! (setq file-name-history
! (cons (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory ff)
! dir-C))
! file-name-history))
(ediff-get-default-file-name ff 2)))
)))
(ediff-files-internal file-A
--- 245,266 ----
ediff-last-dir-B
(file-name-directory f)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B)))
(ediff-get-default-file-name f 1))))
(ediff-read-file-name "File C to compare"
(setq dir-C (if ediff-use-last-dir
ediff-last-dir-C
(file-name-directory ff)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory ff)
! dir-C)))
(ediff-get-default-file-name ff 2)))
)))
(ediff-files-internal file-A
***************
*** 1109,1120 ****
ediff-last-dir-B
(file-name-directory f)))
(progn
! (setq file-name-history
! (cons (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B))
! file-name-history))
(ediff-get-default-file-name f 1)))
)))
(setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
--- 1105,1115 ----
ediff-last-dir-B
(file-name-directory f)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B)))
(ediff-get-default-file-name f 1)))
)))
(setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
***************
*** 1153,1165 ****
ediff-last-dir-B
(file-name-directory f)))
(progn
! (setq file-name-history
! (cons
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B))
! file-name-history))
(ediff-get-default-file-name f 1))))
(ediff-read-file-name "Ancestor file"
(setq dir-ancestor
--- 1148,1158 ----
ediff-last-dir-B
(file-name-directory f)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory f)
! dir-B)))
(ediff-get-default-file-name f 1))))
(ediff-read-file-name "Ancestor file"
(setq dir-ancestor
***************
*** 1167,1178 ****
ediff-last-dir-ancestor
(file-name-directory ff)))
(progn
! (setq file-name-history
! (cons (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory ff)
! dir-ancestor))
! file-name-history))
(ediff-get-default-file-name ff 2)))
)))
(setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
--- 1160,1170 ----
ediff-last-dir-ancestor
(file-name-directory ff)))
(progn
! (add-to-history 'file-name-history
! (ediff-abbreviate-file-name
! (expand-file-name
! (file-name-nondirectory ff)
! dir-ancestor)))
(ediff-get-default-file-name ff 2)))
)))
(setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
Index: lisp/env.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/env.el,v
retrieving revision 1.36
diff -c -r1.36 env.el
*** lisp/env.el 18 Apr 2006 21:17:50 -0000 1.36
--- lisp/env.el 4 May 2006 22:42:16 -0000
***************
*** 117,123 ****
(let* ((var (read-envvar-name "Set environment variable: " nil))
(value (getenv var)))
(when value
! (push value setenv-history))
;; Here finally we specify the args to give call setenv with.
(list var
(read-from-minibuffer (format "Set %s to value: " var)
--- 117,123 ----
(let* ((var (read-envvar-name "Set environment variable: " nil))
(value (getenv var)))
(when value
! (add-to-history 'setenv-history value))
;; Here finally we specify the args to give call setenv with.
(list var
(read-from-minibuffer (format "Set %s to value: " var)
Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.287
diff -c -r1.287 isearch.el
*** lisp/isearch.el 3 May 2006 23:27:53 -0000 1.287
--- lisp/isearch.el 4 May 2006 22:42:46 -0000
***************
*** 831,851 ****
(defun isearch-update-ring (string &optional regexp)
"Add STRING to the beginning of the search ring.
REGEXP if non-nil says use the regexp search ring."
! (if regexp
! (when (or (null regexp-search-ring)
! (not (string= string (car regexp-search-ring))))
! (when history-delete-duplicates
! (setq regexp-search-ring (delete string regexp-search-ring)))
! (push string regexp-search-ring)
! (when (> (length regexp-search-ring) regexp-search-ring-max)
! (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) nil)))
! (when (or (null search-ring)
! (not (string= string (car search-ring))))
! (when history-delete-duplicates
! (setq search-ring (delete string search-ring)))
! (push string search-ring)
! (when (> (length search-ring) search-ring-max)
! (setcdr (nthcdr (1- search-ring-max) search-ring) nil)))))
;; Switching buffers should first terminate isearch-mode.
;; ;; For Emacs 19, the frame switch event is handled.
--- 831,839 ----
(defun isearch-update-ring (string &optional regexp)
"Add STRING to the beginning of the search ring.
REGEXP if non-nil says use the regexp search ring."
! (add-to-history
! (if regexp 'regexp-search-ring 'search-ring)
! (if regexp regexp-search-ring-max search-ring-max)))
;; Switching buffers should first terminate isearch-mode.
;; ;; For Emacs 19, the frame switch event is handled.
Index: lisp/kmacro.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/kmacro.el,v
retrieving revision 1.32
diff -c -r1.32 kmacro.el
*** lisp/kmacro.el 6 Feb 2006 14:33:34 -0000 1.32
--- lisp/kmacro.el 4 May 2006 22:43:11 -0000
***************
*** 349,358 ****
(defun kmacro-push-ring (&optional elt)
"Push ELT or current macro onto `kmacro-ring'."
(when (setq elt (or elt (kmacro-ring-head)))
! (let ((len (length kmacro-ring)))
! (setq kmacro-ring (cons elt kmacro-ring))
! (if (>= len kmacro-ring-max)
! (setcdr (nthcdr len kmacro-ring) nil)))))
(defun kmacro-split-ring-element (elt)
--- 349,355 ----
(defun kmacro-push-ring (&optional elt)
"Push ELT or current macro onto `kmacro-ring'."
(when (setq elt (or elt (kmacro-ring-head)))
! (add-to-history 'kmacro-ring elt kmacro-ring-max t)))
(defun kmacro-split-ring-element (elt)
***************
*** 377,387 ****
(kmacro-pop-ring1 raw)))
- (defun kmacro-ring-length ()
- "Return length of macro ring, including pseudo head."
- (+ (if last-kbd-macro 1 0) (length kmacro-ring)))
-
-
(defun kmacro-ring-empty-p (&optional none)
"Tell user and return t if `last-kbd-macro' is nil or `kmacro-ring' is empty.
Check only `last-kbd-macro' if optional arg NONE is non-nil."
--- 374,379 ----
***************
*** 577,589 ****
(let ((append (and arg (listp arg))))
(unless append
(if last-kbd-macro
! (let ((len (length kmacro-ring)))
! (setq kmacro-ring
! (cons
! (list last-kbd-macro kmacro-counter kmacro-counter-format-start)
! kmacro-ring))
! (if (>= len kmacro-ring-max)
! (setcdr (nthcdr len kmacro-ring) nil))))
(setq kmacro-counter (or (if arg (prefix-numeric-value arg))
kmacro-initial-counter-value
0)
--- 569,576 ----
(let ((append (and arg (listp arg))))
(unless append
(if last-kbd-macro
! (kmacro-push-ring
! (list last-kbd-macro kmacro-counter kmacro-counter-format-start)))
(setq kmacro-counter (or (if arg (prefix-numeric-value arg))
kmacro-initial-counter-value
0)
Index: lisp/server.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/server.el,v
retrieving revision 1.109
diff -c -r1.109 server.el
*** lisp/server.el 4 Mar 2006 16:06:46 -0000 1.109
--- lisp/server.el 4 May 2006 22:43:33 -0000
***************
*** 411,417 ****
;; deleted file, offer to write it.
(let* ((filen (car file))
(obuf (get-file-buffer filen)))
! (push filen file-name-history)
(if (and obuf (set-buffer obuf))
(progn
(cond ((file-exists-p filen)
--- 411,417 ----
;; deleted file, offer to write it.
(let* ((filen (car file))
(obuf (get-file-buffer filen)))
! (add-to-history 'file-name-history filen)
(if (and obuf (set-buffer obuf))
(progn
(cond ((file-exists-p filen)
Index: lisp/progmodes/grep.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.55
diff -c -r1.55 grep.el
*** lisp/progmodes/grep.el 2 May 2006 08:49:59 -0000 1.55
--- lisp/progmodes/grep.el 4 May 2006 22:43:51 -0000
***************
*** 676,682 ****
(setq command
(read-from-minibuffer "Confirm: "
command nil nil 'grep-history))
! (push command grep-history))))
(when command
;; Setting process-setup-function makes exit-message-function work
;; even when async processes aren't supported.
--- 676,682 ----
(setq command
(read-from-minibuffer "Confirm: "
command nil nil 'grep-history))
! (add-to-history 'grep-history command))))
(when command
;; Setting process-setup-function makes exit-message-function work
;; even when async processes aren't supported.
***************
*** 742,748 ****
(setq command
(read-from-minibuffer "Confirm: "
command nil nil 'grep-find-history))
! (push command grep-find-history))
(compilation-start command 'grep-mode))))))
--- 742,748 ----
(setq command
(read-from-minibuffer "Confirm: "
command nil nil 'grep-find-history))
! (add-to-history 'grep-find-history command))
(compilation-start command 'grep-mode))))))
Index: lisp/progmodes/vhdl-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/vhdl-mode.el,v
retrieving revision 1.50
diff -c -r1.50 vhdl-mode.el
*** lisp/progmodes/vhdl-mode.el 10 Feb 2006 09:00:30 -0000 1.50
--- lisp/progmodes/vhdl-mode.el 4 May 2006 22:45:20 -0000
***************
*** 16723,16730 ****
(progn (save-buffer)
(kill-buffer (current-buffer))
(set-buffer orig-buffer)
! (setq file-name-history
! (cons makefile-path-name file-name-history)))
(vhdl-warning-when-idle
(format "File not writable: \"%s\""
(abbreviate-file-name makefile-path-name)))
--- 16723,16729 ----
(progn (save-buffer)
(kill-buffer (current-buffer))
(set-buffer orig-buffer)
! (add-to-history 'file-name-history makefile-path-name))
(vhdl-warning-when-idle
(format "File not writable: \"%s\""
(abbreviate-file-name makefile-path-name)))
Index: lisp/progmodes/xscheme.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/xscheme.el,v
retrieving revision 1.9
diff -c -r1.9 xscheme.el
*** lisp/progmodes/xscheme.el 10 Feb 2006 09:00:30 -0000 1.9
--- lisp/progmodes/xscheme.el 4 May 2006 22:45:38 -0000
***************
*** 580,591 ****
;;;; Scheme expressions ring
(defun xscheme-insert-expression (string)
! (setq xscheme-expressions-ring (cons string xscheme-expressions-ring))
! (if (> (length xscheme-expressions-ring) xscheme-expressions-ring-max)
! (setcdr (nthcdr (1- xscheme-expressions-ring-max)
! xscheme-expressions-ring)
! nil))
! (setq xscheme-expressions-ring-yank-pointer xscheme-expressions-ring))
(defun xscheme-rotate-yank-pointer (arg)
"Rotate the yanking point in the kill ring."
--- 580,588 ----
;;;; Scheme expressions ring
(defun xscheme-insert-expression (string)
! (setq xscheme-expressions-ring-yank-pointer
! (add-to-history 'xscheme-expressions-ring string
! xscheme-expressions-ring-max)))
(defun xscheme-rotate-yank-pointer (arg)
"Rotate the yanking point in the kill ring."
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
next prev parent reply other threads:[~2006-05-04 22:44 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-03 0:54 should search ring contain duplicates? Drew Adams
2006-05-03 7:27 ` Dan Nicolaescu
2006-05-03 8:26 ` Kim F. Storm
2006-05-03 12:48 ` Juri Linkov
2006-05-03 13:53 ` Kim F. Storm
2006-05-04 10:12 ` Kim F. Storm
2006-05-04 10:29 ` David Kastrup
2006-05-04 12:00 ` Stefan Monnier
2006-05-04 12:19 ` Kim F. Storm
2006-05-04 12:25 ` David Kastrup
2006-05-05 22:14 ` Richard Stallman
2006-05-05 23:55 ` Kim F. Storm
2006-05-06 8:00 ` Eli Zaretskii
2006-05-06 23:36 ` Richard Stallman
2006-05-07 20:41 ` Kim F. Storm
2006-05-04 16:05 ` Stuart D. Herring
2006-05-04 16:23 ` David Kastrup
2006-05-04 16:36 ` Stuart D. Herring
2006-05-04 21:55 ` Kim F. Storm
2006-05-03 15:04 ` query-replace in isearch (was Re: should search ring contain duplicates?) Dan Nicolaescu
2006-05-03 20:27 ` query-replace in isearch Juri Linkov
2006-05-03 20:43 ` query-replace in isearch (was Re: should search ring contain duplicates?) Richard Stallman
2006-05-11 3:45 ` Richard Stallman
2006-05-11 11:57 ` Juri Linkov
2006-05-11 14:10 ` Kim F. Storm
2006-05-11 21:52 ` Juri Linkov
2006-05-19 3:05 ` Juri Linkov
2006-05-20 22:39 ` Kim F. Storm
2006-05-21 4:27 ` Juri Linkov
2006-05-21 0:55 ` Richard Stallman
2006-05-23 5:17 ` Juri Linkov
2006-05-24 2:18 ` Richard Stallman
2006-05-25 22:47 ` Juri Linkov
2006-05-29 6:39 ` Richard Stallman
2006-05-30 9:28 ` Juri Linkov
2006-05-31 0:40 ` Richard Stallman
2006-05-12 4:15 ` Richard Stallman
2006-05-12 11:14 ` Juri Linkov
2006-05-13 4:52 ` Richard Stallman
2006-05-13 23:13 ` Kim F. Storm
2006-05-14 15:09 ` Richard Stallman
2006-05-14 20:52 ` Kim F. Storm
2006-05-09 20:47 ` should search ring contain duplicates? Juri Linkov
2006-05-10 9:34 ` Kim F. Storm
2006-05-10 22:55 ` Juri Linkov
2006-05-11 10:08 ` Kim F. Storm
2006-05-14 23:29 ` Richard Stallman
2006-05-15 9:54 ` Kim F. Storm
2006-05-16 4:29 ` Richard Stallman
2006-05-16 11:07 ` Kim F. Storm
2006-05-11 11:59 ` C-f in isearch minibuffer (was: should search ring contain duplicates?) Juri Linkov
2006-05-11 14:04 ` C-f in isearch minibuffer Miles Bader
2006-05-11 21:52 ` Juri Linkov
2006-05-12 4:15 ` C-f in isearch minibuffer (was: should search ring contain duplicates?) Richard Stallman
2006-05-12 11:12 ` C-f in isearch minibuffer Juri Linkov
2006-05-13 4:52 ` Richard Stallman
2006-05-03 14:18 ` should search ring contain duplicates? Stefan Monnier
2006-05-03 14:25 ` Kim F. Storm
2006-05-03 14:40 ` Drew Adams
2006-05-03 15:54 ` Drew Adams
2006-05-03 20:27 ` Juri Linkov
2006-05-03 23:08 ` Drew Adams
2006-05-04 14:17 ` Richard Stallman
2006-05-04 15:07 ` Kim F. Storm
2006-05-04 22:44 ` Kim F. Storm [this message]
2006-05-05 19:05 ` Richard Stallman
2006-05-05 19:14 ` Drew Adams
2006-05-05 19:25 ` David Kastrup
2006-05-05 20:09 ` Drew Adams
2006-05-06 14:25 ` Richard Stallman
2006-05-05 23:22 ` Juri Linkov
2006-05-05 23:32 ` Kim F. Storm
2006-05-06 2:05 ` Drew Adams
2006-05-03 14:43 ` Dan Nicolaescu
2006-05-04 19:41 ` Richard Stallman
2006-05-03 20:42 ` Richard Stallman
2006-05-03 22:41 ` Dan Nicolaescu
2006-05-04 19:41 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2006-05-14 23:29 Richard Stallman
2006-05-14 23:46 ` Drew Adams
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3y7xhv29y.fsf@kfs-l.imdomain.dk \
--to=storm@cua.dk \
--cc=drew.adams@oracle.com \
--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 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.