[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole a3ab2c7 2/3: Merge Mats 'master' updates of h
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole a3ab2c7 2/3: Merge Mats 'master' updates of hyperbole |
Date: |
Sun, 7 Nov 2021 23:57:31 -0500 (EST) |
branch: externals/hyperbole
commit a3ab2c769f3f5f10c5139b481264e5b57e68c0dd
Merge: c5b0ffe b4a4ef4
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Merge Mats 'master' updates of hyperbole
---
ChangeLog | 37 ++++++++++++++++++++++++
hargs.el | 4 +--
hbut.el | 4 +--
hsmail.el | 4 +--
hui.el | 8 ++---
hypb.el | 6 ----
kotl/kotl-mode.el | 25 ++++++++++++----
test/kotl-mode-tests.el | 74 +++++++++++++++++++++++++++++++++++++++++++++--
test/kotl-orgtbl-tests.el | 54 ++++++++++++++++++++++++++++++++++
9 files changed, 192 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 95ee23a..4871e3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,29 @@
* hui-window.el (hmouse-x-coord, hmouse-y-coord): Pass 'args' lexically rather
than dynamically, thereby, fixing action key error of unbound argument
+2021-11-05 Mats Lidell <matsl@gnu.org>
+
+* test/kotl-mode-tests.el (smart-menu-loads-kotl-example): Add extra no op
+ input char to make test case stable.
+
+* hypb.el (hypb:mark-marker): Remove compatibility function, use plain
+ mark-marker instead.
+
+* kotl/kotl-mode.el (kotl-mode:transpose-lines, kotl-mode:yank-pop)
+ (kotl-mode:exchange-point-and-mark, kotl-mode:transpose-lines-internal):
+ hui.el (hui:ebut-create, hui:ebut-edit):
+ hsmail.el (mail-yank-original):
+ hbut.el (ebut:operate):
+ hargs.el (hargs:iforms): Use mark-marker.
+
+2021-11-02 Mats Lidell <matsl@gnu.org>
+
+* test/kotl-orgtbl-tests.el
+ (kotl-orgtbl-enabled-uses-kotl-mode-delete-char-ouside-of-table):
+ Add test for C-d binding in orgtbl.
+
+* kotl/kotl-mode.el (kotl-mode): Add orgtbl-mode-map binding for C-d.
+
2021-10-31 Bob Weiner <rsw@gnu.org>
* hactypes.el (link-to-ibut): Remove requirement that implicit button linked to
@@ -51,6 +74,20 @@
(ebut:operate): Add save-restriction around ebut:modify and
ebut:create
calls.
+2021-10-31 Mats Lidell <matsl@gnu.org>
+
+* test/kotl-mode-tests.el (kotl-mode-previous-cell-from-invalid-position)
+ (kotl-mode-backward-cell-from-invalid-position)
+ (kotl-mode-backward-cell-from-invalid-pos-leave-point-in-valid-pos):
+ Test cases for invalid start position before moving backwards.
+
+* kotl/kotl-mode.el (kotl-mode:previous-cell, kotl-mode:backward-cell):
+ Handle case when start pos is invalid.
+
+2021-10-26 Mats Lidell <matsl@gnu.org>
+
+* hui.el (hui:link-directly): Use use-region-p for active region.
+
2021-10-24 Bob Weiner <rsw@gnu.org>
* hmouse-drv.el (mouse-drag-mode-line): Remove XEmacs 'mouse-drag-frame-move'
diff --git a/hargs.el b/hargs.el
index 0e08d14..ddf100f 100644
--- a/hargs.el
+++ b/hargs.el
@@ -727,7 +727,7 @@ help when appropriate."
prompt)
nil t))))
;; Get value of mark. Does not do I/O.
- (?m . (integer . (marker-position (hypb:mark-marker t))))
+ (?m . (integer . (marker-position (mark-marker))))
;; Get numeric prefix argument or a number from the minibuffer.
(?N . (integer .
(if prefix-arg
@@ -751,7 +751,7 @@ help when appropriate."
(?P . (prefix-arg . prefix-arg))
;; Get region, point and mark as 2 args. No I/O
(?r . (region .
- (if (marker-position (hypb:mark-marker t))
+ (if (marker-position (mark-marker))
(list 'args (min (point) (hypb:mark t))
(max (point) (hypb:mark t)))
(list 'args nil nil))))
diff --git a/hbut.el b/hbut.el
index a03d9e1..db9eae1 100644
--- a/hbut.el
+++ b/hbut.el
@@ -356,13 +356,13 @@ button is found in the current buffer."
hui:ebut-modify hui:gbut-create
hui:gbut-modify
hui:link-create ebut:program))
;; Ignore action-key-depress-prev-point
- (progn (setq mark (marker-position
(hypb:mark-marker t))
+ (progn (setq mark (marker-position (mark-marker))
start (region-beginning)
end (region-end)
buf-lbl
(buffer-substring-no-properties start end))
(equal buf-lbl curr-label))
;; Utilize any action-key-depress-prev-point
- (progn (setq mark (marker-position (hypb:mark-marker
t)))
+ (progn (setq mark (marker-position (mark-marker)))
(setq prev-point (and
action-key-depress-prev-point
(marker-position
action-key-depress-prev-point)))
(setq start (if (and prev-point mark (<=
prev-point mark))
diff --git a/hsmail.el b/hsmail.el
index 24c6e29..8db2230 100644
--- a/hsmail.el
+++ b/hsmail.el
@@ -184,7 +184,7 @@ Use (setq sc-nuke-mail-headers 'all) to have them removed."
;; the removal.
(or (hypb:supercite-p)
(mail-yank-clear-headers
- start (marker-position (hypb:mark-marker t))))
+ start (marker-position (mark-marker))))
(goto-char start)
(let ((mail-indentation-spaces (if arg (prefix-numeric-value
arg)
mail-indentation-spaces))
@@ -220,7 +220,7 @@ Use (setq sc-nuke-mail-headers 'all) to have them removed."
;; It is cleaner to avoid activation, even though the command
;; loop would deactivate the mark because we inserted text.
(goto-char (prog1 (hypb:mark t)
- (set-marker (hypb:mark-marker t)
+ (set-marker (mark-marker)
(point) (current-buffer))))
(if (not (eolp)) (insert ?\n))))
(with-current-buffer mail-reply-buffer
diff --git a/hui.el b/hui.el
index d587eb2..82cf5ad 100644
--- a/hui.el
+++ b/hui.el
@@ -120,9 +120,9 @@ Default is the current button."
Indicate button creation by delimiting and adding any necessary instance
number to the button label.
For programmatic creation, use `ebut:program' instead."
- (interactive (list (and (marker-position (hypb:mark-marker t))
+ (interactive (list (and (marker-position (mark-marker))
(region-beginning))
- (and (marker-position (hypb:mark-marker t))
+ (and (marker-position (mark-marker))
(region-end))))
(let ((default-lbl) lbl but-buf actype)
(save-excursion
@@ -179,7 +179,7 @@ be entirely within or entirely outside of an existing
explicit button. When
region is within the button, the button is interactively modified. Otherwise,
a new button is created interactively with the region as the default label."
(interactive)
- (let ((m (marker-position (hypb:mark-marker t)))
+ (let ((m (marker-position (mark-marker)))
(op action-key-depress-prev-point) (p (point)) (lbl-key))
(if (and m (eq (marker-buffer m) (marker-buffer op))
(< op m) (<= (- m op) (hbut:max-len))
@@ -752,7 +752,7 @@ See also documentation for `hui:link-possible-types'."
(hui:hbut-label
(cond ((hmouse-prior-active-region)
hkey-region)
- ((marker-position (hypb:mark-marker t))
+ ((use-region-p)
(hui:hbut-label-default
(region-beginning) (region-end))))
"link-directly"
diff --git a/hypb.el b/hypb.el
index ee18ee8..40f0147 100644
--- a/hypb.el
+++ b/hypb.el
@@ -514,12 +514,6 @@ then `locate-post-command-hook'."
(defalias 'hypb:mark #'mark)
-(defun hypb:mark-marker (inactive-p)
- "Return this buffer's mark as a marker object, or nil if no mark.
-INACTIVE-P is unused, it is for compatibility with XEmacs' version of
-`mark-marker'."
- (mark-marker))
-
;;;###autoload
(defun hypb:map-plist (func plist)
"Return result of applying FUNC of two args, key and value, to key-value
pairs in PLIST, a property list."
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index d64c3ab..e56611b 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -181,6 +181,9 @@ It provides the following keys:
(org-defkey orgtbl-mode-map [(meta return)]
(orgtbl-make-binding 'orgtbl-meta-return 106
[(meta return)] "\M-\C-m"))
+ (org-defkey orgtbl-mode-map "\C-d"
+ (orgtbl-make-binding 'kotl-mode:delete-char 107
+ "\C-d"))
(run-hooks 'kotl-mode-hook)
(add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t))
@@ -892,7 +895,7 @@ that contains mark."
;; Transpose point and mark lines, leaving point on the line of text that
;; originally contained point.
((= arg 0)
- (kotl-mode:transpose-lines-internal (point-marker) (hypb:mark-marker t))
+ (kotl-mode:transpose-lines-internal (point-marker) (mark-marker))
(kotl-mode:exchange-point-and-mark))
;;
;; Move previous line past ARG next lines and leave point after previous
@@ -1328,7 +1331,7 @@ doc string for `insert-for-yank-1', which see."
(if before
(funcall (or yank-undo-function 'delete-region) (point) (mark t))
(funcall (or yank-undo-function 'delete-region) (mark t) (point)))
- (set-marker (hypb:mark-marker t) (point) (current-buffer))
+ (set-marker (mark-marker) (point) (current-buffer))
(let* ((yank-text (current-kill arg))
(indent (kcell-view:indent))
(indent-str (make-string indent ?\ )))
@@ -1365,6 +1368,12 @@ Return number of cells left to move."
(kotl-mode:forward-cell (- arg))
(let ((prior (= arg 0))
(label-sep-len (kview:label-separator-length kview)))
+ (when (not (kview:valid-position-p))
+ (progn
+ (kotl-mode:to-valid-position t)
+ (kotl-mode:beginning-of-cell)
+ (setq arg (1- arg))
+ (setq prior t)))
(while (and (> arg 0) (setq prior (kcell-view:backward t label-sep-len)))
(setq arg (1- arg)))
(if (or prior (not (called-interactively-p 'interactive)))
@@ -1902,6 +1911,12 @@ Return non-nil iff there is a next tree within this
koutline."
(kotl-mode:next-cell (- arg))
(let ((previous (= arg 0))
(label-sep-len (kview:label-separator-length kview)))
+ (when (not (kview:valid-position-p))
+ (progn
+ (kotl-mode:to-valid-position t)
+ (kotl-mode:beginning-of-cell)
+ (setq arg (1- arg))
+ (setq previous t)))
(while (and (> arg 0) (setq previous
(kcell-view:previous t label-sep-len)))
(setq arg (1- arg)))
@@ -2847,7 +2862,7 @@ Does not delete newline at end of line."
"Put the mark where point is now, and point where the mark is now.
This is like `exchange-point-and-mark', but doesn't activate the mark."
(goto-char (prog1 (hypb:mark t)
- (set-marker (hypb:mark-marker t) (point) (current-buffer)))))
+ (set-marker (mark-marker) (point) (current-buffer)))))
(defun kotl-mode:indent-line (&optional arg)
"Indent line relative to the previous one.
@@ -3098,10 +3113,10 @@ Leave point at end of line now residing at START."
;; Set non-point and non-mark markers to point nowhere before signalling
;; an error.
(or (eq start (point-marker))
- (eq start (hypb:mark-marker t))
+ (eq start (mark-marker))
(set-marker start nil))
(or (eq end (point-marker))
- (eq end (hypb:mark-marker t))
+ (eq end (mark-marker))
(set-marker start nil))
(error "(kotl-mode:transpose-lines): Point or mark is at an invalid
position")))
diff --git a/test/kotl-mode-tests.el b/test/kotl-mode-tests.el
index b906b75..ea27e5d 100644
--- a/test/kotl-mode-tests.el
+++ b/test/kotl-mode-tests.el
@@ -38,7 +38,9 @@
"Loading kotl-mode example file works."
(skip-unless (not noninteractive))
(setup-kotl-mode-example-test
- (should (hact 'kbd-key "C-h h k e"))
+ ;; The additional no op key C-a below avoids ert results window to
+ ;; be set as current
+ (should (hact 'kbd-key "C-h h k e C-a"))
(hy-test-helpers:consume-input-events)))
(ert-deftest kotl-mode-example-loads-kotl-example ()
@@ -322,8 +324,74 @@
(should (string= (kcell-view:idstamp) "02")))
(delete-file kotl-file))))
-(provide 'kotl-mode-tests)
-;;; kotl-mode-tests.el ends here
+(ert-deftest kotl-mode-previous-cell-from-invalid-position ()
+ "When in an invalid position previous cell should move back to first valid
cell."
+ (let ((kotl-file (make-temp-file "hypb" nil ".kotl")))
+ (unwind-protect
+ (progn
+ (find-file kotl-file)
+ (insert "1")
+ (kotl-mode:add-cell)
+ (insert "2")
+ (kotl-mode:add-cell)
+ (insert "3")
+ (kotl-mode:previous-cell 1)
+ (kotl-mode:end-of-cell)
+ (goto-char (1+ (point)))
+ (should-not (kview:valid-position-p))
+ (kotl-mode:previous-cell 1)
+ (should (string= (kcell-view:label (point)) "2")))
+ (delete-file kotl-file))))
+
+(ert-deftest kotl-mode-backward-cell-from-invalid-position ()
+ "When in an invalid position backward cell should move back to first valid
cell."
+ (let ((kotl-file (make-temp-file "hypb" nil ".kotl")))
+ (unwind-protect
+ (progn
+ (find-file kotl-file)
+ (insert "1")
+ (kotl-mode:add-child)
+ (insert "1a")
+ (kotl-mode:add-parent)
+ (insert "2")
+ (kotl-mode:previous-cell 1)
+ (kotl-mode:end-of-cell)
+ (goto-char (1+ (point)))
+ (should-not (kview:valid-position-p))
+
+ (kotl-mode:backward-cell 1)
+ (should (string= (kcell-view:label (point)) "1a")))
+ (delete-file kotl-file))))
+
+(ert-deftest kotl-mode-backward-cell-from-invalid-pos-leave-point-in-valid-pos
()
+ "From invalid pos backward cell leaves point in valid pos on error."
+ (let ((kotl-file (make-temp-file "hypb" nil ".kotl")))
+ (unwind-protect
+ (progn
+ (find-file kotl-file)
+ (insert "1")
+ (kotl-mode:add-child)
+ (insert "1a")
+ (kotl-mode:add-parent)
+ (insert "2")
+
+ (kotl-mode:previous-cell 1)
+ (kotl-mode:end-of-cell)
+ (goto-char (1+ (point)))
+ (should-not (kview:valid-position-p))
+
+ (condition-case err
+ (funcall-interactively #'kotl-mode:backward-cell 2)
+ (error
+ (progn
+ (should (equal (car err) 'error))
+ (should (string-match "(kotl-mode:backward-cell): No prior cell
at same level" (cadr err))))))
+ (should (kotl-mode:bocp)) ;; Point is moved to begining of cell
+ (should (string= (kcell-view:label (point)) "1a")))
+ (delete-file kotl-file))))
+
+(provide 'kotl-mode-tests)
+;;; kotl-mode-tests.el ends here
diff --git a/test/kotl-orgtbl-tests.el b/test/kotl-orgtbl-tests.el
new file mode 100644
index 0000000..9fd6c4d
--- /dev/null
+++ b/test/kotl-orgtbl-tests.el
@@ -0,0 +1,54 @@
+;;; kotl-orgtbl-tests.el --- kotl orgtbl tests -*- lexical-binding:
t; -*-
+
+;; Copyright (C) 2021 Mats Lidell
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 2-Nov-21 at 17:04:30
+;;
+;; 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 kotl-orgtbl in "../kotl/kotl-orgtbl.el"
+
+;;; Code:
+
+(require 'ert)
+(require 'kotl-mode "kotl/kotl-mode")
+
+(load (expand-file-name "hy-test-helpers"
+ (file-name-directory (or load-file-name
+ default-directory))))
+(declare-function hy-test-helpers:consume-input-events "hy-test-helpers")
+
+(ert-deftest kotl-orgtbl-enabled-uses-kotl-mode-delete-char-ouside-of-table ()
+ "kotl-mode:detele-char is used ouside of org table."
+ (let ((kotl-file (make-temp-file "hypb" nil ".kotl")))
+ (unwind-protect
+ (progn
+ (find-file kotl-file)
+ (insert "1")
+
+ ;; Create an org table and leave point at end of cell
+ (should (hact 'kbd-key "RET |-| RET"))
+ (hy-test-helpers:consume-input-events)
+
+ ;; Verify that kotl-mode:delete-char is used outside of the
+ ;; table
+ (condition-case err
+ (progn
+ (should (hact 'kbd-key "C-d"))
+ (hy-test-helpers:consume-input-events))
+ (error
+ (progn
+ (should (equal (car err) 'error))
+ (should (string-match "(kotl-mode:delete-char): End of cell"
(cadr err)))))
+ (:success (ert-fail "C-d shall fail when deleting at the end of a
cell."))))
+ (delete-file kotl-file))))
+
+(provide 'kotl-orgtbl-tests)
+;;; kotl-orgtbl-tests.el ends here