emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r106912: lisp/subr.el: Rework previou


From: Juanma Barranquero
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r106912: lisp/subr.el: Rework previous change.
Date: Mon, 23 Jan 2012 03:10:36 +0100
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 106912
committer: Juanma Barranquero <address@hidden>
branch nick: trunk
timestamp: Mon 2012-01-23 03:10:36 +0100
message:
  lisp/subr.el: Rework previous change.
  
  * lisp/subr.el (display-delayed-warnings): Doc fix.
    (collapse-delayed-warnings): New function to collapse identical
    adjacent warnings.
    (delayed-warnings-hook): Add it.
modified:
  lisp/ChangeLog
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-01-23 01:10:50 +0000
+++ b/lisp/ChangeLog    2012-01-23 02:10:36 +0000
@@ -1,7 +1,9 @@
 2012-01-23  Juanma Barranquero  <address@hidden>
 
-       * subr.el (display-delayed-warnings):
-       Collapse identical adjacent messages.
+       * subr.el (display-delayed-warnings): Doc fix.
+       (collapse-delayed-warnings): New function to collapse identical
+       adjacent warnings.
+       (delayed-warnings-hook): Add it.
 
 2012-01-22  Michael Albinus  <address@hidden>
 

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2012-01-23 01:10:50 +0000
+++ b/lisp/subr.el      2012-01-23 02:10:36 +0000
@@ -1857,23 +1857,30 @@
 
 (defun display-delayed-warnings ()
   "Display delayed warnings from `delayed-warnings-list'.
-Collapse identical adjacent messages into one (plus count).
-This is the default value of `delayed-warnings-hook'."
+Used from `delayed-warnings-hook' (which see)."
+  (dolist (warning (nreverse delayed-warnings-list))
+    (apply 'display-warning warning))
+  (setq delayed-warnings-list nil))
+
+(defun collapse-delayed-warnings ()
+  "Remove duplicates from `delayed-warnings-list'.
+Collapse identical adjacent warnings into one (plus count).
+Used from `delayed-warnings-hook' (which see)."
   (let ((count 1)
-        (warnings (nreverse delayed-warnings-list))
-        warning)
-    (while warnings
-      (setq warning (pop warnings))
-      (if (equal warning (car warnings))
+        collapsed warning)
+    (while delayed-warnings-list
+      (setq warning (pop delayed-warnings-list))
+      (if (equal warning (car delayed-warnings-list))
           (setq count (1+ count))
         (when (> count 1)
           (setcdr warning (cons (format "%s [%d times]" (cadr warning) count)
                                 (cddr warning)))
           (setq count 1))
-        (apply 'display-warning warning))))
-  (setq delayed-warnings-list nil))
+        (push warning collapsed)))
+    (setq delayed-warnings-list (nreverse collapsed))))
 
-(defvar delayed-warnings-hook '(display-delayed-warnings)
+(defvar delayed-warnings-hook '(collapse-delayed-warnings
+                                display-delayed-warnings)
   "Normal hook run to process delayed warnings.
 Functions in this hook should access the `delayed-warnings-list'
 variable (which see) and remove from it the warnings they process.")


reply via email to

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