unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43652: [PATCH] cperl-mode: Add helpers to run on Emacs 26.1
@ 2020-09-27 16:45 Harald Jörg
  2020-09-28 12:13 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Harald Jörg @ 2020-09-27 16:45 UTC (permalink / raw)
  To: 43652

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch: Add cperl-mode compatibility --]
[-- Type: text/x-diff, Size: 3113 bytes --]

From a70829396d569656dda5864c4dbece97eddb5167 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20J=C3=B6rg?= <haj@posteo.de>
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 <monnier@iro.umontreal.ca>
---
 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 <jon@jrock.us>
 ;; 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:
 \f
+;;; 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 ": ")))))
+\f
 (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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#43652: [PATCH] cperl-mode: Add helpers to run on Emacs 26.1
  2020-09-27 16:45 bug#43652: [PATCH] cperl-mode: Add helpers to run on Emacs 26.1 Harald Jörg
@ 2020-09-28 12:13 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-28 12:13 UTC (permalink / raw)
  To: Harald Jörg; +Cc: 43652

haj@posteo.de (Harald Jörg) writes:

> 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.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-28 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27 16:45 bug#43652: [PATCH] cperl-mode: Add helpers to run on Emacs 26.1 Harald Jörg
2020-09-28 12:13 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).