@@ -209,6 +209,12 @@ kill ring and C-d destructures the expression."
209
209
`merlin-allow-sit-for' is `t' ."
210
210
:group 'merlin :type 'boolean )
211
211
212
+ (defcustom merlin-construct-with-local-values nil
213
+ " If non-nil, `merlin-construct' includes values in the local environment.
214
+
215
+ Otherwise, `merlin-construct' only includes constructors."
216
+ :group 'merlin :type 'boolean )
217
+
212
218
(defalias 'merlin-find-file 'find-file-other-window
213
219
" The function called when merlin try to open a file (doesn't apply to
214
220
merlin-locate, see `merlin-locate-in-new-window' )." )
@@ -1458,19 +1464,30 @@ strictly within, or nil if there is no such element."
1458
1464
(`(, result ) (insert-choice result))
1459
1465
(results (insert-choice (completing-read " Constructor: " results nil t )))))))
1460
1466
1461
- (defun merlin--construct-point (point )
1462
- " Execute a construct at POINT."
1467
+ (defun merlin--construct-point (with-local-values point )
1468
+ " Execute a construct at POINT.
1469
+
1470
+ If WITH-LOCAL-VALUES is non-nil, pass \" -with-values local\" to
1471
+ include local values in the candidate list."
1463
1472
(when-let ((result (merlin-call " construct"
1464
- " -position" (merlin-unmake-point point))))
1473
+ " -position" (merlin-unmake-point point)
1474
+ " -with-values"
1475
+ (if (or with-local-values merlin-construct-with-local-values)
1476
+ " local"
1477
+ " null" ))))
1465
1478
(let* ((loc (car result))
1466
1479
(start (cdr (assoc 'start loc)))
1467
1480
(stop (cdr (assoc 'end loc))))
1468
1481
(merlin--construct-complete start stop (cadr result)))))
1469
1482
1470
- (defun merlin-construct ()
1471
- " Construct over the current hole."
1472
- (interactive )
1473
- (merlin--construct-point (point )))
1483
+ (defun merlin-construct (&optional arg )
1484
+ " Construct over the current hole.
1485
+
1486
+ With prefix ARG, include local values and not just constructors.
1487
+ This is like temporarily setting
1488
+ `merlin-construct-with-local-values' non-nil."
1489
+ (interactive " P" )
1490
+ (merlin--construct-point arg (point )))
1474
1491
1475
1492
1476
1493
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0 commit comments