Skip to content

Commit 12cb169

Browse files
authored
Merge pull request #284 from riscy/master
adjust docstring formatting
2 parents ee262cc + 5d0406f commit 12cb169

File tree

1 file changed

+45
-48
lines changed

1 file changed

+45
-48
lines changed

rust-mode.el

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@
5555
"\\_>"))
5656

5757
(defun rust-looking-back-str (str)
58-
"Like `looking-back' but for fixed strings rather than regexps (so that it's not so slow)"
58+
"Return non-nil if there's a match on the text before point and STR.
59+
Like `looking-back' but for fixed strings rather than regexps (so that it's not so slow)."
5960
(let ((len (length str)))
6061
(and (> (point) len)
6162
(equal str (buffer-substring-no-properties (- (point) len) (point))))))
6263

6364
(defun rust-looking-back-symbols (SYMS)
64-
"Return non-nil if the point is just after a complete symbol that is a member of the list of strings SYMS"
65+
"Return non-nil if the point is just after a complete symbol that is a member of the list of strings SYMS."
6566
(save-excursion
6667
(let* ((pt-orig (point))
6768
(beg-of-symbol (progn (forward-thing 'symbol -1) (point)))
@@ -71,7 +72,7 @@
7172
(member (buffer-substring-no-properties beg-of-symbol pt-orig) SYMS)))))
7273

7374
(defun rust-looking-back-ident ()
74-
"Non-nil if we are looking backwards at a valid rust identifier"
75+
"Non-nil if we are looking backwards at a valid rust identifier."
7576
(let ((beg-of-symbol (save-excursion (forward-thing 'symbol -1) (point))))
7677
(looking-back rust-re-ident beg-of-symbol)))
7778

@@ -116,30 +117,29 @@
116117
:safe #'integerp)
117118

118119
(defcustom rust-indent-method-chain nil
119-
"Indent Rust method chains, aligned by the '.' operators"
120+
"Indent Rust method chains, aligned by the `.' operators."
120121
:type 'boolean
121122
:group 'rust-mode
122123
:safe #'booleanp)
123124

124125
(defcustom rust-indent-where-clause nil
125-
"Indent the line starting with the where keyword following a
126-
function or trait. When nil, where will be aligned with fn or trait."
126+
"Indent lines starting with the `where' keyword following a function or trait.
127+
When nil, `where' will be aligned with `fn' or `trait'."
127128
:type 'boolean
128129
:group 'rust-mode
129130
:safe #'booleanp)
130131

131132
(defcustom rust-playpen-url-format "https://play.rust-lang.org/?code=%s"
132-
"Format string to use when submitting code to the playpen"
133+
"Format string to use when submitting code to the playpen."
133134
:type 'string
134135
:group 'rust-mode)
135136
(defcustom rust-shortener-url-format "https://is.gd/create.php?format=simple&url=%s"
136-
"Format string to use for creating the shortened link of a playpen submission"
137+
"Format string to use for creating the shortened link of a playpen submission."
137138
:type 'string
138139
:group 'rust-mode)
139140

140141
(defcustom rust-match-angle-brackets t
141-
"Enable angle bracket matching. Attempt to match `<' and `>' where
142-
appropriate."
142+
"Whether to attempt angle bracket matching (`<' and `>') where appropriate."
143143
:type 'boolean
144144
:safe #'booleanp
145145
:group 'rust-mode)
@@ -161,8 +161,7 @@ function or trait. When nil, where will be aligned with fn or trait."
161161
:group 'rust-mode)
162162

163163
(defcustom rust-always-locate-project-on-open nil
164-
"Whether to run `cargo locate-project' every time `rust-mode'
165-
is activated."
164+
"Whether to run `cargo locate-project' every time `rust-mode' is activated."
166165
:type 'boolean
167166
:group 'rust-mode)
168167

@@ -351,7 +350,7 @@ buffer."
351350
(rust-rewind-to-beginning-of-current-level-expr)
352351
(+ (current-column) rust-indent-offset))))))
353352
(cond
354-
;; Indent inside a non-raw string only if the the previous line
353+
;; Indent inside a non-raw string only if the previous line
355354
;; ends with a backslash that is inside the same string
356355
((nth 3 (syntax-ppss))
357356
(let*
@@ -576,8 +575,9 @@ buffer."
576575

577576

578577
(defun rust-path-font-lock-matcher (re-ident)
579-
"Matches names like \"foo::\" or \"Foo::\" (depending on RE-IDENT, which should match
580-
the desired identifiers), but does not match type annotations \"foo::<\"."
578+
"Match occurrences of RE-IDENT followed by a double-colon.
579+
Examples include to match names like \"foo::\" or \"Foo::\".
580+
Does not match type annotations of the form \"foo::<\"."
581581
`(lambda (limit)
582582
(catch 'rust-path-font-lock-matcher
583583
(while t
@@ -593,8 +593,7 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
593593
(throw 'rust-path-font-lock-matcher match))))))))
594594

595595
(defun rust-next-string-interpolation (limit)
596-
"Search forward from point for next Rust interpolation marker
597-
before LIMIT.
596+
"Search forward from point for the next Rust interpolation marker before LIMIT.
598597
Set point to the end of the occurrence found, and return match beginning
599598
and end."
600599
(catch 'match
@@ -615,8 +614,8 @@ and end."
615614
(throw 'match (list start (point)))))))))))
616615

617616
(defun rust-string-interpolation-matcher (limit)
618-
"Match next Rust interpolation marker before LIMIT and set
619-
match data if found. Returns nil if not within a Rust string."
617+
"Match the next Rust interpolation marker before LIMIT; set match data if found.
618+
Returns nil if the point is not within a Rust string."
620619
(when (rust-in-str)
621620
(let ((match (rust-next-string-interpolation limit)))
622621
(when match
@@ -630,7 +629,7 @@ match data if found. Returns nil if not within a Rust string."
630629
"format"
631630
"print"
632631
"println")
633-
"List of builtin Rust macros for string formatting used by `rust-mode-font-lock-keywords'. (`write!' is handled separately.)")
632+
"List of builtin Rust macros for string formatting used by `rust-mode-font-lock-keywords' (`write!' is handled separately).")
634633

635634
(defvar rust-formatting-macro-opening-re
636635
"[[:space:]\n]*[({[][[:space:]\n]*"
@@ -751,10 +750,11 @@ match data if found. Returns nil if not within a Rust string."
751750
(goto-char dest))))))
752751

