Skip to content

Commit e6a25fc

Browse files
committed
Add utility functions
1 parent afedae9 commit e6a25fc

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

mldoc.el

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
(require 'cl-lib)
3232
(require 'eldoc)
3333
(require 'nadvice)
34-
34+
35+
;; Custom variables:
3536
(defgroup mldoc nil
3637
"Multi ElDoc integration"
3738
:group 'tools)
@@ -52,7 +53,22 @@
5253

5354
(defvar-local mldoc-returns-string t
5455
"When not-NIL, MLDoc functions return ElDoc complatible string.")
55-
56+
57+
;; Utility functions
58+
(defsubst mldoc-in-string ()
59+
"Return non-nil if inside a string.
60+
it is the character that will terminate the string, or t if the string should be terminated by a generic string delimiter."
61+
(nth 3 (syntax-ppss)))
62+
63+
(defsubst mldoc-in-comment ()
64+
"Return nil if outside a comment, t if inside a non-nestable comment, else an integer (the current comment nesting)."
65+
(nth 4 (syntax-ppss)))
66+
67+
(defsubst mldoc-in-string-or-comment ()
68+
"Return character address of start of comment or string; nil if not in one."
69+
(nth 8 (syntax-ppss)))
70+
71+
;; Macros
5672
(defmacro define-mldoc (name docstring &rest body)
5773
"Define `NAME' as a ElDoc-MLDOC compatible function.
5874
The definition is (lambda ARGLIST [DOCSTRING] BODY...)."

0 commit comments

Comments
 (0)