ERC. For example, the function 'erc-echo-timestamp' is now
interactive and can be invoked on any message to view its timestamp in
the echo area. The command 'erc-button-previous' now moves to the
-beginning instead of the end of buttons. And the 'irccontrols' module
-now supports additional colors and special handling for "spoilers"
-(hidden text).
+beginning instead of the end of buttons. A new command, 'erc-news',
+can now be invoked to visit this very file. And the 'irccontrols'
+module now supports additional colors and special handling for
+"spoilers" (hidden text).
** Changes in the library API.
(goto-char (point-min))
(insert "X-Debbugs-CC: emacs-erc@gnu.org\n")))
+(defconst erc--news-url
+ "https://git.savannah.gnu.org/cgit/emacs.git/plain/etc/ERC-NEWS")
+
+(defvar erc--news-temp-file nil)
+
+(defun erc-news (arg)
+ "Show ERC news in a manner similar to `view-emacs-news'.
+With ARG, download and display the latest revision, which may
+contain more up-to-date information, even for older versions."
+ (interactive "P")
+ (find-file
+ (or (and arg erc--news-temp-file
+ (time-less-p (current-time) (car erc--news-temp-file))
+ (cdr erc--news-temp-file))
+ (and arg
+ (with-current-buffer (url-retrieve-synchronously erc--news-url)
+ (goto-char (point-min))
+ (search-forward "200 OK" (pos-eol))
+ (search-forward "\n\n")
+ (delete-region (point-min) (point))
+ (let ((tempfile (make-temp-file "erc-news.")))
+ (write-region (point-min) (point-max) tempfile)
+ (kill-buffer)
+ (cdr (setq erc--news-temp-file
+ (cons (time-add (current-time) (* 60 60 12))
+ tempfile))))))
+ (and-let* ((file (or (eval-when-compile (macroexp-file-name))
+ (locate-library "erc")))
+ (dir (file-name-directory file))
+ (adjacent (expand-file-name "ERC-NEWS" dir))
+ ((file-exists-p adjacent)))
+ adjacent)
+ (expand-file-name "ERC-NEWS" data-directory)))
+ (when (fboundp 'emacs-news-view-mode)
+ (emacs-news-view-mode))
+ (let ((v (mapcar #'number-to-string
+ (seq-take-while #'natnump (version-to-list erc-version)))))
+ (while (and v
+ (goto-char (point-min))
+ (not (search-forward (concat "\014\n* Changes in ERC "
+ (string-join v "."))
+ nil t)))
+ (setq v (butlast v))))
+ (beginning-of-line))
+
(defun erc-port-to-string (p)
"Convert port P to a string.
P may be an integer or a service name."