753752
(defun rust-rewind-to-decl-name ()
754-
"If we are before an ident that is part of a declaration that
755-
can have a where clause, rewind back to just before the name of
756-
the subject of that where clause and return the new point.
757-
Otherwise return nil"
753+
"Return the point at the beginning of the name in a declaration.
754+
I.e. if we are before an ident that is part of a declaration that
755+
can have a where clause, rewind back to just before the name of
756+
the subject of that where clause and return the new point.
757+
Otherwise return nil."
758758

759759
(let* ((ident-pos (point))
760760
(newpos (save-excursion
@@ -783,13 +783,13 @@ match data if found. Returns nil if not within a Rust string."
783783

784784
(defun rust-is-in-expression-context (token)
785785
"Return t if what comes right after the point is part of an
786-
expression (as opposed to starting a type) by looking at what
787-
comes before. Takes a symbol that roughly indicates what is
788-
after the point.
786+
expression (as opposed to starting a type) by looking at what
787+
comes before. Takes a symbol that roughly indicates what is
788+
after the point.
789789
790-
This function is used as part of `rust-is-lt-char-operator' as
791-
part of angle bracket matching, and is not intended to be used
792-
outside of this context."
790+
This function is used as part of `rust-is-lt-char-operator' as
791+
part of angle bracket matching, and is not intended to be used
792+
outside of this context."
793793

794794
(save-excursion
795795
(let ((postchar (char-after)))
@@ -970,8 +970,8 @@ match data if found. Returns nil if not within a Rust string."
970970
))))
971971

972972
(defun rust-is-lt-char-operator ()
973-
"Return t if the < sign just after point is an operator rather
974-
than an opening angle bracket, otherwise nil."
973+
"Return t if the `<' after the point is the less-than operator.
974+
Otherwise, for instance if it's an opening angle bracket, return nil."
975975

976976
(let ((case-fold-search nil))
977977
(save-excursion
@@ -1019,9 +1019,8 @@ match data if found. Returns nil if not within a Rust string."
10191019
))))
10201020

10211021
(defun rust-electric-pair-inhibit-predicate-wrap (char)
1022-
"Wraps the default `electric-pair-inhibit-predicate' to prevent
1023-
inserting a \"matching\" > after a < that would be treated as a
1024-
less than sign rather than as an opening angle bracket."
1022+
"Prevent \"matching\" with a `>' when CHAR is the less-than operator.
1023+
This wraps the default defined by `electric-pair-inhibit-predicate'."
10251024
(or
10261025
(when (= ?< char)
10271026
(save-excursion
@@ -1067,7 +1066,7 @@ should be considered a paired angle bracket."
10671066
(not (looking-at "<"))))))))
10681067

10691068
(defun rust-mode-syntactic-face-function (state)
1070-
"Syntactic face function to distinguish doc comments from other comments."
1069+
"Return face which distinguishes doc and normal comments in the given syntax STATE."
10711070
(if (nth 3 state) 'font-lock-string-face
10721071
(save-excursion
10731072
(goto-char (nth 8 state))
@@ -1097,7 +1096,7 @@ should be considered a paired angle bracket."
10971096
10981097
If point is already in a raw string, this will apply the
10991098
appropriate string syntax to the character up to the end of the
1100-
raw string, or to `end', whichever comes first."
1099+
raw string, or to END, whichever comes first."
11011100
(let ((str-start (nth 8 (syntax-ppss))))
11021101
(when str-start
11031102
(when (save-excursion
@@ -1115,7 +1114,7 @@ raw string, or to `end', whichever comes first."
11151114
(goto-char (match-end 0))))))))
11161115

11171116
(defun rust-syntax-propertize (start end)
1118-
"A `syntax-propertize-function' for `rust-mode'."
1117+
"A `syntax-propertize-function' to apply properties from START to END."
11191118
(goto-char start)
11201119
(rust--syntax-propertize-raw-string end)
11211120
(funcall
@@ -1139,7 +1138,7 @@ raw string, or to `end', whichever comes first."
11391138
(point) end))
11401139

11411140
(defun rust-fill-prefix-for-comment-start (line-start)
1142-
"Determine what to use for `fill-prefix' based on what is at the beginning of a line."
1141+
"Determine what to use for `fill-prefix' based on the text at LINE-START."
11431142
(let ((result
11441143
;; Replace /* with same number of spaces
11451144
(replace-regexp-in-string
@@ -1304,7 +1303,7 @@ which calls this, does that afterwards."
13041303
With argument, do it that many times.
13051304
Negative argument -N means move back to Nth preceding end of defun.
13061305
1307-
Assume that this is called after beginning-of-defun. So point is
1306+
Assume that this is called after `beginning-of-defun'. So point is
13081307
at the beginning of the defun body.
13091308
13101309
This is written mainly to be used as `end-of-defun-function' for Rust."
@@ -1612,10 +1611,10 @@ See `compilation-error-regexp-alist' for help on their format.")
16121611

16131612
(defun rustc-scroll-down-after-next-error ()
16141613
"In the new style error messages, the regular expression
1615-
matches on the file name (which appears after `-->`), but the
1616-
start of the error appears a few lines earlier. This hook runs
1617-
after `M-x next-error`; it simply scrolls down a few lines in
1618-
the compilation window until the top of the error is visible."
1614+
matches on the file name (which appears after `-->`), but the
1615+
start of the error appears a few lines earlier. This hook runs
1616+
after `next-error' (\\[next-error]); it simply scrolls down a few lines in
1617+
the compilation window until the top of the error is visible."
16191618
(save-selected-window
16201619
(when (eq major-mode 'rust-mode)
16211620
(select-window (get-buffer-window next-error-last-buffer 'visible))
@@ -1646,8 +1645,7 @@ See `compilation-error-regexp-alist' for help on their format.")
16461645
;;; Functions to submit (parts of) buffers to the rust playpen, for
16471646
;;; sharing.
16481647
(defun rust-playpen-region (begin end)
1649-
"Create a sharable URL for the contents of the current region
1650-
on the Rust playpen."
1648+
"Create a shareable URL for the region from BEGIN to END on the Rust playpen."
16511649
(interactive "r")
16521650
(let* ((data (buffer-substring begin end))
16531651
(escaped-data (url-hexify-string data))
@@ -1672,8 +1670,7 @@ See `compilation-error-regexp-alist' for help on their format.")
16721670
(message "%s" last-line)))))))))
16731671

16741672
(defun rust-playpen-buffer ()
1675-
"Create a sharable URL for the contents of the current buffer
1676-
on the Rust playpen."
1673+
"Create a shareable URL for the contents of the buffer on the Rust playpen."
16771674
(interactive)
16781675
(rust-playpen-region (point-min) (point-max)))
16791676

0 commit comments

Comments
 (0)