From 28e75b6955af4e6531861decd3e9660d9136d371 Mon Sep 17 00:00:00 2001 From: Johan Claesson Date: Sun, 17 Mar 2019 18:14:33 +0100 Subject: Emacs: Adapt to changed make-symbolic-link behavior Since Emacs 26 make-symbolic-link will by default not expand a leading ~ in the target. Let's do it ourselves then i guess. --- lib/tools/emacs/erldoc.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tools/emacs/erldoc.el b/lib/tools/emacs/erldoc.el index 770ab299ee..77e66bfc98 100644 --- a/lib/tools/emacs/erldoc.el +++ b/lib/tools/emacs/erldoc.el @@ -280,7 +280,7 @@ up the indexing." (unless (file-exists-p of) (erldoc-parse-all erldoc-man-index of)) (unless (string= erldoc-output-file of) - (make-symbolic-link of erldoc-output-file)))) + (make-symbolic-link (expand-file-name of) erldoc-output-file)))) (setq erldoc-lookup-table (with-temp-buffer (insert-file-contents erldoc-output-file) -- cgit v1.2.3 From 7a63195cc680a6e89fc1a59440d494f343c023d3 Mon Sep 17 00:00:00 2001 From: Johan Claesson Date: Sun, 17 Mar 2019 18:27:32 +0100 Subject: Emacs: Collect more function signatures for erldoc Before this commit some function signatures were missed when parsing the html doc of OTP 21.3. After this commit more are collected but still two signatures are missed (erlang:statistics/1 and filename:basedir/3). --- lib/tools/emacs/erldoc.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/tools/emacs/erldoc.el b/lib/tools/emacs/erldoc.el index 77e66bfc98..b9d5e9572a 100644 --- a/lib/tools/emacs/erldoc.el +++ b/lib/tools/emacs/erldoc.el @@ -213,9 +213,10 @@ up the indexing." (when (and (eq (car-safe d) 'a) (gethash (erldoc-dom-get-attribute d 'name) table)) (push (append (gethash (erldoc-dom-get-attribute d 'name) table) - (list (funcall span-content - (or (erldoc-dom-get-element d 'span) - (cadr (memq d erldoc-dom-walk-siblings)))))) + (list (or (funcall span-content d) + (funcall span-content + (or (erldoc-dom-get-element d 'span) + (cadr (memq d erldoc-dom-walk-siblings))))))) entries)) ;; Get data types (when (and (eq (car-safe d) 'a) -- cgit v1.2.3 From 6d33a26a344fe6d788f3c3a52f6637f0ea6b98e6 Mon Sep 17 00:00:00 2001 From: Johan Claesson Date: Sun, 17 Mar 2019 19:37:48 +0100 Subject: Emacs: Hide html parsing failure in erldoc by default The parsing of the OTP doc seldom fails but in the rare cases it does not find a function signature hide the error by default. If the user wish to be notified they may customize `erldoc-no-signature-function'. Sorry for breaking the "Let it crash!" rule ;) --- lib/tools/emacs/erldoc.el | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/tools/emacs/erldoc.el b/lib/tools/emacs/erldoc.el index b9d5e9572a..bc16d7a14d 100644 --- a/lib/tools/emacs/erldoc.el +++ b/lib/tools/emacs/erldoc.el @@ -89,6 +89,13 @@ up the indexing." :type 'file :group 'erldoc) +(defcustom erldoc-no-signature-function #'ignore + "Notification function called if no function signature was found." + :type '(choice (function-item :tag "Ignore" ignore) + (function-item :tag "Warn" warn) + (function-item :tag "Error" error)) + :group 'erldoc) + (defun erldoc-strip-string (s) (let* ((re "[ \t\n\r\f\v\u00a0]+") (from (if (string-match (concat "\\`" re) s) (match-end 0) 0)) @@ -212,12 +219,21 @@ up the indexing." ;; Get the full function signature. (when (and (eq (car-safe d) 'a) (gethash (erldoc-dom-get-attribute d 'name) table)) - (push (append (gethash (erldoc-dom-get-attribute d 'name) table) - (list (or (funcall span-content d) - (funcall span-content - (or (erldoc-dom-get-element d 'span) - (cadr (memq d erldoc-dom-walk-siblings))))))) - entries)) + (let* ((name (erldoc-dom-get-attribute d 'name)) + (mfa-url (gethash name table)) + (mfa (car mfa-url)) + (sig (or (funcall span-content d) + (funcall span-content + (or (erldoc-dom-get-element d 'span) + (cadr + (memq d erldoc-dom-walk-siblings)))) + (progn + (funcall erldoc-no-signature-function + "erldoc-parse-man: no sig for %s" + mfa) + nil)))) + (push (append mfa-url (list sig)) + entries))) ;; Get data types (when (and (eq (car-safe d) 'a) (string-prefix-p "type-" @@ -357,9 +373,12 @@ up the indexing." (sigs)) (maphash (lambda (k v) (when (string-match re k) - (push (cons (string-to-number (match-string 1 k)) - (cdr (erldoc-tokenize-signature (cadr v)))) - sigs))) + (if (cadr v) + (push (cons (string-to-number (match-string 1 k)) + (cdr (erldoc-tokenize-signature (cadr v)))) + sigs) + (funcall erldoc-no-signature-function + "erldoc-format-signature: No sig for %s" k)))) (erldoc-lookup-table)) (when sigs ;; Mostly single return type but there are exceptions such as -- cgit v1.2.3