From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#39546: 28.0.50; Do not require subr-x at run time Date: Mon, 10 Feb 2020 22:00:21 +0100 Message-ID: <87a75qyx7e.fsf@gmail.com> References: <87k14uwnjl.fsf@gmail.com> <831rr2cvci.fsf@gnu.org> <83r1z2bau6.fsf@gnu.org> <57dc180c-4b60-462c-88c2-9a6f97c191df@beta.fastmail.com> <87ftfiyye1.fsf@gmail.com> <87d0amyxpt.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="6545"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39546@debbugs.gnu.org, michael.albinus@gmx.de, larsi@gnus.org To: "Tassilo Horn" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 10 22:01:24 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j1GBH-0001bR-T6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 22:01:23 +0100 Original-Received: from localhost ([::1]:38648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1GBG-0007M2-Oc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 16:01:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59216) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1GAy-0007Jj-He for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 16:01:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1GAw-00063g-CA for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 16:01:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j1GAw-000630-84 for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 16:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j1GAw-0003vH-6Y for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 16:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Feb 2020 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39546 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39546-submit@debbugs.gnu.org id=B39546.158136843215030 (code B ref 39546); Mon, 10 Feb 2020 21:01:02 +0000 Original-Received: (at 39546) by debbugs.gnu.org; 10 Feb 2020 21:00:32 +0000 Original-Received: from localhost ([127.0.0.1]:55532 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1GAR-0003uL-Kw for submit@debbugs.gnu.org; Mon, 10 Feb 2020 16:00:32 -0500 Original-Received: from mail-wm1-f68.google.com ([209.85.128.68]:52644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1GAP-0003u6-H9 for 39546@debbugs.gnu.org; Mon, 10 Feb 2020 16:00:30 -0500 Original-Received: by mail-wm1-f68.google.com with SMTP id p9so799170wmc.2 for <39546@debbugs.gnu.org>; Mon, 10 Feb 2020 13:00:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=B8/pre19JLue+Ec23GOr26kiB1dq4GRWabQtkGUY4uU=; b=X808d/Ma/qnXPU1cqdTTRuaQG/9e2CPb/FOFWHVXsxqSy+h0LHEEQ+VwDBee+1mi9K M2bsUWTRy/u2+Es0Q5Vo8WFKW3Rb8EmZB3znRD98iX30OP8MdsP/IKNrj9gD9p8XJUuS oR5PHFBCidVvRZ87gDhRaWwD+qWPEdPPaSfmxYyob29mG3TipZfGgxgjZyJcuOumT+H3 vb5HRNKxBqz0xgMTBo/U5Sh1Gjsa8c3TQQciOy3QPzbHC4hmeo3TBCBLkd9goEybRwtV kpO0QbS2HUi3lrMCd4x8pa9lO308OI77RI9Dg/6k1E+cayVPavHCrEMHs7iiWiNWFu9W JUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=B8/pre19JLue+Ec23GOr26kiB1dq4GRWabQtkGUY4uU=; b=khXPKgMOUihlUGnrUD+ulPY/5QMQkc1SBYoUquMs5giPhvM0Mfr1g3Eb/RizxsGzdQ JTGqv2jhbg3HSD5F7PqLER+AiGr3qfED4mohneZhxpvibM+i8MstLhoO3GxMwNbEMT+f KZZ6cKpCABSZH7mQAGtJxPpNEXL/MWiBQrQP8NW2XZHtpPJswc5a+5RBHh3PN3iW52pQ LUcLiId8jM1en92fy6hn/ujIkc4R406wosiVe2pJQfQ529fMf1EPSIHaFnVQvDJrFguE aKdswpeVoMdpRnmsnBCmqkpcbYa6sf+8FzQhCwsQZyWTzBbf31U8aaenu1eO793nbZ1B bcgg== X-Gm-Message-State: APjAAAVgG1cQJtQrCZ3mDBgQ/7OKeggrz3pIhH6IE6gbgrgSoOMn/2S7 aaUJsY++s5USeAPNQUOQwMU= X-Google-Smtp-Source: APXvYqyGorOOyBrUZPCC8O5eeADmR+dZEkPrxfMj4ju3JxlLHGEzHjAWK1dQ8SNgoxnYksepkgXlOw== X-Received: by 2002:a7b:cf39:: with SMTP id m25mr858657wmg.146.1581368423518; Mon, 10 Feb 2020 13:00:23 -0800 (PST) Original-Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id w19sm664344wmc.22.2020.02.10.13.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 13:00:23 -0800 (PST) In-Reply-To: <87d0amyxpt.fsf@gmail.com> (Tino Calancha's message of "Mon, 10 Feb 2020 21:49:18 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175908 Archived-At: Tino Calancha writes: >> I have run the testsuite without surprises. > Well, actually there was a surprise, but who don't like surprises after > all! Well, I must recognize I am one of those guys who doesn't like surprises. It seems `when-let' became very popular these days. Here is the updated patch. It takes in account all usages of `when-let' once dropped the cookie. --8<-----------------------------cut here---------------start------------->8--- commit 0c8d7c5312ce167d6123a768c6fe00a2b07288b4 Author: Constantino Calancha Date: Mon Feb 10 21:56:53 2020 +0100 Do not require subr-x at run time Move back `replace-region-contents' to subr.el according with the convention for subr-x (Bug#39546). * lisp/subr-x.el (replace-region-contents): Delete it. (when-let): Delete autoload cookie. * calendar/time-date.el * net/net-utils.el * net/nsm.el * lisp/dired-x.el * lisp/emacs-lisp/edebug.el * lisp/gnus/gnus-sum.el * lisp/gnus/mml.el * lisp/image/image-converter.el * lisp/mail/emacsbug.el * lisp/image/exif.el * net/tramp-compat.el * lisp/net/mailcap.el * lisp/net/tramp-adb.el * lisp/net/tramp-cmds.el * lisp/net/tramp-gvfs.el * lisp/net/tramp-rclone.el * lisp/net/tramp-sh.el * lisp/net/tramp-smb.el * lisp/net/tramp-sudoedit.el * lisp/net/tramp.el: Require subr-x at compile time. * lisp/replace.el (replace-region-contents): Move it from subr-x.el. * lisp/emacs-lisp/json.el: Do not require subr-x since now `replace-region-contents' is loaded at start up. diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index e2402de801..b4b13037bf 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -37,7 +37,7 @@ ;;; Code: (require 'cl-lib) -(require 'subr-x) +(eval-when-compile (require 'subr-x)) (defmacro with-decoded-time-value (varlist &rest body) "Decode a time value and bind it according to VARLIST, then eval BODY. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 623a1dd325..73029a0095 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -43,6 +43,7 @@ ;; This is a no-op if dired-x is being loaded via `dired-load-hook', ;; but maybe not if a dired-x function is being autoloaded. (require 'dired) +(eval-when-compile (require 'subr-x)) ;;; User-defined variables. diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 85cc8c8e7a..5a5a79488f 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -55,7 +55,9 @@ (require 'backtrace) (require 'macroexp) (require 'cl-lib) -(eval-when-compile (require 'pcase)) +(eval-when-compile + (require 'pcase) + (require 'subr-x) ;;; Options diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 044c9aada0..2c1415ab2a 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -182,7 +182,6 @@ if-let (setq spec (list spec))) (list 'if-let* spec then (macroexp-progn else))) -;;;###autoload (defmacro when-let (spec &rest body) "Bind variables according to SPEC and conditionally evaluate BODY. Evaluate each binding in turn, stopping if a binding value is nil. @@ -254,34 +253,6 @@ string-remove-suffix (substring string 0 (- (length string) (length suffix))) string)) -(defun replace-region-contents (beg end replace-fn - &optional max-secs max-costs) - "Replace the region between BEG and END using REPLACE-FN. -REPLACE-FN runs on the current buffer narrowed to the region. It -should return either a string or a buffer replacing the region. - -The replacement is performed using `replace-buffer-contents' -which also describes the MAX-SECS and MAX-COSTS arguments and the -return value. - -Note: If the replacement is a string, it'll be placed in a -temporary buffer so that `replace-buffer-contents' can operate on -it. Therefore, if you already have the replacement in a buffer, -it makes no sense to convert it to a string using -`buffer-substring' or similar." - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (let ((repl (funcall replace-fn))) - (if (bufferp repl) - (replace-buffer-contents repl max-secs max-costs) - (let ((source-buffer (current-buffer))) - (with-temp-buffer - (insert repl) - (let ((tmp-buffer (current-buffer))) - (set-buffer source-buffer) - (replace-buffer-contents tmp-buffer max-secs max-costs))))))))) (provide 'subr-x) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index a47e657623..bd865ca9b0 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -25,6 +25,7 @@ ;;; Code: (require 'cl-lib) +(eval-when-compile (require 'subr-x)) (defvar tool-bar-mode) (defvar gnus-category-predicate-alist) diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el index cdd8f3d3a5..903c3ff7ec 100644 --- a/lisp/gnus/mml.el +++ b/lisp/gnus/mml.el @@ -27,9 +27,11 @@ (require 'mm-encode) (require 'mm-decode) (require 'mml-sec) -(eval-when-compile (require 'cl-lib)) -(eval-when-compile (require 'url)) -(eval-when-compile (require 'gnus-util)) +(eval-when-compile + (require 'cl-lib) + (require 'url) + (require 'gnus-util) + (require 'subr-x)) (autoload 'message-make-message-id "message") (declare-function gnus-setup-posting-charset "gnus-msg" (group)) diff --git a/lisp/image/exif.el b/lisp/image/exif.el index 642bc58321..27ad616146 100644 --- a/lisp/image/exif.el +++ b/lisp/image/exif.el @@ -62,6 +62,7 @@ ;;; Code: (require 'cl-lib) +(eval-when-compile (require 'subr-x)) (defvar exif-tag-alist '((11 processing-software) diff --git a/lisp/image/image-converter.el b/lisp/image/image-converter.el index 0488a13d41..33a8903e94 100644 --- a/lisp/image/image-converter.el +++ b/lisp/image/image-converter.el @@ -27,7 +27,9 @@ ;;; Code: (require 'cl-generic) -(eval-when-compile (require 'cl-lib)) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) (defcustom image-converter nil "Type of the external image converter to use. diff --git a/lisp/json.el b/lisp/json.el index 18d7fda882..e31928e825 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -55,7 +55,6 @@ ;;; Code: (require 'map) -(require 'subr-x) ;; Parameters diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el index 7f3dc4454a..3aea5aae8a 100644 --- a/lisp/mail/emacsbug.el +++ b/lisp/mail/emacsbug.el @@ -34,6 +34,7 @@ (require 'sendmail) (require 'message) +(eval-when-compile (require 'subr-x)) (defgroup emacsbug nil "Sending Emacs bug reports." diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 5fe5b4d3a5..75c91946e4 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -29,6 +29,7 @@ ;;; Code: +(eval-when-compile (require 'subr-x)) (autoload 'mail-header-parse-content-type "mail-parse") (defgroup mailcap nil diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index ef3651b033..780f34b028 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -44,7 +44,7 @@ ;; days is for /sbin to be a symlink to /usr/sbin, but we still need to ;; search both for older systems. -(require 'subr-x) +(eval-when-compile (require 'subr-x)) (require 'cl-lib) (defun net-utils--executable-find-sbin (command) diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el index 2d36c5e257..f85529f726 100644 --- a/lisp/net/nsm.el +++ b/lisp/net/nsm.el @@ -26,7 +26,7 @@ (require 'cl-lib) (require 'rmc) ; read-multiple-choice -(require 'subr-x) +(eval-when-compile (require 'subr-x)) (require 'seq) (require 'map) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index aa7fe147c2..60c46f1224 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -33,6 +33,7 @@ ;;; Code: +(eval-when-compile (require 'subr-x)) (require 'tramp) ;;;###tramp-autoload diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index b4dca2321c..871c215e87 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -29,6 +29,7 @@ ;;; Code: (require 'tramp) +(eval-when-compile (require 'subr-x)) ;; Pacify byte-compiler. (declare-function mml-mode "mml") diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 87bcd08b85..8f74683dee 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -39,7 +39,7 @@ tramp-unload-file-name-handlers (require 'ls-lisp) ;; Due to `tramp-handle-insert-directory'. (require 'parse-time) (require 'shell) -(require 'subr-x) +(eval-when-compile (require 'subr-x)) ;; `temporary-file-directory' as function is introduced with Emacs 26.1. (declare-function tramp-handle-temporary-file-directory "tramp") diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 0d800cb42b..5b037fb94b 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -102,6 +102,7 @@ (declare-function dbus-get-unique-name "dbusbind.c") (eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'subr-x)) (require 'tramp) (require 'dbus) (require 'url-parse) diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index 445098a5bc..b7c99829ed 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el @@ -36,6 +36,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'subr-x)) (require 'tramp) ;;;###tramp-autoload diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 5a3abc31ea..0c5bc72deb 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -32,6 +32,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'subr-x)) (require 'tramp) (declare-function dired-remove-file "dired-aux") diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index f02be394a7..43e775b921 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -28,6 +28,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'subr-x)) (require 'tramp) ;; Define SMB method ... diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index f258ad6b93..6ea52bedf8 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -34,6 +34,7 @@ ;;; Code: +(eval-when-compile (require 'subr-x)) (require 'tramp) ;;;###tramp-autoload diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 19d36c3a97..0783eda09e 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -60,6 +60,7 @@ (require 'tramp-compat) (require 'tramp-integration) (require 'trampver) +(eval-when-compile (require 'subr-x)) ;; Pacify byte-compiler. (require 'cl-lib) diff --git a/lisp/replace.el b/lisp/replace.el index a0b050637e..74c54a0b80 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -743,6 +743,35 @@ replace-regexp (if (use-region-p) (region-noncontiguous-p))))) (perform-replace regexp to-string nil t delimited nil nil start end backward region-noncontiguous-p)) +(defun replace-region-contents (beg end replace-fn + &optional max-secs max-costs) + "Replace the region between BEG and END using REPLACE-FN. +REPLACE-FN runs on the current buffer narrowed to the region. It +should return either a string or a buffer replacing the region. + +The replacement is performed using `replace-buffer-contents' +which also describes the MAX-SECS and MAX-COSTS arguments and the +return value. + +Note: If the replacement is a string, it'll be placed in a +temporary buffer so that `replace-buffer-contents' can operate on +it. Therefore, if you already have the replacement in a buffer, +it makes no sense to convert it to a string using +`buffer-substring' or similar." + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (let ((repl (funcall replace-fn))) + (if (bufferp repl) + (replace-buffer-contents repl max-secs max-costs) + (let ((source-buffer (current-buffer))) + (with-temp-buffer + (insert repl) + (let ((tmp-buffer (current-buffer))) + (set-buffer source-buffer) + (replace-buffer-contents tmp-buffer max-secs max-costs))))))))) + (defvar regexp-history nil "History list for some commands that read regular expressions. --8<-----------------------------cut here---------------end--------------->8---