aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2022-12-27 17:24:18 +0100
committerStefan Kangas2022-12-27 18:10:50 +0100
commitfb0ff54eb45ba9fc939d07740c895ed2ef58c406 (patch)
tree98e95c4ae75c8595ba5ce24779681e2c31695464
parent2ffe1494e16381cfc7fec95a6a0879f268df3e95 (diff)
downloademacs-fb0ff54eb45ba9fc939d07740c895ed2ef58c406.tar.gz
emacs-fb0ff54eb45ba9fc939d07740c895ed2ef58c406.zip
Make elide-head-headers-to-hide more forgiving
* lisp/elide-head.el (elide-head-headers-to-hide): Make regexp more forgiving of line breaks and comment characters in address. * test/lisp/elide-head-tests.el (gpl3-6): New test.
-rw-r--r--lisp/elide-head.el49
-rw-r--r--test/lisp/elide-head-tests.el84
2 files changed, 115 insertions, 18 deletions
diff --git a/lisp/elide-head.el b/lisp/elide-head.el
index 75a3612df91..7f565d346d4 100644
--- a/lisp/elide-head.el
+++ b/lisp/elide-head.el
@@ -50,24 +50,37 @@
50 :group 'tools) 50 :group 'tools)
51 51
52(defcustom elide-head-headers-to-hide 52(defcustom elide-head-headers-to-hide
53 `(;; GNU GPL 53 (rx-let ((delim
54 ("is free software[:;] you can redistribute it" . 54 ;; A line break could be in a non-standard place, and the
55 ,(rx (or (seq "If not, see " (? "<") 55 ;; license could be in a comment.
56 "http" (? "s") "://www.gnu.org/licenses" 56 (or
57 (? "/") (? ">") (? " ")) 57 ;; Either just some spaces:
58 (seq "Boston, MA " (? " ") 58 (+ " ")
59 "0211" (or "1-1307" "0-1301") 59 ;; Or a newline and some comment starter:
60 (or " " ", ") "USA") 60 (: (* (in " \t"))
61 "675 Mass Ave, Cambridge, MA 02139, USA") 61 "\n"
62 (? "."))) 62 (* (in " \t"))
63 ;; FreeBSD license / Modified BSD license (3-clause) 63 (* (or (syntax comment-start) (in ";#*-")))
64 (,(rx (or "The Regents of the University of California. All rights reserved." 64 (* (in " \t"))))))
65 "Redistribution and use in source and binary")) 65 `(;; GNU GPL
66 . "POSSIBILITY OF SUCH DAMAGE\\.") 66 ("is free software[:;] you can redistribute it" .
67 ;; X11 and Expat 67 ,(rx (or (seq "If not, see " (? "<")
68 ("Permission is hereby granted, free of charge" . 68 "http" (? "s") "://www.gnu.org/licenses"
69 ,(rx (or "authorization from the X Consortium." ; X11 69 (? "/") (? ">") (? " "))
70 "THE USE OR OTHER DEALINGS IN THE SOFTWARE.")))) ; Expat 70 (seq "Boston," delim "MA" delim
71 (or "02111-1307" "02110-1301" "02111-1301")
72 (? ",") delim
73 "USA")
74 "675 Mass Ave, Cambridge, MA 02139, USA")
75 (? ".")))
76 ;; FreeBSD license / Modified BSD license (3-clause)
77 (,(rx (or "The Regents of the University of California. All rights reserved."
78 "Redistribution and use in source and binary"))
79 . "POSSIBILITY OF SUCH DAMAGE\\.")
80 ;; X11 and Expat
81 ("Permission is hereby granted, free of charge" .
82 ,(rx (or "authorization from the X Consortium." ; X11
83 "THE USE OR OTHER DEALINGS IN THE SOFTWARE."))))) ; Expat
71 "Alist of regexps defining start and end of text to elide. 84 "Alist of regexps defining start and end of text to elide.
72 85
73The cars of elements of the list are searched for in order. Text is 86The cars of elements of the list are searched for in order. Text is
diff --git a/test/lisp/elide-head-tests.el b/test/lisp/elide-head-tests.el
index 429ef266572..293fb0dc09d 100644
--- a/test/lisp/elide-head-tests.el
+++ b/test/lisp/elide-head-tests.el
@@ -180,6 +180,90 @@
180;; along with Mentor. If not, see <https://www.gnu.org/licenses>. 180;; along with Mentor. If not, see <https://www.gnu.org/licenses>.
181" "Mentor is distributed in the hope that") 181" "Mentor is distributed in the hope that")
182 182
183;; from GnuTLS [has a line break in snail mail address]
184(elide-head--add-test gpl3-6 "\
185# This file is part of GnuTLS.
186#
187# This program is free software; you can redistribute it and/or modify
188# it under the terms of the GNU General Public License as published by
189# the Free Software Foundation; either version 3 of the License, or
190# (at your option) any later version.
191#
192# This program is distributed in the hope that it will be useful, but
193# WITHOUT ANY WARRANTY; without even the implied warranty of
194# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
195# General Public License for more details.
196#
197# You should have received a copy of the GNU General Public License
198# along with this program; if not, write to the Free Software
199# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
200# USA
201" "This program is distributed in the hope that")
202
203;; from GnuTLS [has a different line break in snail mail address]
204(elide-head--add-test gpl3-7 "\
205# This file is part of GnuTLS.
206#
207# The GnuTLS is free software; you can redistribute it and/or
208# modify it under the terms of the GNU Lesser General Public License
209# as published by the Free Software Foundation; either version 2.1 of
210# the License, or (at your option) any later version.
211#
212# The GnuTLS is distributed in the hope that it will be
213# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
214# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
215# Lesser General Public License for more details.
216#
217# You should have received a copy of the GNU Lesser General Public
218# License along with GnuTLS; if not, write to the Free
219# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
220# MA 02110-1301, USA
221" "The GnuTLS is distributed in the hope that")
222
223;; from GnuTLS [has a typo in the 02111-1301 part]
224(elide-head--add-test gpl3-8 "\
225/* nettle, low-level cryptographics library
226 *
227 * Copyright (C) 2002 Niels Möller
228 * Copyright (C) 2014 Red Hat
229 *\s\s
230 * The nettle library is free software; you can redistribute it and/or modify
231 * it under the terms of the GNU Lesser General Public License as published by
232 * the Free Software Foundation; either version 2.1 of the License, or (at your
233 * option) any later version.
234 *\s
235 * The nettle library is distributed in the hope that it will be useful, but
236 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
237 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
238 * License for more details.
239 *\s
240 * You should have received a copy of the GNU Lesser General Public License
241 * along with the nettle library; see the file COPYING.LIB. If not, write to
242 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
243 * MA 02111-1301, USA.
244 */
245" "The nettle library is distributed in the hope that")
246
247;; from GnuTLS-EXTRA [has a different line break in snail mail address]
248(elide-head--add-test gpl3-9 "\
249# This file is part of GnuTLS-EXTRA.
250#
251# GnuTLS-extra is free software; you can redistribute it and/or
252# modify it under the terms of the GNU General Public License as
253# published by the Free Software Foundation; either version 3 of the
254# License, or (at your option) any later version.
255#
256# GnuTLS-extra is distributed in the hope that it will be useful, but
257# WITHOUT ANY WARRANTY; without even the implied warranty of
258# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
259# General Public License for more details.
260#
261# You should have received a copy of the GNU General Public License
262# along with GnuTLS-EXTRA; if not, write to the Free Software
263# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
264# 02110-1301, USA.
265" "GnuTLS-extra is distributed in the hope that")
266
183 267
184;;; GPLv2 268;;; GPLv2
185 269