emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole c05d22c 8/8: For automated testing, let kotl-


From: ELPA Syncer
Subject: [elpa] externals/hyperbole c05d22c 8/8: For automated testing, let kotl-mode:example use alternative dirs
Date: Tue, 18 May 2021 23:57:14 -0400 (EDT)

branch: externals/hyperbole
commit c05d22cedd89e7023d010d610f8fdce24bf6930d
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    For automated testing, let kotl-mode:example use alternative dirs
---
 ChangeLog               | 12 ++++++++++++
 kotl/kotl-mode.el       | 50 ++++++++++++++++++++++++++++++++++++-------------
 test/kotl-mode-tests.el |  4 ++--
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 193e3f3..36d1f28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2021-05-18  Bob Weiner  <rsw@gnu.org>
 
+
+* kotl/kotl-mode.el (kotl-mode:example): Update to allow for
+    an optional directory or absolute file path.  Prompt for
+    the path when interactive and given a prefix argument,
+    archive any existing file and start with a fresh EXAMPLE.kotl
+    file.  Programmatically, give a 2nd arg of t to force
+    archiving of any existing file and starting with a fresh
+    EXAMPLE.kotl file.
+  test/kotl-mode-tests.el (kotl-mode-move-between-cells,
+                           kotl-mode-indent-cell-changes-level):
+    Update to use new kotl-mode:example arguments.
+
 * hrmail.el (rmail:msg-to-p): Alias to Rmail-msg-to-p for use in
     in hactypes.el.
             (require 'hvar): Add, used in Rmail-init.
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index f9ea587..722cbcb 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -16,9 +16,8 @@
 ;;; Other required Lisp Libraries
 ;;; ************************************************************************
 
-(eval-and-compile (mapc #'require '(cl-lib delsel hsettings hmail kfile kvspec 
kcell outline org-table kotl-orgtbl)))
-
-(require 'hypb)
+(eval-and-compile (mapc #'require '(cl-lib delsel hsettings hmail hypb kfile
+                                   kvspec kcell outline org-table 
kotl-orgtbl)))
 
 ;;; ************************************************************************
 ;;; Public variables
@@ -186,15 +185,41 @@ It provides the following keys:
   (add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t))
 
 ;;;###autoload
-(defun kotl-mode:example ()
-  "Display the Koutliner example file for demonstration use by a user."
-  (interactive)
-  (let* ((example "EXAMPLE.kotl")
-        (personal-example (expand-file-name example "~/"))
-        (original-example (expand-file-name example (concat hyperb:dir 
"kotl/"))))
-    (when (file-newer-than-file-p original-example personal-example)
+(defun kotl-mode:example (&optional example replace-flag)
+  "Display the optional Koutliner EXAMPLE file for demonstration and editing 
use by a user.
+With optional REPLACE-FLAG non-nil, archive any existing file,
+and replace it with the latest Hyperbole EXAMPLE.
+
+EXAMPLE may be a file or directory name (\"EXAMPLE.kotl\" is appended).
+
+If EXAMPLE is omitted or nil, create or edit the \"~/EXAMPLE.kotl\" file.
+
+When called interactively, prompt for EXAMPLE if given a prefix
+argument, archive any existing file, and replace it with the latest
+Hyperbole EXAMPLE."
+  (interactive
+   (list (when current-prefix-arg
+          (read-file-name "Path to replace and save EXAMPLE.kotl file: "
+                          nil nil nil "EXAMPLE.kotl"))))
+  (when (and current-prefix-arg (called-interactively-p 'interactive))
+    (setq replace-flag t))
+  (let (personal-example
+       original-example)
+    (unless (stringp example)
+      (setq example "EXAMPLE.kotl"))
+    (when (file-directory-p example)
+      (setq personal-example (expand-file-name "EXAMPLE.kotl" example )
+           example "EXAMPLE.kotl"))
+    (unless personal-example
+      (if (file-name-absolute-p example)
+         (setq personal-example example
+               example (file-name-nondirectory example))
+       (setq personal-example (expand-file-name example "~/"))))
+    (setq original-example (expand-file-name example (expand-file-name "kotl/" 
hyperb:dir)))
+    (when (or replace-flag
+             (file-newer-than-file-p original-example personal-example))
       (when (file-exists-p personal-example)
-       ;; save it and use the original example file
+       ;; Save personally edited one and use the newer Hyperbole Example file
        (rename-file personal-example (expand-file-name (concat "SAVED-" 
example) "~/") t)))
     (cond ((get-file-buffer personal-example)
           (switch-to-buffer (get-file-buffer personal-example)))
@@ -206,8 +231,7 @@ It provides the following keys:
                   default-directory (expand-file-name "~/")
                   buffer-auto-save-file-name nil
                   buffer-read-only nil)
-            (insert-file-contents
-             (expand-file-name example (concat hyperb:dir "kotl/")))
+            (insert-file-contents original-example)
             (goto-char (point-min))
             (kotl-mode)
             (save-buffer)))))
diff --git a/test/kotl-mode-tests.el b/test/kotl-mode-tests.el
index 5ce7658..ddbe7be 100644
--- a/test/kotl-mode-tests.el
+++ b/test/kotl-mode-tests.el
@@ -50,7 +50,7 @@
   "Loading kotl-mode example file works."
   (setup-kotl-mode-example-test
    ;; Start in first cell
-   (kotl-mode:example)
+   (kotl-mode:example temporary-file-directory t)
    (should (kotl-mode:first-cell-p))
 
    ;; Move to next cell
@@ -70,7 +70,7 @@
   "Loading kotl-mode example file works."
   (skip-unless (not noninteractive))
   (setup-kotl-mode-example-test
-   (kotl-mode:example)
+   (kotl-mode:example temporary-file-directory t)
    (should (kotl-mode:first-cell-p))
    (kotl-mode:next-cell 1)
    (should (hact 'kbd-key "TAB"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]