@@ -41,6 +41,12 @@ This variable might soon be remove again.")
41
41
:type 'function
42
42
:group 'rust-mode )
43
43
44
+ (defvar rust-prettify-symbols-alist
45
+ '((" &&" . ?∧ ) (" ||" . ?∨ )
46
+ (" <=" . ?≤ ) (" >=" . ?≥ ) (" !=" . ?≠ )
47
+ (" INFINITY" . ?∞ ) (" ->" . ?→ ) (" =>" . ?⇒ ))
48
+ " Alist of symbol prettifications used for `prettify-symbols-alist' ." )
49
+
44
50
; ;; Customization
45
51
46
52
(defgroup rust-mode nil
@@ -204,6 +210,20 @@ Use idomenu (imenu with `ido-mode') for best mileage.")
204
210
table)
205
211
" Syntax definitions and helpers." )
206
212
213
+ ; ;; Prettify
214
+
215
+ (defun rust--prettify-symbols-compose-p (start end match )
216
+ " Return true iff the symbol MATCH should be composed.
217
+ See `prettify-symbols-compose-predicate' ."
218
+ (and (fboundp 'prettify-symbols-default-compose-p )
219
+ (prettify-symbols-default-compose-p start end match )
220
+ ; ; Make sure there is a space before || as it is also used for
221
+ ; ; functions with 0 arguments.
222
+ (not (and (string= match " ||" )
223
+ (save-excursion
224
+ (goto-char start)
225
+ (looking-back " \\ (?:\\ <move\\ |=\\ ) *" ))))))
226
+
207
227
; ;; Mode
208
228
209
229
(defvar rust-mode-map
@@ -273,6 +293,9 @@ Use idomenu (imenu with `ido-mode') for best mileage.")
273
293
(setq-local electric-pair-inhibit-predicate
274
294
'rust-electric-pair-inhibit-predicate-wrap )
275
295
(setq-local electric-pair-skip-self 'rust-electric-pair-skip-self-wrap )
296
+ ; ; Configure prettify
297
+ (setq prettify-symbols-alist rust-prettify-symbols-alist)
298
+ (setq prettify-symbols-compose-predicate #'rust--prettify-symbols-compose-p )
276
299
277
300
(add-hook 'before-save-hook rust-before-save-hook nil t )
278
301
(add-hook 'after-save-hook rust-after-save-hook nil t ))
0 commit comments