emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112618: * subr.el (delete-consecutiv


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112618: * subr.el (delete-consecutive-dups): New function.
Date: Fri, 17 May 2013 10:43:41 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112618
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Fri 2013-05-17 10:43:41 +0800
message:
  * subr.el (delete-consecutive-dups): New function.
  * ido.el (ido-set-matches-1): Use it.
  * progmodes/octave.el (inferior-octave-completion-table): Use it.
  * ido.el (ido-remove-consecutive-dups): Remove.
modified:
  lisp/ChangeLog
  lisp/ido.el
  lisp/progmodes/octave.el
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-17 00:36:33 +0000
+++ b/lisp/ChangeLog    2013-05-17 02:43:41 +0000
@@ -1,3 +1,10 @@
+2013-05-17  Leo Liu  <address@hidden>
+
+       * subr.el (delete-consecutive-dups): New function.
+       * ido.el (ido-set-matches-1): Use it.
+       * progmodes/octave.el (inferior-octave-completion-table): Use it.
+       * ido.el (ido-remove-consecutive-dups): Remove.
+
 2013-05-17  Stefan Monnier  <address@hidden>
 
        * progmodes/f90.el (f90-keywords-re, f90-keywords-level-3-re)

=== modified file 'lisp/ido.el'
--- a/lisp/ido.el       2013-05-08 14:22:24 +0000
+++ b/lisp/ido.el       2013-05-17 02:43:41 +0000
@@ -3785,7 +3785,7 @@
           (if (string-match re name)
               (setq matches (cons item matches)))))
        items))
-    matches))
+    (delete-consecutive-dups matches t)))
 
 
 (defun ido-set-matches ()
@@ -4676,21 +4676,6 @@
                              ido-temp-list))))
     (ido-to-end summaries)))
 
-(defun ido-remove-consecutive-dups (list)
-  "Remove consecutive duplicates in LIST.
-Use `equal' for comparison.  First and last elements are
-considered consecutive."
-  (let ((tail list)
-       (last (make-symbol ""))
-       (result nil))
-    (while (consp tail)
-      (unless (equal (car tail) last)
-       (push (setq last (car tail)) result))
-      (setq tail (cdr tail)))
-    (nreverse (or (and (equal last (car list))
-                      (cdr result))
-                 result))))
-
 ;;; Helper functions for other programs
 
 (put 'dired-do-rename 'ido 'ignore)
@@ -4808,7 +4793,7 @@
        (ido-directory-nonreadable nil)
        (ido-directory-too-big nil)
        (ido-context-switch-command 'ignore)
-       (ido-choice-list (ido-remove-consecutive-dups choices)))
+       (ido-choice-list choices))
     ;; Initialize ido before invoking ido-read-internal
     (ido-common-initialization)
     (ido-read-internal 'list prompt hist def require-match initial-input)))

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-05-16 08:52:02 +0000
+++ b/lisp/progmodes/octave.el  2013-05-17 02:43:41 +0000
@@ -38,7 +38,9 @@
 (require 'newcomment)
 (eval-and-compile
   (unless (fboundp 'user-error)
-    (defalias 'user-error 'error)))
+    (defalias 'user-error 'error))
+  (unless (fboundp 'delete-consecutive-dups)
+    (defalias 'delete-consecutive-dups 'delete-dups)))
 (eval-when-compile
   (unless (fboundp 'setq-local)
     (defmacro setq-local (var val)
@@ -777,8 +779,8 @@
          (inferior-octave-send-list-and-digest
           (list (concat "completion_matches (\"" command "\");\n")))
          (setq cache (list command (float-time)
-                           (sort (delete-dups inferior-octave-output-list)
-                                 'string-lessp))))
+                           (delete-consecutive-dups
+                            (sort inferior-octave-output-list 
'string-lessp)))))
        (car (cddr cache))))))
 
 (defun inferior-octave-completion-at-point ()

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2013-05-16 10:14:30 +0000
+++ b/lisp/subr.el      2013-05-17 02:43:41 +0000
@@ -376,6 +376,23 @@
       (setq tail (cdr tail))))
   list)
 
+;; See http://lists.gnu.org/archive/html/emacs-devel/2013-05/msg00204.html
+(defun delete-consecutive-dups (list &optional circular)
+  "Destructively remove `equal' consecutive duplicates from LIST.
+First and last elements are considered consecutive if CIRCULAR is
+non-nil."
+  (let ((tail list) last)
+    (while (consp tail)
+      (if (equal (car tail) (cadr tail))
+         (setcdr tail (cddr tail))
+       (setq last (car tail)
+             tail (cdr tail))))
+    (if (and circular
+            (cdr list)
+            (equal last (car list)))
+       (nbutlast list)
+      list)))
+
 (defun number-sequence (from &optional to inc)
   "Return a sequence of numbers from FROM to TO (both inclusive) as a list.
 INC is the increment used between numbers in the sequence and defaults to 1.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]