File 1327-Fix-some-emacs-deprecations-and-warnings.patch of Package erlang

From 4c0dd3ca805edf428be0d78ea1b35e3ffa8d4e1e Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Fri, 8 Aug 2025 10:47:09 +0200
Subject: [PATCH] Fix some emacs deprecations and warnings

---
 lib/tools/emacs/erlang-eunit.el     | 11 ++--
 lib/tools/emacs/erlang-flymake.el   |  7 +--
 lib/tools/emacs/erlang-skels-old.el |  2 +-
 lib/tools/emacs/erlang-skels.el     | 16 +++++-
 lib/tools/emacs/erlang-start.el     |  2 +-
 lib/tools/emacs/erlang-test.el      | 48 +++++++++--------
 lib/tools/emacs/erlang.el           | 83 +++++++++++++----------------
 lib/tools/emacs/erlang_appwiz.el    |  6 ++-
 8 files changed, 94 insertions(+), 81 deletions(-)

diff --git a/lib/tools/emacs/erlang-eunit.el b/lib/tools/emacs/erlang-eunit.el
index d325de06a3..25e5e595bb 100644
--- a/lib/tools/emacs/erlang-eunit.el
+++ b/lib/tools/emacs/erlang-eunit.el
@@ -220,11 +220,11 @@ buffer and vice versa"
 With prefix arg, compiles for debug and runs tests with the verbose flag set."
   (interactive)
   (cl-case (erlang-eunit-recent 'mode)
-    ('test-mode
+    (test-mode
      (erlang-eunit-compile-and-test
       'erlang-eunit-run-test (list (erlang-eunit-recent 'module)
                                    (erlang-eunit-recent 'test))))
-    ('module-mode
+    (module-mode
      (erlang-eunit-compile-and-test
       'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module))
       (erlang-eunit-recent 'cover)))
@@ -258,8 +258,7 @@ code along with the coverage analysis results."
                            (erlang-eunit-module-name buffer-file-name)))
          (tmp-filename    (make-temp-file "cover"))
          (analyze-command (format "cover:analyze_to_file(%s, \"%s\"). "
-                                  module-name tmp-filename))
-         (buf-name        (format "*%s coverage*" module-name)))
+                                  module-name tmp-filename)))
     (erlang-eunit-inferior-erlang-send-command analyze-command)
     ;; The purpose of the following snippet is to get the result of the
     ;; analysis from a file into a new buffer (or an old, if one with
@@ -379,7 +378,7 @@ With prefix arg, compiles for debug and runs tests with the verbose flag set."
 
 (defun erlang-eunit-last-compilation-successful-p ()
   (with-current-buffer inferior-erlang-buffer
-    (goto-char compilation-parsing-end)
+    (goto-char erlang-compilation-parsing-end)
     (erlang-eunit-all-list-elems-fulfill-p
      (lambda (re) (let ((continue t)
                         (result   t))
diff --git a/lib/tools/emacs/erlang-flymake.el b/lib/tools/emacs/erlang-flymake.el
index 07eb6d93d8..e49367aee0 100644
--- a/lib/tools/emacs/erlang-flymake.el
+++ b/lib/tools/emacs/erlang-flymake.el
@@ -43,6 +43,8 @@
 ;; This code is inspired by http://www.emacswiki.org/emacs/FlymakeErlang.
 
 (require 'flymake)
+(require 'flymake-proc nil 'noerror)
+
 (eval-when-compile
   (require 'cl-lib))
 
@@ -73,8 +75,7 @@ check on newline and when there are no changes)."
   ;; There doesn't seem to be a way of disabling this; set to the
   ;; largest int available as a workaround (most-positive-fixnum
   ;; equates to 8.5 years on my machine, so it ought to be enough ;-) )
-  (setq flymake-no-changes-timeout most-positive-fixnum)
-  (setq flymake-start-syntax-check-on-newline nil))
+  (setq flymake-no-changes-timeout most-positive-fixnum))
 
 
 (defun erlang-flymake-get-code-path-dirs ()
diff --git a/lib/tools/emacs/erlang-skels.el b/lib/tools/emacs/erlang-skels.el
index 8bca9b0e3c..e118b00ba7 100644
--- a/lib/tools/emacs/erlang-skels.el
+++ b/lib/tools/emacs/erlang-skels.el
@@ -24,6 +24,10 @@
 ;;; Purpose: Provide Erlang code skeletons.
 ;;; See 'erlang-skel-file' variable.
 
+;; (eval-when-compile
+;;   (let ((erlang-skels-loading-for-compilation t))
+;;     (load "erlang")))
+
 (defvar erlang-tempo-tags nil
   "Tempo tags for erlang mode")
 
@@ -1957,6 +1961,16 @@ Please see the function `tempo-define-template'.")
 ;; This code is based on the package `tempo' which is part of modern
 ;; Emacsen.  (GNU Emacs 19.25 (?) and XEmacs 19.14.)
 
+(declare-function erlang-menu-init "erlang")
+(declare-function erlang-menu-add-above "erlang")
+(declare-function erlang-beginning-of-function "erlang")
+(declare-function erlang-get-function-name "erlang")
+(declare-function erlang-get-function-arguments "erlang")
+
+;; Forward declarations
+(defvar erlang-menu-items)
+(defvar erlang-menu-skel-items)
+
 (defun erlang-skel-init ()
   "Generate the skeleton functions and menu items.
 The variable `erlang-skel' contains the name and descriptions of
diff --git a/lib/tools/emacs/erlang-test.el b/lib/tools/emacs/erlang-test.el
index 9efa4d258d..0d44e5b44d 100644
--- a/lib/tools/emacs/erlang-test.el
+++ b/lib/tools/emacs/erlang-test.el
@@ -223,28 +223,34 @@ concatenated to form an erlang file to test on.")
     erlang))
 
 
+
 (ert-deftest erlang-test-parse-id ()
-  (cl-loop for id-string in '("fun/10"
-                              "qualified-function module:fun/10"
-                              "record reko"
-                              "macro _SYMBOL"
-                              "macro MACRO/10"
-                              "module modula"
-                              "macro"
-                              nil)
-           for id-list in '((nil nil "fun" 10)
-                            (qualified-function "module" "fun" 10)
-                            (record nil "reko" nil)
-                            (macro nil "_SYMBOL" nil)
-                            (macro nil "MACRO" 10)
-                            (module nil "modula" nil)
-                            (nil nil "macro" nil)
-                            nil)
-           for id-list2 = (erlang-id-to-list id-string)
-           do (should (equal id-list id-list2))
-           for id-string2 = (erlang-id-to-string id-list)
-           do (should (equal id-string id-string2))
-           collect id-list2))
+  ;; Put it in a lambda to make it work on new (and old) versions
+  ;; (with-suppressed-warnings ((ignored-return-value nreverse))
+  ;; don't exist on emacs 26.
+  (let ((dotest (lambda ()
+                  (cl-loop for id-string in '("fun/10"
+                                              "qualified-function module:fun/10"
+                                              "record reko"
+                                              "macro _SYMBOL"
+                                              "macro MACRO/10"
+                                              "module modula"
+                                              "macro"
+                                              nil)
+                           for id-list in '((nil nil "fun" 10)
+                                            (qualified-function "module" "fun" 10)
+                                            (record nil "reko" nil)
+                                            (macro nil "_SYMBOL" nil)
+                                            (macro nil "MACRO" 10)
+                                            (module nil "modula" nil)
+                                            (nil nil "macro" nil)
+                                            nil)
+                           for id-list2 = (erlang-id-to-list id-string)
+                           do (should (equal id-list id-list2))
+                           for id-string2 = (erlang-id-to-string id-list)
+                           do (should (equal id-string id-string2))
+                           collect id-list2))))
+    (funcall dotest)))
 
 
 (provide 'erlang-test)
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index 723d330d1e..ac3c95d736 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -81,6 +81,7 @@
 (require 'comint)
 (require 'tempo)
 (require 'cl-lib)
+(require 'advice)
 
 ;;; `caddr' is builtin since Emacs 26.
 (eval-and-compile
@@ -93,7 +94,7 @@
   "The Erlang programming language."
   :group 'languages)
 
-(defconst erlang-version "2.8.5"
+(defconst erlang-version "2.8.6"
   "The version number of Erlang mode.")
 
 (defcustom erlang-root-dir nil
@@ -578,6 +579,10 @@ command. The FUNCTION will be called with two arguments: module name and
 default compilation options, like output directory. The FUNCTION
 is expected to return a string.")
 
+(defvar erlang-compilation-parsing-end nil
+  "The position after last compilation command")
+
+
 (defvar erlang-leex-compile-opts '()
   "Options to pass to leex when compiling xrl files.
 This is an elisp list of options. Each option can be either:
@@ -1265,7 +1270,7 @@ This must be placed in front of `erlang-font-lock-keywords-vars'.")
   "Font lock keyword highlighting Erlang variables.
 Must be preceded by `erlang-font-lock-keywords-macros' to work properly.")
 
-(defvar erlang-font-lock-descr-string
+(defmacro erlang-font-lock-descr-string ()
   "Font-lock keywords used by Erlang Mode.
 
 There exists three levels of Font Lock keywords for Erlang:
@@ -1289,7 +1294,7 @@ Example:
           erlang-font-lock-keywords-keywords
           )
   ;; DocStringOrig: erlang-font-lock-keywords
-  erlang-font-lock-descr-string)
+  (erlang-font-lock-descr-string))
 
 (defvar erlang-font-lock-keywords-2
   (append erlang-font-lock-keywords-1
@@ -1300,7 +1305,7 @@ Example:
           erlang-font-lock-keywords-guards
           )
   ;; DocStringCopy: erlang-font-lock-keywords
-  erlang-font-lock-descr-string)
+  (erlang-font-lock-descr-string))
 
 (defvar erlang-font-lock-keywords-3
   (append erlang-font-lock-keywords-2
@@ -1311,7 +1316,7 @@ Example:
           erlang-font-lock-keywords-predefined-types
           )
   ;; DocStringCopy: erlang-font-lock-keywords
-  erlang-font-lock-descr-string)
+  (erlang-font-lock-descr-string))
 
 (defvar erlang-font-lock-keywords-4
   (append erlang-font-lock-keywords-3
@@ -1322,11 +1327,11 @@ Example:
           erlang-font-lock-keywords-lc
           )
   ;; DocStringCopy: erlang-font-lock-keywords
-  erlang-font-lock-descr-string)
+  (erlang-font-lock-descr-string))
 
 (defvar erlang-font-lock-keywords erlang-font-lock-keywords-4
   ;; DocStringCopy: erlang-font-lock-keywords
-  erlang-font-lock-descr-string)
+  (erlang-font-lock-descr-string))
 
 (defvar erlang-font-lock-syntax-table nil
   "Syntax table used by Font Lock mode.
@@ -2394,9 +2399,6 @@ buffer more accurate."
              function-name
              module-name)))
 
-;; Should the defadvice be at the top level, the package `advice' would
-;; be required.  Now it is only required when this functionality
-;; is used.  (Emacs 19 specific.)
 (defun erlang-man-patch-notify ()
   "Patch the function `Man-notify-when-ready' to search for function.
 The variable `erlang-man-function-name' is assumed to be bound to
@@ -2404,23 +2406,17 @@ the function name, or to nil.
 
 The reason for patching a function is that under Emacs 19, the man
 command is executed asynchronously."
-  (condition-case nil
-      (require 'advice)
-    ;; This should never happened since this is only called when
-    ;; running under Emacs 19.
-    (error (error (concat "This command needs the package `advice', "
-                          "please upgrade your Emacs."))))
   (require 'man)
-  (defadvice Man-notify-when-ready
-      (after erlang-Man-notify-when-ready activate)
-    "Set point at the documentation of the function name in
-`erlang-man-function-name' when the man page is displayed."
-    (if erlang-man-function-name
-        (erlang-man-repeated-search-for-function (ad-get-arg 0)
-                                                 erlang-man-function-name)
-      (setq erlang-man-function-name nil))))
-
+  (if (fboundp 'advice-add)
+    (advice-add 'Man-notify-when-ready :after
+      #'erlang-man-function-name-advice)))
 
+(defun erlang-man-function-name-advice (arg)
+  "Set point at the documentation of the function name in
+`erlang-man-function-name' when the man page is displayed."
+  (if erlang-man-function-name
+    (erlang-man-repeated-search-for-function arg erlang-man-function-name)
+    (setq erlang-man-function-name nil)))
 
 
 (defun erlang-man-find-function (buf func &optional module-name)
@@ -5121,19 +5117,11 @@ for a tag on the form `module:tag'."
 ;;; completion-table' containing all normal tags plus tags on the form
 ;;; `module:tag' and `module:'.
 
-(if (fboundp 'advice-add)
-    ;; Emacs 24.4+
-    (progn
-      (require 'etags)
-      (advice-add 'etags-tags-completion-table :around
-                  #'erlang-etags-tags-completion-table-advice))
-  ;; Emacs 23.1-24.3
-  (defadvice etags-tags-completion-table (around
-                                          erlang-replace-tags-table
-                                          activate)
-    (if erlang-replace-etags-tags-completion-table
-        (setq ad-return-value (erlang-etags-tags-completion-table))
-      ad-do-it)))
+(progn
+  (require 'etags)
+  (if (fboundp 'advice-add)
+    (advice-add 'etags-tags-completion-table :around
+      #'erlang-etags-tags-completion-table-advice)))
 
 (defun erlang-etags-tags-completion-table-advice (oldfun)
   (if erlang-replace-etags-tags-completion-table
@@ -6129,7 +6117,7 @@ Return the position after the newly inserted command."
                       (not (eq (point) (point-max))))
           (delete-char 1)
           (or (bolp)
-              (backward-delete-char 1))))))
+            (delete-char -1))))))
 
 
 ;; Basically `comint-strip-ctrl-m', with a few extra checks.
@@ -6183,9 +6171,9 @@ There exists two workarounds for this bug:
     (sit-for 0)
     (inferior-erlang-wait-prompt)
     (with-current-buffer inferior-erlang-buffer
-      (when (and (boundp 'compilation-error-list) (boundp 'compilation-parsing-end))
-        (setq compilation-error-list nil)
-        (set-marker compilation-parsing-end end)))
+      (set-marker erlang-compilation-parsing-end end)
+      (when (boundp 'compilation-error-list)
+        (setq compilation-error-list nil)))
     (setq next-error-last-buffer inferior-erlang-buffer)))
 
 (defun inferior-erlang-prepare-for-input (&optional no-display)
@@ -6408,9 +6396,12 @@ The default is to go to the directory of the current buffer."
         (match-string 0))))
 
 (defconst erlang-unload-hook
-  (list (lambda ()
-          (ad-unadvise 'Man-notify-when-ready)
-          (ad-unadvise 'set-visited-file-name))))
+  (if (fboundp 'advice-remove)
+    (list (lambda ()
+            (advice-remove 'Man-notify-when-ready
+              #'erlang-man-function-name-advice)
+            (advice-remove 'etags-tags-completion-table
+              #'erlang-etags-tags-completion-table-advice)))))
 
 ;; The end...
 
diff --git a/lib/tools/emacs/erlang_appwiz.el b/lib/tools/emacs/erlang_appwiz.el
index 739f6d51fc..5141f07f13 100644
--- a/lib/tools/emacs/erlang_appwiz.el
+++ b/lib/tools/emacs/erlang_appwiz.el
@@ -468,7 +468,7 @@ is an expression which is evaluated every time the menu is displayed.
 Should the expression evaluate to nil the menu item is ghosted.
 
 Example:
-    '((\"Func1\" function-one)
+    \='((\"Func1\" function-one)
       (\"SubItem\" 
        ((\"Yellow\" function-yellow)
         (\"Blue\" function-blue)))
@@ -940,6 +940,8 @@ Please see the function `tempo-define-template'.")
 
 (add-hook 'erlang-load-hook 'my-erlang-load-mods)
 
+(defvar erlang-atom-regexp)
+
 (defun fixed-erlang-add-quotes-if-needed (str)
   "Return STR, possibly with quotes."
   (let ((saved-case-fold-search case-fold-search)
-- 
2.43.0

openSUSE Build Service is sponsored by