File 2877-Make-fixes-due-to-comments-by-johanclaesson-on-pull-.patch of Package erlang
From 7864c569054b647c740d3e675d686aa962798b79 Mon Sep 17 00:00:00 2001
From: Kjell Winblad <kjellwinblad@gmail.com>
Date: Tue, 15 Oct 2019 11:06:24 +0200
Subject: [PATCH 07/10] Make fixes due to comments by @johanclaesson on pull
request #2414
This commit contains two fixes due to comments by Johan Claesson
(https://github.com/erlang/otp/pull/2414):
* Refactor flet expression into a defun
* Reduce the length of an error message by removing an unnecessary
sentence
---
lib/tools/emacs/erlang.el | 74 ++++++++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 36 deletions(-)
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index ba7493a126..a8f17a364b 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -2141,6 +2141,36 @@ This function is aware of imported functions."
Used for communication between `erlang-man-function' and the
patch to `Man-notify-when-ready'.")
+(defun erlang-man-function-display-man-page (name)
+ "Helper function for erlang-man-function. Displays the man page
+ text for the Erlang function named name if it can be found."
+ (let ((modname nil)
+ (funcname nil))
+ (cond ((string-match ":" name)
+ (setq modname (substring name 0 (match-beginning 0)))
+ (setq funcname (substring name (match-end 0) nil)))
+ ((stringp name)
+ (setq modname name)))
+ (when (or (null modname) (string= modname ""))
+ (error "No Erlang module name given"))
+ (cond ((fboundp 'Man-notify-when-ready)
+ ;; Emacs 19: The man command could possibly start an
+ ;; asynchronous process, i.e. we must hook ourselves into
+ ;; the system to be activated when the man-process
+ ;; terminates.
+ (if (null funcname)
+ ()
+ (erlang-man-patch-notify)
+ (setq erlang-man-function-name funcname))
+ (condition-case err
+ (erlang-man-module modname)
+ (error (setq erlang-man-function-name nil)
+ (signal (car err) (cdr err)))))
+ (t
+ (erlang-man-module modname)
+ (when funcname
+ (erlang-man-find-function (current-buffer) funcname))))))
+
(defun erlang-man-function (&optional name)
"Find manual page for NAME, where NAME is module:function.
The entry for `function' is displayed.
@@ -2160,41 +2190,13 @@ This function is aware of imported functions."
(require 'man)
(setq name (or name
(erlang-default-function-or-module)))
- (require 'cl)
- (flet ((disp-man-page-erl-fun (name)
- (let ((modname nil)
- (funcname nil))
- (cond ((string-match ":" name)
- (setq modname (substring name 0 (match-beginning 0)))
- (setq funcname (substring name (match-end 0) nil)))
- ((stringp name)
- (setq modname name)))
- (when (or (null modname) (string= modname ""))
- (error "No Erlang module name given"))
- (cond ((fboundp 'Man-notify-when-ready)
- ;; Emacs 19: The man command could possibly start an
- ;; asynchronous process, i.e. we must hook ourselves into
- ;; the system to be activated when the man-process
- ;; terminates.
- (if (null funcname)
- ()
- (erlang-man-patch-notify)
- (setq erlang-man-function-name funcname))
- (condition-case err
- (erlang-man-module modname)
- (error (setq erlang-man-function-name nil)
- (signal (car err) (cdr err)))))
- (t
- (erlang-man-module modname)
- (when funcname
- (erlang-man-find-function (current-buffer) funcname)))))))
- (disp-man-page-erl-fun name)
- (sleep-for 0 600)
- ;; A hack to make sure that the function scrolls
- ;; to the description of the function when it is
- ;; the first time that the man page for a module
- ;; is opened
- (disp-man-page-erl-fun name)))
+ (erlang-man-function-display-man-page name)
+ (sleep-for 0 600)
+ ;; A hack to make sure that the function scrolls
+ ;; to the description of the function when it is
+ ;; the first time that the man page for a module
+ ;; is opened
+ (erlang-man-function-display-man-page name))
(defun erlang-man-function-no-prompt ()
@@ -2207,7 +2209,7 @@ opening the man page for the function."
(let ((name (erlang-default-function-or-module)))
(if name
(erlang-man-function name)
- (error "No function name under the cursor. Place the cursor over the function name you want to find the man page for and try again"))))
+ (error "No function name under the cursor"))))
;; Should the defadvice be at the top level, the package `advice' would
;; be required. Now it is only required when this functionality
--
2.16.4