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 21:34:46 +0100 Message-ID: <87ftfiyye1.fsf@gmail.com> References: <87k14uwnjl.fsf@gmail.com> <831rr2cvci.fsf@gnu.org> <83r1z2bau6.fsf@gnu.org> <57dc180c-4b60-462c-88c2-9a6f97c191df@beta.fastmail.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="25110"; 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 21:35:21 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 1j1Fm5-0006N1-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 21:35:21 +0100 Original-Received: from localhost ([::1]:38458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1Fm4-000064-7x for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 15:35:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39886) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1Flp-0008VU-Sz for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 15:35:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1Flm-0001dX-T7 for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 15:35:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j1Flm-0001d9-P8 for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 15:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j1Flm-0003Hm-KZ for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 15:35: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 20:35: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.158136689612616 (code B ref 39546); Mon, 10 Feb 2020 20:35:02 +0000 Original-Received: (at 39546) by debbugs.gnu.org; 10 Feb 2020 20:34:56 +0000 Original-Received: from localhost ([127.0.0.1]:55512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1Flg-0003HP-3e for submit@debbugs.gnu.org; Mon, 10 Feb 2020 15:34:56 -0500 Original-Received: from mail-wr1-f65.google.com ([209.85.221.65]:34307) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1Fle-0003HD-Cq for 39546@debbugs.gnu.org; Mon, 10 Feb 2020 15:34:55 -0500 Original-Received: by mail-wr1-f65.google.com with SMTP id t2so9493845wrr.1 for <39546@debbugs.gnu.org>; Mon, 10 Feb 2020 12:34:54 -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=zKtpXyzVSOVKIov2haQuHTsCgetMI8w5hlA+Fq9S5Fo=; b=KmsCow7zv/AkrYERE5kfmFB7bqOX5haKzcI9lCKokBCNBRqfY+TftJFJrrVwt9mwAp yy33JTk13VQv5PAMykXUuw4vxvDOVDt7nAv2DkLcjXdft+6/B9txx0dtwsCg7zh7yFZi fJFR4vyXpbVUd9wOfobLulKowhGeOodiImv/RKLxXu/sR54EwTpBItiHUtwgVsKPzKhQ +7gvgzxsqDqYJ8jA1knPifAIY/j7fEV+f1aNzreLI3BneonTjNBdghmhuV4gjOpeo1cR W3XinkrFSpZzUQsUyq0bmnBoJIgVymOIPLSidOvrd5p+fqFj37zbI9gbWAU1uSbAFpRJ Rd8g== 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=zKtpXyzVSOVKIov2haQuHTsCgetMI8w5hlA+Fq9S5Fo=; b=Sj3lYdzm0odl8W0JacC2aHfigbw4JhYCuKzp2yU5Y9n8Jbd1htq54R1lRQRb4niYqY hH2mAKv34RkkcTQD1CJ4Vu6QyGUmeeMiVzfipbDRlYqUvrM19HLSqJL+M5eptz/ruHPc m816HYCUuDx9Su7OQbU9FB6rX+RhlvJvl3g+/MZglO1ugSpxAePR9z+J4x0qR8GD17LF w5TtrB8+BDb7lL/IHcMc6Ziqe3YMpyFYOWnwFd8TEpt3mZbFHE6l5mWEf/v/BOD3yTT0 2ckj1kIZxzB6ubuBXjBCvI+SzDsRuOOeHv02WqbDz0TqL3ThljpvFb7r6pdollIllhh0 B+DQ== X-Gm-Message-State: APjAAAXiz44nAqcS4IFeNRCZfCqXamUCgnzPa9D/L/7F8wMZobQWboZ1 kBk45Bmd53kblEI4l75MaBs= X-Google-Smtp-Source: APXvYqyisDkGQj6+21EA7DKXqjP9KJ27mT/bHE+EsuCcosVHbBemN+h1pf7pFHou/bnqUJ2dRajAaQ== X-Received: by 2002:adf:e542:: with SMTP id z2mr3765453wrm.346.1581366888304; Mon, 10 Feb 2020 12:34:48 -0800 (PST) Original-Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id z25sm652621wmf.14.2020.02.10.12.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 12:34:47 -0800 (PST) In-Reply-To: <57dc180c-4b60-462c-88c2-9a6f97c191df@beta.fastmail.com> (Tassilo Horn's message of "Mon, 10 Feb 2020 20:54:45 +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:175903 Archived-At: "Tassilo Horn" writes: > Am Mo, 10. Feb 2020, um 20:30, schrieb Tino Calancha: >> replace.el is a good agreement between subr-x.el (it's a defun, so >> it doesn't fit well there) and subr.el. >> >> As subr.el, replace.el is also loaded at start time, but it's ~ half size, >> and more important than that, it's all about replacing in Emacs. > > Sounds good to me! Here is the updated patch: - It deletes the cookie from subr-x (yes, we have one for when-let) - Move replace-region-contents inside replace.el (loaded at startup) - Add all required (eval-when...(req.. 'subr-x)) at tramp files - Replaced loading subr-x at run time with compile time for some other files I have run the testsuite without surprises. --8<-----------------------------cut here---------------start------------->8--- commit f6a7a4fc673f77724ccf0d7ae1fdb164328afc68 Author: Constantino Calancha Date: Mon Feb 10 21:19:29 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 * 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/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/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/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---