@@ -1429,30 +1429,51 @@ Symlinks are not followed."
1429
1429
1430
1430
;; compat
1431
1431
(if (version< emacs-version "29.1")
1432
- ;; Undo macro probably introduced in 29.1
1433
- (defmacro lsp-with-undo-amalgamate (&rest body)
1434
- "Like `progn' but perform BODY with amalgamated undo barriers.
1432
+ (progn
1433
+ ;; Undo macro probably introduced in 29.1
1434
+ (defmacro lsp-with-undo-amalgamate (&rest body)
1435
+ "Like `progn' but perform BODY with amalgamated undo barriers.
1435
1436
1436
1437
This allows multiple operations to be undone in a single step.
1437
1438
When undo is disabled this behaves like `progn'."
1438
- (declare (indent 0) (debug t))
1439
- (let ((handle (make-symbol "--change-group-handle--")))
1440
- `(let ((,handle (prepare-change-group))
1441
- ;; Don't truncate any undo data in the middle of this,
1442
- ;; otherwise Emacs might truncate part of the resulting
1443
- ;; undo step: we want to mimic the behavior we'd get if the
1444
- ;; undo-boundaries were never added in the first place.
1445
- (undo-outer-limit nil)
1446
- (undo-limit most-positive-fixnum)
1447
- (undo-strong-limit most-positive-fixnum))
1448
- (unwind-protect
1439
+ (declare (indent 0) (debug t))
1440
+ (let ((handle (make-symbol "--change-group-handle--")))
1441
+ `(let ((,handle (prepare-change-group))
1442
+ ;; Don't truncate any undo data in the middle of this,
1443
+ ;; otherwise Emacs might truncate part of the resulting
1444
+ ;; undo step: we want to mimic the behavior we'd get if the
1445
+ ;; undo-boundaries were never added in the first place.
1446
+ (undo-outer-limit nil)
1447
+ (undo-limit most-positive-fixnum)
1448
+ (undo-strong-limit most-positive-fixnum))
1449
+ (unwind-protect
1450
+ (progn
1451
+ (activate-change-group ,handle)
1452
+ ,@body)
1449
1453
(progn
1450
- (activate-change-group ,handle)
1451
- ,@body)
1454
+ (accept-change-group ,handle)
1455
+ (undo-amalgamate-change-group ,handle))))))
1456
+
1457
+ ;; delete-all-space function introduced in 29
1458
+ (defun lsp-delete-all-space (&optional backward-only)
1459
+ "Delete all spaces, tabs, and newlines around point.
1460
+ If BACKWARD-ONLY is non-nil, delete them only before point."
1461
+ (interactive "*P")
1462
+ (let ((chars " \t\r\n")
1463
+ (orig-pos (point)))
1464
+ (delete-region
1465
+ (if backward-only
1466
+ orig-pos
1452
1467
(progn
1453
- (accept-change-group ,handle)
1454
- (undo-amalgamate-change-group ,handle))))))
1455
- (defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate))
1468
+ (skip-chars-forward chars)
1469
+ (constrain-to-field nil orig-pos t)))
1470
+ (progn
1471
+ (skip-chars-backward chars)
1472
+ (constrain-to-field nil orig-pos))))))
1473
+ ;;29.1+
1474
+ (defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate)
1475
+ (defalias 'lsp-delete-all-space 'delete-all-space))
1476
+
1456
1477
1457
1478
(defun lsp--merge-results (results method)
1458
1479
"Merge RESULTS by filtering the empty hash-tables and merging
0 commit comments