branch: externals/hyperbole commit 5eb0c2808698e96324bb362622bbada404e7df4f Merge: 7f6fa36 b9017c7 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Merge branch 'master' of hyperbole --- ChangeLog | 19 +++++++ Makefile | 3 +- kotl/kotl-mode.el | 2 +- test/kexport-tests.el | 143 ++++++++++++++++++++++++++++++++++++++++++++++++ test/kotl-mode-tests.el | 15 +++++ 5 files changed, 180 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dccc360..b1dee73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +<<<<<<< HEAD 2021-10-17 Bob Weiner <r...@gnu.org> * hpath.el (hpath:symlink-referent): Fix handling of relative symlinks, adding @@ -14,6 +15,18 @@ HY-NEWS (HYROLO): man/hyperbole.texi (HyRolo Menu): Add hyrolo-find-file manual doc. +2021-10-10 Mats Lidell <ma...@gnu.org> + +* test/kexport-tests.el (kexport:html-creates-html-file) + (kexport:html-sets-title-and-header, kexport:html-contains-each-cell) + (kexport:html-creates-hierarchy) + (kexport:display-creates-html-file-and-displayes-it) + (kexport:buffer-calls-kexport:html): Add kexport tests. + +2021-09-26 Mats Lidell <ma...@gnu.org> + +* Makefile (bin): Hide docstring warnings. + 2021-09-26 Robert Weiner <b...@bka-imac.lan> * hbut.el (ebut:operate): Rewrote to handle label modification properly and thereby @@ -42,6 +55,12 @@ * Makefile (bin-warn): Control what warning messages to get when byte compiling. +2021-09-18 Mats Lidell <ma...@gnu.org> + +* kotl/kotl-mode.el (kotl-mode:split-cell): Create new plist for split cell. + +* test/kotl-mode-tests.el (kotl-mode-split-cell): Add test for split-cell + 2021-09-14 Mats Lidell <ma...@gnu.org> * hbut.el (defib, defil, defal): Use declare notation for making macros diff --git a/Makefile b/Makefile index 87d8793..ee7e05e 100644 --- a/Makefile +++ b/Makefile @@ -264,7 +264,8 @@ src: autoloads tags # which do not yet exist, plus build TAGS file. bin: src $(RM) *.elc kotl/*.elc - $(EMACS) $(BATCHFLAGS) $(PRELOADS) -f batch-byte-compile $(EL_KOTL) $(EL_COMPILE) + $(EMACS) $(BATCHFLAGS) $(PRELOADS) --eval="(setq-default byte-compile-warnings '(not docstrings))" \ + -f batch-byte-compile $(EL_KOTL) $(EL_COMPILE) # Byte compile files but apply a filter for either including or # removing warnings. See variable {C-hv byte-compile-warnings RET} for diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el index 8bdd988..22ce277 100644 --- a/kotl/kotl-mode.el +++ b/kotl/kotl-mode.el @@ -2545,7 +2545,7 @@ the current cell." ;; delete any preceding whitespace (skip-chars-backward " \t\n\r" start) (delete-region (max start (point)) (kcell-view:end-contents)) - (kotl-mode:add-cell arg new-cell-contents (kcell-view:plist)))) + (kotl-mode:add-cell arg new-cell-contents))) (defun kotl-mode:transpose-cells (arg) "Exchange current and previous visible cells, leaving point after both. diff --git a/test/kexport-tests.el b/test/kexport-tests.el new file mode 100644 index 0000000..7663037 --- /dev/null +++ b/test/kexport-tests.el @@ -0,0 +1,143 @@ +;;; kexport-tests.el --- kexport tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 Mats Lidell + +;; Author: Mats Lidell <ma...@gnu.org> +;; +;; Orig-Date: 10-Oct-21 at 17:30:00 +;; +;; Copyright (C) 2021 Free Software Foundation, Inc. +;; See the "HY-COPY" file for license information. +;; +;; This file is part of GNU Hyperbole. + +;;; Commentary: + +;; Tests for kexport in "../kotl/kexport.el" + +;;; Code: + +(require 'ert) +(require 'el-mock) +(require 'kexport "kotl/kexport") + +(ert-deftest kexport:html-creates-html-file () + "kexport:html creates an output html file." + (let ((kotl-file (make-temp-file "hypb" nil ".kotl")) + (html-file (make-temp-file "hypb" nil ".html"))) + (unwind-protect + (progn + (find-file kotl-file) + (insert "first") + (kotl-mode:add-cell) + (insert "second") + (let ((auto-insert nil)) + (kexport:html kotl-file html-file)) + (should (file-exists-p html-file))) + (progn + (delete-file kotl-file) + (delete-file html-file))))) + +(ert-deftest kexport:html-sets-title-and-header () + "kexport:html set title and header from first cell." + (let ((kotl-file (make-temp-file "hypb" nil ".kotl")) + (html-file (make-temp-file "hypb" nil ".html"))) + (unwind-protect + (progn + (find-file kotl-file) + (insert "first") + (kotl-mode:add-cell) + (insert "second") + (let ((auto-insert nil)) + (kexport:html kotl-file html-file)) + (find-file html-file) + (goto-char (point-min)) + (re-search-forward "<title>first</title>") + (re-search-forward "<h1>first</h1>")) + (progn + (delete-file kotl-file) + (delete-file html-file))))) + +(ert-deftest kexport:html-contains-each-cell () + "kexport:html contains each cell." + (let ((kotl-file (make-temp-file "hypb" nil ".kotl")) + (html-file (make-temp-file "hypb" nil ".html"))) + (unwind-protect + (progn + (find-file kotl-file) + (insert "first") + (kotl-mode:add-cell) + (insert "second") + (let ((auto-insert nil)) + (kexport:html kotl-file html-file)) + (find-file html-file) + (goto-char (point-min)) + (re-search-forward "<pre>first</pre>") + (re-search-forward "<pre>second</pre>")) + (progn + (delete-file kotl-file) + (delete-file html-file))))) + +(ert-deftest kexport:html-creates-hierarchy () + "kexport:html exports cells in a hierachy." + (let ((kotl-file (make-temp-file "hypb" nil ".kotl")) + (html-file (make-temp-file "hypb" nil ".html"))) + (unwind-protect + (progn + (find-file kotl-file) + (insert "first") + (kotl-mode:add-child) + (insert "second") + (kotl-mode:add-child) + (insert "third") + (let ((auto-insert nil)) + (kexport:html kotl-file html-file)) + (find-file html-file) + (goto-char (point-min)) + (re-search-forward "<pre>.*1\\. .*</pre>") + (re-search-forward "<pre>first</pre>") + (re-search-forward "<pre>.*1a\\. .*</pre>") + (re-search-forward "<pre>second</pre>") + (re-search-forward "<pre>.*1a1\\. .*</pre>") + (re-search-forward "<pre>third</pre>")) + (progn + (delete-file kotl-file) + (delete-file html-file))))) + +(ert-deftest kexport:display-creates-html-file-and-displayes-it () + "kexport:display creates html file and displays it in external browser." + (let* ((kotl-file (make-temp-file "hypb" nil ".kotl")) + (html-file (concat (file-name-sans-extension kotl-file) ".html")) + (browse-url-browser-function + `(lambda (url &rest _args) + (should (string= url (concat "file://" ',html-file))))) + (auto-insert nil)) + (unwind-protect + (progn + (find-file kotl-file) + (insert "first") + (kotl-mode:add-cell) + (insert "second") + (should (string= (kexport:display) html-file))) + (progn + (delete-file kotl-file) + (delete-file html-file))))) + +(ert-deftest kexport:buffer-calls-kexport:html () + "kexport:buffer calls kexport:html and returns html buffer name." + (let* ((kotl-file (make-temp-file "hypb")) + (html-file (concat kotl-file ".html"))) + (unwind-protect + (cl-letf (((symbol-function 'kexport:html) + (lambda (export-from output-to &optional soft-newlines-flag) + (should (string= export-from kotl-file)) + (should (string= output-to html-file)) + (should (equal soft-newlines-flag nil)) + nil))) + (find-file kotl-file) + (should (string= (kexport:buffer) html-file))) + (progn + (delete-file kotl-file))))) + +(provide 'kexport-tests) +;;; kexport-tests.el ends here diff --git a/test/kotl-mode-tests.el b/test/kotl-mode-tests.el index 9b4b0f6..b906b75 100644 --- a/test/kotl-mode-tests.el +++ b/test/kotl-mode-tests.el @@ -307,6 +307,21 @@ (should (looking-at-p "$"))) (delete-file kotl-file)))) +(ert-deftest kotl-mode-split-cell () + "Kotl-mode split cell." + (let ((kotl-file (make-temp-file "hypb" nil ".kotl"))) + (unwind-protect + (progn + (find-file kotl-file) + (insert "firstsecond\n") + (backward-char 7) + (kotl-mode:split-cell) + (should (string= (kcell-view:label (point)) "2")) + (kotl-mode:demote-tree 0) + (should (string= (kcell-view:label (point)) "1a")) + (should (string= (kcell-view:idstamp) "02"))) + (delete-file kotl-file)))) + (provide 'kotl-mode-tests) ;;; kotl-mode-tests.el ends here