diff options
| author | Juanma Barranquero | 2012-01-23 03:10:36 +0100 |
|---|---|---|
| committer | Juanma Barranquero | 2012-01-23 03:10:36 +0100 |
| commit | 2724d9c71e29aa0aa298c3534b0b7b18d8fc6202 (patch) | |
| tree | 638dfe8e5e986086dd03f0bf00054eba894a57f9 /lisp | |
| parent | d1a5c3b45081c237658c6f6b74bbd6bc986acb60 (diff) | |
| download | emacs-2724d9c71e29aa0aa298c3534b0b7b18d8fc6202.tar.gz emacs-2724d9c71e29aa0aa298c3534b0b7b18d8fc6202.zip | |
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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/subr.el | 27 |
2 files changed, 21 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ff2b4b5f226..96c18714709 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | 2012-01-23 Juanma Barranquero <lekktu@gmail.com> | 1 | 2012-01-23 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 2 | ||
| 3 | * subr.el (display-delayed-warnings): | 3 | * subr.el (display-delayed-warnings): Doc fix. |
| 4 | Collapse identical adjacent messages. | 4 | (collapse-delayed-warnings): New function to collapse identical |
| 5 | adjacent warnings. | ||
| 6 | (delayed-warnings-hook): Add it. | ||
| 5 | 7 | ||
| 6 | 2012-01-22 Michael Albinus <michael.albinus@gmx.de> | 8 | 2012-01-22 Michael Albinus <michael.albinus@gmx.de> |
| 7 | 9 | ||
diff --git a/lisp/subr.el b/lisp/subr.el index da11b7e982a..c9e213c86a0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1857,23 +1857,30 @@ FILE should be the name of a library, with no directory name." | |||
| 1857 | 1857 | ||
| 1858 | (defun display-delayed-warnings () | 1858 | (defun display-delayed-warnings () |
| 1859 | "Display delayed warnings from `delayed-warnings-list'. | 1859 | "Display delayed warnings from `delayed-warnings-list'. |
| 1860 | Collapse identical adjacent messages into one (plus count). | 1860 | Used from `delayed-warnings-hook' (which see)." |
| 1861 | This is the default value of `delayed-warnings-hook'." | 1861 | (dolist (warning (nreverse delayed-warnings-list)) |
| 1862 | (apply 'display-warning warning)) | ||
| 1863 | (setq delayed-warnings-list nil)) | ||
| 1864 | |||
| 1865 | (defun collapse-delayed-warnings () | ||
| 1866 | "Remove duplicates from `delayed-warnings-list'. | ||
| 1867 | Collapse identical adjacent warnings into one (plus count). | ||
| 1868 | Used from `delayed-warnings-hook' (which see)." | ||
| 1862 | (let ((count 1) | 1869 | (let ((count 1) |
| 1863 | (warnings (nreverse delayed-warnings-list)) | 1870 | collapsed warning) |
| 1864 | warning) | 1871 | (while delayed-warnings-list |
| 1865 | (while warnings | 1872 | (setq warning (pop delayed-warnings-list)) |
| 1866 | (setq warning (pop warnings)) | 1873 | (if (equal warning (car delayed-warnings-list)) |
| 1867 | (if (equal warning (car warnings)) | ||
| 1868 | (setq count (1+ count)) | 1874 | (setq count (1+ count)) |
| 1869 | (when (> count 1) | 1875 | (when (> count 1) |
| 1870 | (setcdr warning (cons (format "%s [%d times]" (cadr warning) count) | 1876 | (setcdr warning (cons (format "%s [%d times]" (cadr warning) count) |
| 1871 | (cddr warning))) | 1877 | (cddr warning))) |
| 1872 | (setq count 1)) | 1878 | (setq count 1)) |
| 1873 | (apply 'display-warning warning)))) | 1879 | (push warning collapsed))) |
| 1874 | (setq delayed-warnings-list nil)) | 1880 | (setq delayed-warnings-list (nreverse collapsed)))) |
| 1875 | 1881 | ||
| 1876 | (defvar delayed-warnings-hook '(display-delayed-warnings) | 1882 | (defvar delayed-warnings-hook '(collapse-delayed-warnings |
| 1883 | display-delayed-warnings) | ||
| 1877 | "Normal hook run to process delayed warnings. | 1884 | "Normal hook run to process delayed warnings. |
| 1878 | Functions in this hook should access the `delayed-warnings-list' | 1885 | Functions in this hook should access the `delayed-warnings-list' |
| 1879 | variable (which see) and remove from it the warnings they process.") | 1886 | variable (which see) and remove from it the warnings they process.") |