aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/emacs/erlang.el
diff options
context:
space:
mode:
authorJohan Claesson <[email protected]>2016-07-15 17:12:09 +0200
committerDan Gudmundsson <[email protected]>2016-08-31 16:40:25 +0200
commitb5a4c4a31e06db72b84df2c40163c2944388863a (patch)
tree58918a9758e9ca9f59a8c26f1a6829f4e7b923a5 /lib/tools/emacs/erlang.el
parent243a05c2474928786cf47ad06966cbf121ce8ea8 (diff)
downloadotp-b5a4c4a31e06db72b84df2c40163c2944388863a.tar.gz
otp-b5a4c4a31e06db72b84df2c40163c2944388863a.tar.bz2
otp-b5a4c4a31e06db72b84df2c40163c2944388863a.zip
Emacs: extend support for compile options
The syntax was limited to atoms, strings and 2-tuples. This covers most compile options but not for example {d,Macro,Value}. Add support for N-tuples and lists. Add a related unit test case.
Diffstat (limited to 'lib/tools/emacs/erlang.el')
-rw-r--r--lib/tools/emacs/erlang.el45
1 files changed, 21 insertions, 24 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index c5904ff686..73c6b8d768 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -4358,8 +4358,7 @@ works under XEmacs.)"
(require 'etags)
(set (make-local-variable 'find-tag-default-function)
'erlang-find-tag-for-completion)
- (if (boundp 'xref-backend-functions)
- ;; Emacs 25+
+ (if (>= emacs-major-version 25)
(add-hook 'xref-backend-functions
#'erlang-etags--xref-backend nil t)
;; Test on a function available in the Emacs 19 version
@@ -5715,31 +5714,29 @@ unless the optional NO-DISPLAY is non-nil."
(defun inferior-erlang-format-comma-opts (opts)
(if (null opts)
""
- (concat ", " (inferior-erlang-format-opts opts))))
-
-(defun inferior-erlang-format-opts (opts)
- (concat "[" (inferior-erlang-string-join (mapcar 'inferior-erlang-format-opt
- opts)
- ", ")
- "]"))
+ (concat ", " (inferior-erlang-format-opt opts))))
(defun inferior-erlang-format-opt (opt)
(cond ((stringp opt) (concat "\"" opt "\""))
- ((atom opt) (format "%s" opt))
- ((consp opt) (concat "{" (inferior-erlang-string-join
- (mapcar 'inferior-erlang-format-opt
- (list (car opt) (cdr opt)))
- ", ")
- "}"))
- (t (error (format "Unexpected opt %s" opt)))))
-
-(defun inferior-erlang-string-join (strs sep)
- (let ((result (or (car strs) "")))
- (setq strs (cdr strs))
- (while strs
- (setq result (concat result sep (car strs)))
- (setq strs (cdr strs)))
- result))
+ ((vectorp opt) (inferior-erlang-tuple (append opt nil)))
+ ((atom opt) (format "%s" opt))
+ ((consp opt) (if (listp (cdr opt))
+ (inferior-erlang-list opt)
+ (inferior-erlang-tuple (list (car opt) (cdr opt)))))
+ (t (error "Unexpected erlang compile option %s" opt))))
+
+(defun inferior-erlang-tuple (opts)
+ (concat "{" (mapconcat 'inferior-erlang-format-opt
+ opts
+ ", ")
+ "}"))
+
+(defun inferior-erlang-list (opts)
+ (concat "[" (mapconcat 'inferior-erlang-format-opt
+ opts
+ ", ")
+ "]"))
+
(defun erlang-local-buffer-file-name ()
;; When editing a file remotely via tramp,