]> git.eshelyaron.com Git - emacs.git/commitdiff
Make elide-head-headers-to-hide more forgiving
authorStefan Kangas <stefankangas@gmail.com>
Tue, 27 Dec 2022 16:24:18 +0000 (17:24 +0100)
committerStefan Kangas <stefankangas@gmail.com>
Tue, 27 Dec 2022 17:10:50 +0000 (18:10 +0100)
* 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.

lisp/elide-head.el
test/lisp/elide-head-tests.el

index 75a3612df911211bb30219d4b99db435fad33725..7f565d346d45f4d51f1e46569c2ba6c2b2cb5f6d 100644 (file)
   :group 'tools)
 
 (defcustom elide-head-headers-to-hide
-  `(;; GNU GPL
-    ("is free software[:;] you can redistribute it" .
-     ,(rx (or (seq "If not, see " (? "<")
-                   "http" (? "s") "://www.gnu.org/licenses"
-                   (? "/") (? ">") (? " "))
-              (seq "Boston, MA " (? " ")
-                   "0211" (or "1-1307" "0-1301")
-                   (or "  " ", ") "USA")
-              "675 Mass Ave, Cambridge, MA 02139, USA")
-          (? ".")))
-    ;; FreeBSD license / Modified BSD license (3-clause)
-    (,(rx (or "The Regents of the University of California.  All rights reserved."
-              "Redistribution and use in source and binary"))
-     . "POSSIBILITY OF SUCH DAMAGE\\.")
-    ;; X11 and Expat
-    ("Permission is hereby granted, free of charge" .
-     ,(rx (or "authorization from the X Consortium."           ; X11
-              "THE USE OR OTHER DEALINGS IN THE SOFTWARE.")))) ; Expat
+  (rx-let ((delim
+            ;; A line break could be in a non-standard place, and the
+            ;; license could be in a comment.
+            (or
+             ;; Either just some spaces:
+             (+ " ")
+             ;; Or a newline and some comment starter:
+             (: (* (in " \t"))
+                "\n"
+                (* (in " \t"))
+                (* (or (syntax comment-start) (in ";#*-")))
+                (* (in " \t"))))))
+    `(;; GNU GPL
+      ("is free software[:;] you can redistribute it" .
+       ,(rx (or (seq "If not, see " (? "<")
+                     "http" (? "s") "://www.gnu.org/licenses"
+                     (? "/") (? ">") (? " "))
+                (seq "Boston," delim "MA" delim
+                     (or "02111-1307" "02110-1301" "02111-1301")
+                     (? ",") delim
+                     "USA")
+                "675 Mass Ave, Cambridge, MA 02139, USA")
+            (? ".")))
+      ;; FreeBSD license / Modified BSD license (3-clause)
+      (,(rx (or "The Regents of the University of California.  All rights reserved."
+                "Redistribution and use in source and binary"))
+       . "POSSIBILITY OF SUCH DAMAGE\\.")
+      ;; X11 and Expat
+      ("Permission is hereby granted, free of charge" .
+       ,(rx (or "authorization from the X Consortium." ; X11
+                "THE USE OR OTHER DEALINGS IN THE SOFTWARE."))))) ; Expat
   "Alist of regexps defining start and end of text to elide.
 
 The cars of elements of the list are searched for in order.  Text is
index 429ef266572325f8844c7acdc3430edbe2be6ee9..293fb0dc09da94994fe9690b1ecb384a425ecc53 100644 (file)
 ;; along with Mentor.  If not, see <https://www.gnu.org/licenses>.
 " "Mentor is distributed in the hope that")
 
+;; from GnuTLS       [has a line break in snail mail address]
+(elide-head--add-test gpl3-6 "\
+# This file is part of GnuTLS.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+# USA
+" "This program is distributed in the hope that")
+
+;; from GnuTLS       [has a different line break in snail mail address]
+(elide-head--add-test gpl3-7 "\
+# This file is part of GnuTLS.
+#
+# The GnuTLS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# The GnuTLS is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GnuTLS; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA
+" "The GnuTLS is distributed in the hope that")
+
+;; from GnuTLS       [has a typo in the 02111-1301 part]
+(elide-head--add-test gpl3-8 "\
+/* nettle, low-level cryptographics library
+ *
+ * Copyright (C) 2002 Niels Möller
+ * Copyright (C) 2014 Red Hat
+ *\s\s
+ * The nettle library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *\s
+ * The nettle library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ * License for more details.
+ *\s
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the nettle library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02111-1301, USA.
+ */
+" "The nettle library is distributed in the hope that")
+
+;; from GnuTLS-EXTRA  [has a different line break in snail mail address]
+(elide-head--add-test gpl3-9 "\
+# This file is part of GnuTLS-EXTRA.
+#
+# GnuTLS-extra is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# GnuTLS-extra is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GnuTLS-EXTRA; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+" "GnuTLS-extra is distributed in the hope that")
+
 \f
 ;;; GPLv2