commit 0b049fe71d73f6885a3c81ea31829e3befc18933 (HEAD, refs/remotes/origin/master) Merge: c18bfbe6e4 b77f6af24e Author: Glenn Morris Date: Fri Aug 6 08:49:32 2021 -0700 Merge from origin/emacs-27 b77f6af24e (origin/emacs-27) ERC right stamps: also use latest buffer... # Conflicts: # lisp/erc/erc-stamp.el commit c18bfbe6e452bfbef276fc8325bdbfc6c7e0d61b Author: dickmao Date: Fri Aug 6 13:29:31 2021 +0200 Improve ffap-ido-mode test * test/lisp/ffap-tests.el (ffap-ido-mode): Actually test `ido-everywhere' at run time, not compile time (bug#49895). diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el index 4fb4c90e76..f8113bffc1 100644 --- a/test/lisp/ffap-tests.el +++ b/test/lisp/ffap-tests.el @@ -127,13 +127,17 @@ left alone when opening a URL in an external browser." (require 'ido) (with-temp-buffer (let ((ido-mode t) - (read-filename-function read-file-name-function) + (read-file-name-function read-file-name-function) (read-buffer-function read-buffer-function)) - (ido-everywhere) + ;; Says ert-deftest: + ;; Macros in BODY are expanded when the test is defined, not when it + ;; is run. If a macro (possibly with side effects) is to be tested, + ;; it has to be wrapped in `(eval (quote ...))'. + (eval (quote (ido-everywhere))) (let ((read-file-name-function (lambda (&rest args) - (expand-file-name - (nth 4 args) - (nth 1 args))))) + (expand-file-name + (nth 4 args) + (nth 1 args))))) (save-excursion (insert "ffap-tests.el")) (let (kill-buffer-query-functions) (kill-buffer (call-interactively #'find-file-at-point))))))) commit 93e1248c2085dfb675d7ed916ec5621e3fe6e2c6 Author: dick r. chiang Date: Fri Aug 6 13:24:53 2021 +0200 Fix problem with occasional stalls in `url-retrieve-synchronously' * lisp/url/url.el (url-retrieve-synchronously): Use `accept-process-output' on a null process. That is the safer, more conventional way of achieving non-blocking sleep-for (bug#49897). Also rewrite for greater readability. diff --git a/lisp/url/url.el b/lisp/url/url.el index a6565e2cdb..ccc95a6eec 100644 --- a/lisp/url/url.el +++ b/lisp/url/url.el @@ -235,85 +235,55 @@ If INHIBIT-COOKIES is non-nil, refuse to store cookies. If TIMEOUT is passed, it should be a number that says (in seconds) how long to wait for a response before giving up." (url-do-setup) - - (let ((retrieval-done nil) - (start-time (current-time)) - (url-asynchronous nil) - (asynch-buffer nil) - (timed-out nil)) - (setq asynch-buffer - (url-retrieve url (lambda (&rest ignored) - (url-debug 'retrieval "Synchronous fetching done (%S)" (current-buffer)) - (setq retrieval-done t - asynch-buffer (current-buffer))) - nil silent inhibit-cookies)) - (if (null asynch-buffer) - ;; We do not need to do anything, it was a mailto or something - ;; similar that takes processing completely outside of the URL - ;; package. - nil - (let ((proc (get-buffer-process asynch-buffer))) - ;; If the access method was synchronous, `retrieval-done' should - ;; hopefully already be set to t. If it is nil, and `proc' is also - ;; nil, it implies that the async process is not running in - ;; asynch-buffer. This happens e.g. for FTP files. In such a case - ;; url-file.el should probably set something like a `url-process' - ;; buffer-local variable so we can find the exact process that we - ;; should be waiting for. In the mean time, we'll just wait for any - ;; process output. - (while (and (not retrieval-done) - (or (not timeout) - (not (setq timed-out - (time-less-p timeout - (time-since start-time)))))) - (url-debug 'retrieval - "Spinning in url-retrieve-synchronously: %S (%S)" - retrieval-done asynch-buffer) - (if (buffer-local-value 'url-redirect-buffer asynch-buffer) - (setq proc (get-buffer-process - (setq asynch-buffer - (buffer-local-value 'url-redirect-buffer - asynch-buffer)))) - (if (and proc (memq (process-status proc) - '(closed exit signal failed)) - ;; Make sure another process hasn't been started. - (eq proc (or (get-buffer-process asynch-buffer) proc))) - ;; FIXME: It's not clear whether url-retrieve's callback is - ;; guaranteed to be called or not. It seems that url-http - ;; decides sometimes consciously not to call it, so it's not - ;; clear that it's a bug, but even then we need to decide how - ;; url-http can then warn us that the download has completed. - ;; In the mean time, we use this here workaround. - ;; XXX: The callback must always be called. Any - ;; exception is a bug that should be fixed, not worked - ;; around. - (progn ;; Call delete-process so we run any sentinel now. - (delete-process proc) - (setq retrieval-done t))) - ;; We used to use `sit-for' here, but in some cases it wouldn't - ;; work because apparently pending keyboard input would always - ;; interrupt it before it got a chance to handle process input. - ;; `sleep-for' was tried but it lead to other forms of - ;; hanging. --Stef - (unless (or (with-local-quit - (accept-process-output proc 1)) - (null proc)) - ;; accept-process-output returned nil, maybe because the process - ;; exited (and may have been replaced with another). If we got - ;; a quit, just stop. - (when quit-flag - (delete-process proc)) - (setq proc (and (not quit-flag) - (get-buffer-process asynch-buffer)))))) - ;; On timeouts, make sure we kill any pending processes. - ;; There may be more than one if we had a redirect. - (when timed-out - (when (process-live-p proc) - (delete-process proc)) - (when-let ((aproc (get-buffer-process asynch-buffer))) - (when (process-live-p aproc) - (delete-process aproc)))))) - asynch-buffer)) + (let* (url-asynchronous + data-buffer + (callback (lambda (&rest _args) + (setq data-buffer (current-buffer)) + (url-debug 'retrieval + "Synchronous fetching done (%S)" + data-buffer))) + (start-time (current-time)) + (proc-buffer (url-retrieve url callback nil silent + inhibit-cookies))) + (if (not proc-buffer) + (url-debug 'retrieval "Synchronous fetching unnecessary %s" url) + (unwind-protect + (catch 'done + (while (not data-buffer) + (when (and timeout (time-less-p timeout + (time-since start-time))) + (url-debug 'retrieval "Timed out %s (after %ss)" url + (float-time (time-since start-time))) + (throw 'done 'timeout)) + (url-debug 'retrieval + "Spinning in url-retrieve-synchronously: nil (%S)" + proc-buffer) + (when-let ((redirect-buffer + (buffer-local-value 'url-redirect-buffer + proc-buffer))) + (unless (eq redirect-buffer proc-buffer) + (url-debug + 'retrieval "Redirect in url-retrieve-synchronously: %S -> %S" + proc-buffer redirect-buffer) + (let (kill-buffer-query-functions) + (kill-buffer proc-buffer)) + ;; Accommodate hack in commit 55d1d8b. + (setq proc-buffer redirect-buffer))) + (when-let ((proc (get-buffer-process proc-buffer))) + (when (memq (process-status proc) + '(closed exit signal failed)) + ;; Process sentinel vagaries occasionally cause + ;; url-retrieve to fail calling callback. + (unless data-buffer + (url-debug 'retrieval "Dead process %s" url) + (throw 'done 'exception)))) + ;; Querying over consumer internet in the US takes 100 + ;; ms, so split the difference. + (accept-process-output nil 0.05))) + (unless (eq data-buffer proc-buffer) + (let (kill-buffer-query-functions) + (kill-buffer proc-buffer))))) + data-buffer)) ;; url-mm-callback called from url-mm, which requires mm-decode. (declare-function mm-dissect-buffer "mm-decode" commit b17fd982a3a02e687c965d75b2354c9793c1328f Author: Eli Zaretskii Date: Fri Aug 6 14:20:54 2021 +0300 ; * doc/lispref/package.texi (Package Archives): Fix typo. diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi index 0cbb3aa8bb..9c033fe3df 100644 --- a/doc/lispref/package.texi +++ b/doc/lispref/package.texi @@ -283,12 +283,14 @@ variable @code{load-file-name} (@pxref{Loading}). Here is an example: @section Creating and Maintaining Package Archives @cindex package archive +@cindex GNU ELPA +@cindex non-GNU ELPA Via the Package Menu, users may download packages from @dfn{package archives}. Such archives are specified by the variable -@code{package-archives}, whose default value lists the archives the -archive hosted by the GNU project at @url{https://elpa.gnu.org} and -@url{https://elpa.nongnu.org}. This section describes how to set up -and maintain a package archive. +@code{package-archives}, whose default value lists the archives +hosted on @url{https://elpa.gnu.org, GNU ELPA} and +@url{https://elpa.nongnu.org, non-GNU ELPA}. This section describes +how to set up and maintain a package archive. @cindex base location, package archive @defopt package-archives commit 483fce3093083b94d9c5e545f2b91d188286f90f Author: Lars Ingebrigtsen Date: Fri Aug 6 13:03:28 2021 +0200 Mention NonGNU in "Package Archives" node in the manual * doc/lispref/package.texi (Package Archives): Mention NonGNU, too (bug#49899). diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi index e8aaa3ae1d..0cbb3aa8bb 100644 --- a/doc/lispref/package.texi +++ b/doc/lispref/package.texi @@ -285,9 +285,10 @@ variable @code{load-file-name} (@pxref{Loading}). Here is an example: Via the Package Menu, users may download packages from @dfn{package archives}. Such archives are specified by the variable -@code{package-archives}, whose default value contains a single entry: -the archive hosted by the GNU project at @url{https://elpa.gnu.org}. This -section describes how to set up and maintain a package archive. +@code{package-archives}, whose default value lists the archives the +archive hosted by the GNU project at @url{https://elpa.gnu.org} and +@url{https://elpa.nongnu.org}. This section describes how to set up +and maintain a package archive. @cindex base location, package archive @defopt package-archives commit b77f6af24e9193a4f70622cda6d641c58e885c22 (refs/remotes/origin/emacs-27) Author: Olivier Certner Date: Tue Jul 6 12:35:43 2021 +0200 ERC right stamps: also use latest buffer's window's width (Bug#44140) * lisp/erc/erc-stamp.el (erc-insert-timestamp-right): Use latest buffer's window's width to position the timestamp, if both `erc-timestamp-right-column' and `erc-fill-column' are not set (or `erc-fill-mode' is off). This is what the documentation says, but was not implemented. Also fix the bug of using selected window's width instead of the (or some) window showing the buffer. The latest window's width is saved in `erc-timestamp-last-window-width' and used when the buffer is no more shown. In case the buffer was never shown, which I'm not sure can happen, either use `fill-column' if set, or give up on aligning and just output the timestamp (modulo the kludge) right after message text. While here, fix the off by one calculation of point start when the reference is the window's width. diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el index 0714800246..b9adce6585 100644 --- a/lisp/erc/erc-stamp.el +++ b/lisp/erc/erc-stamp.el @@ -192,6 +192,11 @@ or `erc-send-modify-hook'." (list (lambda (_window _before dir) (erc-echo-timestamp dir ct)))))))) +(defvar-local erc-timestamp-last-window-width nil + "Stores the width of the last window that showed the current +buffer. This is used by `erc-insert-timestamp-right' when the +current buffer is not shown in any window.") + (defvar erc-timestamp-last-inserted nil "Last timestamp inserted into the buffer.") (make-variable-buffer-local 'erc-timestamp-last-inserted) @@ -267,27 +272,32 @@ property to get to the POSth column." (defun erc-insert-timestamp-right (string) "Insert timestamp on the right side of the screen. -STRING is the timestamp to insert. The function is a possible value -for `erc-insert-timestamp-function'. - -If `erc-timestamp-only-if-changed-flag' is nil, a timestamp is always -printed. If this variable is non-nil, a timestamp is only printed if -it is different from the last. - -If `erc-timestamp-right-column' is set, its value will be used as the -column at which the timestamp is to be printed. If it is nil, and -`erc-fill-mode' is active, then the timestamp will be printed just -before `erc-fill-column'. Otherwise, if the current buffer is -shown in a window, that window's width is used. If the buffer is -not shown, and `fill-column' is set, then the timestamp will be -printed just `fill-column'. As a last resort, the timestamp will -be printed just before the window-width." +STRING is the timestamp to insert. This function is a possible +value for `erc-insert-timestamp-function'. + +If `erc-timestamp-only-if-changed-flag' is nil, a timestamp is +always printed. If this variable is non-nil, a timestamp is only +printed if it is different from the last. + +If `erc-timestamp-right-column' is set, its value will be used as +the column at which the timestamp is to be printed. If it is +nil, and `erc-fill-mode' is active, then the timestamp will be +printed just before `erc-fill-column'. Otherwise, if the current +buffer is shown in a window, that window's width is used as the +right boundary. In case multiple windows show the buffer, the +width of the most recently selected one is used. If the buffer +is not shown, the timestamp will be printed just before the +window width of the last window that showed it. If the buffer +was never shown, and `fill-column' is set, it will be printed +just before `fill-column'. As a last resort, timestamp will be +printed just after each line's text (no alignment)." (unless (and erc-timestamp-only-if-changed-flag (string-equal string erc-timestamp-last-inserted)) (setq erc-timestamp-last-inserted string) (goto-char (point-max)) - (forward-char -1);; before the last newline + (forward-char -1) ; before the last newline (let* ((str-width (string-width string)) + window ; used in computation of `pos' only (pos (cond (erc-timestamp-right-column erc-timestamp-right-column) ((and (boundp 'erc-fill-mode) @@ -295,10 +305,15 @@ be printed just before the window-width." (boundp 'erc-fill-column) erc-fill-column) (1+ (- erc-fill-column str-width))) + ((setq window (get-buffer-window nil t)) + (setq erc-timestamp-last-window-width + (window-width window)) + (- erc-timestamp-last-window-width str-width)) + (erc-timestamp-last-window-width + (- erc-timestamp-last-window-width str-width)) (fill-column (1+ (- fill-column str-width))) - (t - (- (window-width) str-width 1)))) + (t (current-column)))) (from (point)) (col (current-column))) ;; The following is a kludge used to calculate whether to move