@@ -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
@@ -209,6 +215,20 @@ Use idomenu (imenu with `ido-mode') for best mileage.")
209
215
table)
210
216
" Syntax definitions and helpers." )
211
217
218
+ ; ;; Prettify
219
+
220
+ (defun rust--prettify-symbols-compose-p (start end match )
221
+ " Return true iff the symbol MATCH should be composed.
222
+ See `prettify-symbols-compose-predicate' ."
223
+ (and (fboundp 'prettify-symbols-default-compose-p )
224
+ (prettify-symbols-default-compose-p start end match )
225
+ ; ; Make sure there is a space before || as it is also used for
226
+ ; ; functions with 0 arguments.
227
+ (not (and (string= match " ||" )
228
+ (save-excursion
229
+ (goto-char start)
230
+ (looking-back " \\ (?:\\ <move\\ |=\\ ) *" ))))))
231
+
212
232
; ;; Mode
213
233
214
234
(defvar rust-mode-map
@@ -278,6 +298,9 @@ Use idomenu (imenu with `ido-mode') for best mileage.")
278
298
(setq-local electric-pair-inhibit-predicate
279
299
'rust-electric-pair-inhibit-predicate-wrap )
280
300
(setq-local electric-pair-skip-self 'rust-electric-pair-skip-self-wrap )
301
+ ; ; Configure prettify
302
+ (setq prettify-symbols-alist rust-prettify-symbols-alist)
303
+ (setq prettify-symbols-compose-predicate #'rust--prettify-symbols-compose-p )
281
304
282
305
(add-hook 'before-save-hook rust-before-save-hook nil t )
283
306
(add-hook 'after-save-hook rust-after-save-hook nil t ))
0 commit comments