|
32 | 32 | ;;; Code: |
33 | 33 |
|
34 | 34 | (eval-when-compile |
| 35 | + (require 'hideshow) |
35 | 36 | (require 'sgml-mode) |
36 | 37 |
|
37 | 38 | (require 'mwim) |
|
83 | 84 |
|
84 | 85 | (declare-function sgml-skip-tag-forward "ext:sgml-mode.el") |
85 | 86 |
|
| 87 | +(declare-function hs-hide-block "ext:hideshow.el") |
| 88 | +(declare-function hs-show-block "ext:hideshow.el") |
| 89 | +(declare-function hs-hide-all "ext:hideshow.el") |
| 90 | +(declare-function hs-show-all "ext:hideshow.el") |
| 91 | + |
86 | 92 | ;; |
87 | 93 | ;; (@* "Entry" ) |
88 | 94 | ;; |
|
442 | 448 | (t ; Do nothing if no fold range found! |
443 | 449 | )))) |
444 | 450 |
|
445 | | -(defun vs-edit--close-node () ; internal |
| 451 | +(defun vs-edit--fold-close-node () ; internal |
446 | 452 | "Close node at the end of line, inspired from Visual Studio." |
447 | 453 | (save-excursion |
448 | 454 | (vs-edit--to-smallest-range) |
449 | 455 | (when (vs-edit--comment-p) (back-to-indentation)) |
450 | 456 | (ts-fold-close))) |
451 | 457 |
|
452 | | -(defun vs-edit--open-node () ; internal |
| 458 | +(defun vs-edit--fold-open-node () ; internal |
453 | 459 | "Open node at the end of line, inspired from Visual Studio." |
454 | 460 | (save-excursion |
455 | 461 | (vs-edit--to-smallest-range) |
|
465 | 471 | result))) |
466 | 472 |
|
467 | 473 | ;;;###autoload |
468 | | -(defun vs-edit-close-node () |
| 474 | +(defun vs-edit-fold-close () |
469 | 475 | "Close the current scope of the node." |
470 | 476 | (interactive) |
471 | | - (when-let* ((ov (or (vs-edit--close-node) (ts-fold-close))) |
| 477 | + (when-let* ((ov (or (ignore-errors (vs-edit--fold-close-node)) |
| 478 | + (ignore-errors (ts-fold-close)) |
| 479 | + (progn (require 'hideshow) |
| 480 | + (hs-hide-block)))) |
472 | 481 | (beg (overlay-start ov)) |
473 | 482 | ((< beg (point)))) |
474 | 483 | (goto-char beg))) |
475 | 484 |
|
476 | 485 | ;;;###autoload |
477 | | -(defun vs-edit-open-node () |
| 486 | +(defun vs-edit-fold-open () |
478 | 487 | "Open the current scope of the node." |
479 | 488 | (interactive) |
480 | | - (or (vs-edit--open-node) (ts-fold-open))) |
| 489 | + (or (ignore-errors (vs-edit--fold-open-node)) |
| 490 | + (ignore-errors (ts-fold-open)) |
| 491 | + (progn (require 'hideshow) |
| 492 | + (hs-show-block)))) |
| 493 | + |
| 494 | +;;;###autoload |
| 495 | +(defun vs-edit-fold-close-all () |
| 496 | + "Close all nodes in buffer." |
| 497 | + (interactive) |
| 498 | + (or (ignore-errors (ts-fold-close-all)) |
| 499 | + (progn (require 'hideshow) |
| 500 | + (hs-hide-all)))) |
| 501 | + |
| 502 | +;;;###autoload |
| 503 | +(defun vs-edit-fold-open-all () |
| 504 | + "Open all nodes in buffer." |
| 505 | + (interactive) |
| 506 | + (or (ignore-errors (ts-fold-open-all)) |
| 507 | + (progn (require 'hideshow) |
| 508 | + (hs-show-all)))) |
481 | 509 |
|
482 | 510 | (provide 'vs-edit-mode) |
483 | 511 | ;;; vs-edit-mode.el ends here |
0 commit comments