File 0838-erlang.el-also-search-in-alternative-directory-for-m.patch of Package erlang

From 034959dd254d7df387d59048e7623bc5e90797e4 Mon Sep 17 00:00:00 2001
From: Kjell Winblad <kjellwinblad@gmail.com>
Date: Sun, 29 Sep 2019 19:53:30 +0200
Subject: [PATCH] erlang.el: also search in alternative directory for man pages

One way of creating an Erlang/OTP release from an Erlang git
repository is to run the following command:

    cd path_to_the_erlang_otp_git_repo && \
    ERL_TOP="`pwd`" && \
    ./otp_build autoconf && \
    ./configure && \
    make && \
    make release && \
    make release_docs && \
    TARGET_SYS=`$ERL_TOP/erts/autoconf/config.guess` && \
    cd "$ERL_TOP/release/$TARGET_SYS" && \
    ./Install -minimal "`pwd`"

The Erlang release will then be placed in
"$ERL_TOP/release/$TARGET_SYS" and the Erlang man pages will be placed
in "$ERL_TOP/release/$TARGET_SYS/man" but the erlang emacs mode would
not find these man pages even if one set the emacs variable
erlang-root-dir to "$ERL_TOP/release/$TARGET_SYS". This commit fixes
this by allowing an alternative search path to the Erlang man pages.
---
 lib/tools/emacs/erlang.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index 68d777b8a4..40899dc872 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -1935,7 +1935,15 @@ The format is described in the documentation of `erlang-man-dirs'."
          (("Error! Why?" erlang-man-describe-error)))))))
 
 (defun erlang-man-dir (subdir)
-  (concat erlang-root-dir "/lib/erlang/" subdir))
+  (let ((default_man_dir (concat (file-name-as-directory erlang-root-dir)
+                                 (file-name-as-directory "lib")
+                                 (file-name-as-directory "erlang") subdir)))
+    (if (or (equal erlang-root-dir nil) (file-directory-p default_man_dir))
+        default_man_dir
+      (concat (file-name-as-directory erlang-root-dir) subdir)
+      )
+    )
+  )
 
 ;; Should the menu be to long, let's split it into a number of
 ;; smaller menus.  Warning, this code contains beautiful
-- 
2.16.4

openSUSE Build Service is sponsored by