Gentoo Archives: gentoo-commits

From: Matthew Smith <matthew@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/erlang/, dev-lang/erlang/files/
Date: Thu, 05 May 2022 14:35:24
Message-Id: 1651761293.23330408d7ae93d2fe67c2e7c33cdca4fe613351.matthew@gentoo
1 commit: 23330408d7ae93d2fe67c2e7c33cdca4fe613351
2 Author: Matthew Smith <matthew <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 5 14:32:15 2022 +0000
4 Commit: Matthew Smith <matthew <AT> gentoo <DOT> org>
5 CommitDate: Thu May 5 14:34:53 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23330408
7
8 dev-lang/erlang: backport emacs-28 compatibility patch
9
10 Signed-off-by: Matthew Smith <matthew <AT> gentoo.org>
11
12 ...23.3.4.14.ebuild => erlang-23.3.4.14-r1.ebuild} | 1 +
13 .../files/erlang-23.3.4.14-emacs28-compat.patch | 137 +++++++++++++++++++++
14 2 files changed, 138 insertions(+)
15
16 diff --git a/dev-lang/erlang/erlang-23.3.4.14.ebuild b/dev-lang/erlang/erlang-23.3.4.14-r1.ebuild
17 similarity index 98%
18 rename from dev-lang/erlang/erlang-23.3.4.14.ebuild
19 rename to dev-lang/erlang/erlang-23.3.4.14-r1.ebuild
20 index 689ece693ee0..4ec3b42e084e 100644
21 --- a/dev-lang/erlang/erlang-23.3.4.14.ebuild
22 +++ b/dev-lang/erlang/erlang-23.3.4.14-r1.ebuild
23 @@ -47,6 +47,7 @@ S="${WORKDIR}/otp-OTP-${PV}"
24 PATCHES=(
25 "${FILESDIR}"/18.2.1-wx3.0.patch
26 "${FILESDIR}"/${PN}-22.0-dont-ignore-LDFLAGS.patch
27 + "${FILESDIR}"/${PN}-23.3.4.14-emacs28-compat.patch
28 )
29
30 SITEFILE=50"${PN}"-gentoo.el
31
32 diff --git a/dev-lang/erlang/files/erlang-23.3.4.14-emacs28-compat.patch b/dev-lang/erlang/files/erlang-23.3.4.14-emacs28-compat.patch
33 new file mode 100644
34 index 000000000000..32844d8dd1a8
35 --- /dev/null
36 +++ b/dev-lang/erlang/files/erlang-23.3.4.14-emacs28-compat.patch
37 @@ -0,0 +1,137 @@
38 +From 22a7522ef3f0f3c13618214e61f60cb01d80eef4 Mon Sep 17 00:00:00 2001
39 +From: Justin Davis <jrcd83@×××××.com>
40 +Date: Tue, 26 Oct 2021 13:28:16 -0400
41 +Subject: [PATCH] Fix emacs erlang-mode: xref switched to CL-Lib
42 +
43 +Fix for GitHub issue #5314.
44 +
45 +Xref is a package which is also bundled with emacs:
46 +http://elpa.gnu.org/packages/xref.html
47 +
48 +Xref switched its own internally defined classes from EIEIO to
49 +CL-lib (emacs-mirror/emacs@86da812afb2572c7fead2bb07570b976bffd7c55).
50 +erlang-mode subclasses xref-file-location in order to add a function
51 +arity slot to xrefs.
52 +
53 +If xref-file-location is a class, use defclass to subclass it. Otherwise
54 +use cl-defstruct. Avoids referencing make-instance, slot-value functions
55 +from EIEIO. Only references constructor, accessor, and predicate
56 +functions. Updates comments that make references to classes.
57 +
58 +Testing:
59 +- cd into lib/tools/emacs.
60 +- Run the tests included with erlang-mode from the shell:
61 + emacs -Q -batch -L . -l erlang.el -l erlang-test.el \
62 + -f ert-run-tests-batch-and-exit
63 +- Copy xref.el from the xref package (>=1.3.1) into the
64 + lib/tools/emacs directory.
65 +- Run the tests again. This will load xref.el automatically
66 + and use the new interface.
67 +---
68 + lib/tools/emacs/erlang.el | 48 +++++++++++++++++++++++++--------------
69 + 1 file changed, 31 insertions(+), 17 deletions(-)
70 +
71 +diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
72 +index 69a5fdaeb55..40fe32689e7 100644
73 +--- a/lib/tools/emacs/erlang.el
74 ++++ b/lib/tools/emacs/erlang.el
75 +@@ -5120,8 +5120,8 @@ about Erlang modules."
76 + ;;
77 + ;; As mentioned this xref implementation is based on the etags xref
78 + ;; implementation. But in the cases where arity is considered the
79 +-;; etags information structures (class xref-etags-location) will be
80 +-;; translated to our own structures which include arity (class
81 ++;; etags information structures (struct xref-etags-location) will be
82 ++;; translated to our own structures which include arity (struct
83 + ;; erlang-xref-location). This translation is started in the function
84 + ;; `erlang-refine-xrefs'.
85 +
86 +@@ -5129,6 +5129,11 @@ about Erlang modules."
87 + ;; with xref items with xref-etags-location and some deal with xref
88 + ;; items with erlang-xref-location.
89 +
90 ++;; NOTE: Around Sept 2021, the xrefs package changed all of its defined types
91 ++;; (i.e. xref-location, xref-file-location) from EIEIO classes to CL-Lib
92 ++;; structures. These are both supported. Older Emacsen with earlier versions of
93 ++;; xref will continue to use defclass. Newer Emacsen will use cl-defstruct.
94 ++
95 + (defun erlang-etags--xref-backend () 'erlang-etags)
96 +
97 + (defun erlang-soft-require (feature)
98 +@@ -5137,6 +5142,7 @@ about Erlang modules."
99 +
100 + (when (and (erlang-soft-require 'xref)
101 + (erlang-soft-require 'cl-generic)
102 ++ (erlang-soft-require 'cl-lib)
103 + (erlang-soft-require 'eieio)
104 + (erlang-soft-require 'etags))
105 + ;; The purpose of using eval here is to avoid compilation
106 +@@ -5165,10 +5171,20 @@ about Erlang modules."
107 + (let ((erlang-replace-etags-tags-completion-table t))
108 + (tags-completion-table)))
109 +
110 +- (defclass erlang-xref-location (xref-file-location)
111 +- ((arity :type fixnum :initarg :arity
112 +- :reader erlang-xref-location-arity))
113 +- :documentation "An erlang location is a file location plus arity.")
114 ++ ;; Xref 1.3.1 bundled with Emacs 28+ switched from using EIEIO classes to
115 ++ ;; using CL-Lib structs.
116 ++ (if (find-class 'xref-file-location)
117 ++ (progn
118 ++ (defclass erlang-xref-location (xref-file-location)
119 ++ ((arity :type fixnum :initarg :arity
120 ++ :reader erlang-xref-location-arity))
121 ++ :documentation "An erlang location is a file location plus arity.")
122 ++ ;; Make a constructor with the same name that a CL structure would have.
123 ++ (defalias 'make-erlang-xref-location 'erlang-xref-location))
124 ++ (cl-defstruct (erlang-xref-location
125 ++ (:include xref-file-location))
126 ++ "An erlang location is a file location plus arity."
127 ++ (arity 0 :type fixnum)))
128 +
129 + ;; This method definition only calls the superclass which is
130 + ;; the default behaviour if it was not defined. It is only
131 +@@ -5331,8 +5347,7 @@ is non-nil then TAG is a regexp."
132 + xrefs
133 + (when (and xrefs
134 + (fboundp 'xref-item-location)
135 +- (fboundp 'xref-location-group)
136 +- (fboundp 'slot-value))
137 ++ (fboundp 'xref-location-group))
138 + (let (files)
139 + (cl-loop for xref in xrefs
140 + for loc = (xref-item-location xref)
141 +@@ -5357,7 +5372,8 @@ is non-nil then TAG is a regexp."
142 + t))))
143 +
144 + (defun erlang-xrefs-in-file (file kind tag is-regexp)
145 +- (when (fboundp 'make-instance)
146 ++ (when (and (fboundp 'make-erlang-xref-location)
147 ++ (fboundp 'xref-make))
148 + (with-current-buffer (find-file-noselect file)
149 + (save-excursion
150 + (goto-char (point-min))
151 +@@ -5369,17 +5385,15 @@ is non-nil then TAG is a regexp."
152 + for name = (match-string-no-properties 1)
153 + for arity = (save-excursion
154 + (erlang-get-arity))
155 +- for loc = (make-instance 'erlang-xref-location
156 +- :file file
157 +- :line (line-number-at-pos)
158 +- :column 0
159 +- :arity arity)
160 ++ for loc = (make-erlang-xref-location
161 ++ :file file
162 ++ :line (line-number-at-pos)
163 ++ :column 0
164 ++ :arity arity)
165 + for sum = (erlang-xref-summary kind name arity)
166 + when (and arity
167 + (not (eq arity last-arity)))
168 +- collect (make-instance 'xref-item
169 +- :summary sum
170 +- :location loc)
171 ++ collect (xref-make sum loc)
172 + do (setq last-arity arity)))))))
173 +
174 + (defun erlang-xref-summary (kind tag arity)