|
3 | 3 | ;; Author: Mats Lidell <[email protected]>
|
4 | 4 | ;;
|
5 | 5 | ;; Orig-Date: 30-Jan-21 at 12:00:00
|
6 |
| -;; Last-Mod: 22-Oct-23 at 15:25:05 by Mats Lidell |
| 6 | +;; Last-Mod: 24-Oct-23 at 23:57:30 by Mats Lidell |
7 | 7 | ;;
|
8 | 8 | ;; SPDX-License-Identifier: GPL-3.0-or-later
|
9 | 9 | ;;
|
@@ -771,6 +771,59 @@ With point on label suggest that ibut for rename."
|
771 | 771 | (goto-char (point-min))
|
772 | 772 | (should (looking-at-p "<(new)><(new)>"))))
|
773 | 773 |
|
| 774 | +(ert-deftest hui--ibut-link-directly-to-file () |
| 775 | + "Create a direct link to a file." |
| 776 | + (let ((filea (make-temp-file "hypb" nil ".txt")) |
| 777 | + (fileb (make-temp-file "hypb" nil ".txt" "1234567890"))) |
| 778 | + (unwind-protect |
| 779 | + (progn |
| 780 | + (delete-other-windows) |
| 781 | + (find-file fileb) |
| 782 | + (goto-char (point-max)) |
| 783 | + (split-window) |
| 784 | + (find-file filea) |
| 785 | + (hui:ibut-link-directly (get-buffer-window) |
| 786 | + (get-buffer-window (get-file-buffer fileb))) |
| 787 | + (should (string= (buffer-string) (concat "\"" fileb ":1:10\"")))) |
| 788 | + (hy-delete-file-and-buffer filea) |
| 789 | + (hy-delete-file-and-buffer fileb)))) |
| 790 | + |
| 791 | +(ert-deftest hui--ibut-link-directly-to-dired () |
| 792 | + "Create a direct link to a directory in dired." |
| 793 | + :expected-result :failed |
| 794 | + (let* ((file (make-temp-file "hypb" nil ".txt")) |
| 795 | + (dir (file-name-parent-directory file)) |
| 796 | + dir-buf) |
| 797 | + (unwind-protect |
| 798 | + (progn |
| 799 | + (delete-other-windows) |
| 800 | + (setq dir-buf (dired dir)) |
| 801 | + (split-window) |
| 802 | + (find-file file) |
| 803 | + (hui:ibut-link-directly (get-buffer-window) (get-buffer-window dir-buf)) |
| 804 | + ;; Was expecting here an ibut "/tmp" but <link-to-directory |
| 805 | + ;; /tmp> could be possible too. Seems a link to the file the |
| 806 | + ;; point in the dired buffer is on!? Is that expected? |
| 807 | + (should (string= (buffer-string) (concat "\"" dir "\"")))) |
| 808 | + (hy-delete-file-and-buffer file)))) |
| 809 | + |
| 810 | +(ert-deftest hui--ibut-link-directly-with-label () |
| 811 | + "Create a direct link with a label." |
| 812 | + (let ((filea (make-temp-file "hypb" nil ".txt")) |
| 813 | + (fileb (make-temp-file "hypb" nil ".txt" "1234567890"))) |
| 814 | + (unwind-protect |
| 815 | + (progn |
| 816 | + (delete-other-windows) |
| 817 | + (find-file fileb) |
| 818 | + (goto-char (point-max)) |
| 819 | + (split-window) |
| 820 | + (find-file filea) |
| 821 | + (with-simulated-input "label RET" |
| 822 | + (hui:ibut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb)) 4)) |
| 823 | + (should (string= (buffer-string) (concat "<[label]> - " "\"" fileb ":1:10\"")))) |
| 824 | + (hy-delete-file-and-buffer filea) |
| 825 | + (hy-delete-file-and-buffer fileb)))) |
| 826 | + |
774 | 827 | ;; This file can't be byte-compiled without `with-simulated-input' which
|
775 | 828 | ;; is not part of the actual dependencies, so:
|
776 | 829 | ;; Local Variables:
|
|
0 commit comments