From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#43652: [PATCH] cperl-mode: Add helpers to run on Emacs 26.1 Date: Sun, 27 Sep 2020 18:45:10 +0200 Message-ID: <87mu1bqicp.fsf@hajtower> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28285"; mail-complaints-to="usenet@ciao.gmane.io" To: 43652@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 27 18:47:46 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 1kMZpy-0007Gc-CC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Sep 2020 18:47:46 +0200 Original-Received: from localhost ([::1]:49620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMZpx-0006xM-En for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Sep 2020 12:47:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMZoI-00062g-1l for bug-gnu-emacs@gnu.org; Sun, 27 Sep 2020 12:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kMZoH-0006OU-Og for bug-gnu-emacs@gnu.org; Sun, 27 Sep 2020 12:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kMZoH-0006gy-Na for bug-gnu-emacs@gnu.org; Sun, 27 Sep 2020 12:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 16:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43652 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160122512625680 (code B ref -1); Sun, 27 Sep 2020 16:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Sep 2020 16:45:26 +0000 Original-Received: from localhost ([127.0.0.1]:50312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZni-0006g8-Gi for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:45:26 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZnh-0006g0-2M for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:45:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMZnd-0005sB-By for bug-gnu-emacs@gnu.org; Sun, 27 Sep 2020 12:45:24 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:33339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMZnY-0006BC-22 for bug-gnu-emacs@gnu.org; Sun, 27 Sep 2020 12:45:19 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 44B702400FB for ; Sun, 27 Sep 2020 18:45:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1601225112; bh=JIHNO6fladakJJ8v2N/+JmARya53pb1zJSCkeVBySsI=; h=From:To:Subject:Date:From; b=iAeSw/V2kc/E2pmF0tZXKyejsXPZtVhMVErrbonSf99FnecPNEAKT1mjRac3gSsIO 7p6jhx3vi8XMjMQoNpnHjDg+DSTuZQQg4W8FI0zicQ7yZFjsn1Bx/jhXg93aZZzExN B4Ut7t7dLWax5/nt0WZD/faSgQp/ZiwThhakUMECjqu3CB76njGf69sz78P37dvWkX hN9YkDbeiY80H13alhVPNQGz3LpgVzqEnAjAkVno6AULLohL+qyhxzYOy2kucq79VM mh9wgXUPuak4XdylFwCiJvbIOh34WZv/5wJXhxa/uDNa/siyCE0vMhfDgMT7kxKU5Y hqo2Xb/TzRZdQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Bzs2b3sB0z9rxc; Sun, 27 Sep 2020 18:45:11 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.66; envelope-from=haj@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/27 12:42:52 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:189155 Archived-At: --=-=-= Content-Type: text/plain I plan to suggest that cperl-mode.el gets a "dual life" in both Emacs and on ELPA on emacs-devel. As a preparation, I added two helpers for the newer functions 'time-convert' and 'format-patch', following a suggestion by Stefan Monnier. He actually wrote cperl--format-patch in a message to emacs-devel and therefore is listed as co-author in the commit message. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-cperl-mode-Add-compatibility-for-Emacs-26.1.patch Content-Description: Patch: Add cperl-mode compatibility >From a70829396d569656dda5864c4dbece97eddb5167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Sun, 27 Sep 2020 18:32:48 +0200 Subject: [PATCH] cperl-mode: Add compatibility for Emacs 26.1 * lisp/progmodes/cperl-mode.el (cperl--time-convert): New compatibility helper for time-convert (available in Emacs 27.1) (cperl--format-prompt): New compatibility helper for format-prompt (available in Emacs 28) (cperl-info-on-command): use cperl--format-prompt (cperl-perldoc): use cperl--format-prompt (cperl-time-fontification): use cperl--time-convert Co-authored-by: Stefan Monnier --- lisp/progmodes/cperl-mode.el | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 6313d015e9..c62fbab059 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -7,6 +7,7 @@ ;; Jonathan Rockway ;; Maintainer: emacs-devel@gnu.org ;; Keywords: languages, Perl +;; Package-Requires: ((emacs "26.1")) ;; This file is part of GNU Emacs. @@ -75,6 +76,26 @@ ;;; Code: +;;; Compatibility with older versions (for publishing on ELPA) +;; The following helpers allow cperl-mode.el to work with older +;; versions of Emacs. +;; +;; Whenever the minimum version is bumped (see "Package-Requires" +;; above), please eliminate the corresponding compatibility-helpers. +;; Whenever you create a new compatibility-helper, please add it here. + +;; Available in Emacs 27.1: time-convert +(defalias 'cperl--time-convert + (if (fboundp 'time-convert) 'time-convert + 'encode-time)) + +;; Available in Emacs 28: format-prompt +(defalias 'cperl--format-prompt + (if (fboundp 'format-prompt) 'format-prompt + (lambda (msg default) + (if default (format "%s (default %s): " msg default) + (concat msg ": "))))) + (eval-when-compile (require 'cl-lib)) (defvar msb-menu-cond) @@ -6126,7 +6147,7 @@ cperl-info-on-command (interactive (let* ((default (cperl-word-at-point)) (read (read-string - (format-prompt "Find doc for Perl function" default)))) + (cperl--format-prompt "Find doc for Perl function" default)))) (list (if (equal read "") default read)))) @@ -8085,7 +8106,7 @@ cperl-perldoc (interactive (list (let* ((default-entry (cperl-word-at-point)) (input (read-string - (format-prompt "perldoc entry" default-entry)))) + (cperl--format-prompt "perldoc entry" default-entry)))) (if (string= input "") (if (string= default-entry "") (error "No perldoc args given") @@ -8312,7 +8333,7 @@ cperl-time-fontification (or l (setq l 1)) (or step (setq step 500)) (or lim (setq lim 40)) - (let* ((timems (function (lambda () (car (time-convert nil 1000))))) + (let* ((timems (function (lambda () (car (cperl--time-convert nil 1000))))) (tt (funcall timems)) (c 0) delta tot) (goto-char (point-min)) (forward-line (1- l)) -- 2.20.1 --=-=-=--