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 14:59:42 +0100 Message-ID: <87k14uwnjl.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="12094"; mail-complaints-to="usenet@ciao.gmane.io" Cc: lars magne ingebrigtsen , michael albinus , tassilo horn To: 39546@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 10 15:01:37 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 1j19d3-00033N-7v for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 15:01:37 +0100 Original-Received: from localhost ([::1]:34114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j19d2-00040I-Ar for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Feb 2020 09:01:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52613) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j19cp-000405-Q5 for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 09:01:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j19co-0006zd-7e for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 09:01:23 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j19cU-0006q3-F9; Mon, 10 Feb 2020 09:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j19cU-00068P-C2; Mon, 10 Feb 2020 09:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: tsdh@gnu.org, michael.albinus@gmx.de, larsi@gnus.org, bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Feb 2020 14:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39546 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: tassilo horn , michael albinus , lars magne ingebrigtsen Original-Received: via spool by submit@debbugs.gnu.org id=B.158134322123526 (code B ref -1); Mon, 10 Feb 2020 14:01:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Feb 2020 14:00:21 +0000 Original-Received: from localhost ([127.0.0.1]:53839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j19bm-00067K-Cp for submit@debbugs.gnu.org; Mon, 10 Feb 2020 09:00:21 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j19bk-00067D-Tn for submit@debbugs.gnu.org; Mon, 10 Feb 2020 09:00:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52483) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j19bi-0003UO-7q for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 09:00:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j19bc-0006Vd-HJ for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 09:00:14 -0500 Original-Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j19bc-0006VE-8I for bug-gnu-emacs@gnu.org; Mon, 10 Feb 2020 09:00:08 -0500 Original-Received: by mail-wr1-x442.google.com with SMTP id g3so6772779wrs.12 for ; Mon, 10 Feb 2020 06:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=JOfwG/bp3fRO6jNvIU3DJ95y+mqO11SpYtF/waTyJ1A=; b=OefKnmYQ5XcEX6YPjSRATFIWSgIjSrr+8uMVWtnGjDoxVc+PCwMKNsH0op9sqLDOBa UJz6mWJv0yNJpvINWxRvUYJdYtpOAc7LBYBzrG6W+G+11vLtC4cvSosI8gQVI2YrfP/q uyIRUEd1FRNKgfVXMKaQjlvoSrMKlk1NENVGs5H8yZZmv5v87dCdw2t7AYZO0uyLZhpD Kz+4LtZXH2rfF36xKAmqjsZxBH0Zr3flGy70pnPNGIOj0NLfDU6UcPEijQiYzibjO+8e Yrapj3h06nfN3C3o+tkVlk3llgdjYJc6Ei4JSmAMv8R5iCsv6I6O8AewqvEAMAS55ghU kgaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=JOfwG/bp3fRO6jNvIU3DJ95y+mqO11SpYtF/waTyJ1A=; b=gos2my5Ign5oP0Y3Uw4PHEwk28iAxBfPqNwrLykHsxGR5VN6+jR2be8StCT/mSZWOe 9locfezsuk0SvvYWfLN0vGhawUQORYdTjfdqEYdiNcPvbh6vfKbKzvvhngj5rbhp/oGj /RoWkwiR4aGCPO7qiEKxqdYEVJkSYIB8sHRYIYFcn46y/ubLSbB4ev5ZHlGzC4e2BDoI DILyNzb+dEOzB2Zx0FEV5nrf7dUTAIFe0RLxwH3wjK1fP2/bFtgv3SIcyNGoyqU1BZVk kt6nA9NEnBqy+rQ3o8cEMdMPo+7aqMRfY6uIfyrIOVvxs87RXwUAj//rQzdpdRh90auv mtkw== X-Gm-Message-State: APjAAAWcJsDzjcEl3TxI6Yt15VhmakG0O5lF1EU6qiXcry9q018utC1r 2WbM7toihc57qkPfNkoNmtBzBDuCO5s= X-Google-Smtp-Source: APXvYqywrwd50jgjJAGwTlV11pFUL8WW/hlTQHyYU62BTTDWAx4icIr808pSr6NqSnLLY/WjVs10YQ== X-Received: by 2002:adf:f3cd:: with SMTP id g13mr2256531wrp.54.1581343206378; Mon, 10 Feb 2020 06:00:06 -0800 (PST) Original-Received: from localhost.example.com (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id e18sm674673wrw.70.2020.02.10.06.00.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 06:00:05 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:175867 Archived-At: X-Debbugs-Cc: Tassilo Horn ,Michael Albinus ,Lars Magne Ingebrigtsen Severity: wishlist tags: patch This patch replaces (require subr-x) with (eval-when-compile (require 'subr-x)) on several files using just defsubst/defmacro from subr-x.el. In addition, it moves back replace-region-contents into subr.el: been a defun, and documented in the manual, then it fits better inside subr.el. --8<-----------------------------cut here---------------start------------->8--- commit 87abdb434ad892256c4a432eb86ac5628d253891 Author: Constantino Calancha Date: Mon Feb 10 14:19:10 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. * calendar/time-date.el * net/net-utils.el * net/nsm.el * net/tramp-compat.el: Require subr-x at compile time. * lisp/subr.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..883607a549 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -254,34 +254,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/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-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/subr.el b/lisp/subr.el index b5ec0de156..406cc50611 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5768,6 +5768,35 @@ flatten-tree ;; for discoverability: (defalias 'flatten-list 'flatten-tree) +(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))))))))) + ;; The initial anchoring is for better performance in searching matches. (defconst regexp-unmatchable "\\`a\\`" "Standard regexp guaranteed not to match any string at all.") --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2020-02-10 built on localhost.example.com Repository revision: ac9acc1864b02b92de4eb2e98db7b5b0cd03e019 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12007000 System Description: openSUSE Tumbleweed