[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole f0438eb 2/5: Fix indent handling if label len
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole f0438eb 2/5: Fix indent handling if label len grows beyond max indent space |
Date: |
Sun, 5 Dec 2021 17:57:19 -0500 (EST) |
branch: externals/hyperbole
commit f0438eb3f18653d8cd4a56a0a3546d57917b5e1d
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Fix indent handling if label len grows beyond max indent space
---
kotl/klabel.el | 9 ++++++---
kotl/kotl-mode.el | 31 ++++++++++++++++---------------
kotl/kview.el | 25 +++++++++++++++----------
3 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/kotl/klabel.el b/kotl/klabel.el
index b2874ea..70a6f0b 100644
--- a/kotl/klabel.el
+++ b/kotl/klabel.el
@@ -359,7 +359,8 @@ and the start of its contents."
(setq opoint (point))
(if (and (not current-tree-only)
(kcell-view:next nil label-sep-len)
- (= current-indent (kcell-view:indent nil label-sep-len)))
+ (< (abs (- (kcell-view:indent nil label-sep-len) current-indent))
+ (kview:level-indent kview)))
(setq suffix-val (1+ suffix-val)
label-suffix (funcall suffix-function suffix-val)
current-cell-label (concat label-prefix label-suffix))
@@ -403,7 +404,8 @@ and the start of its contents."
(setq opoint (point))
(if (and (not current-tree-only)
(kcell-view:next nil label-sep-len)
- (= current-indent (kcell-view:indent nil label-sep-len)))
+ (< (abs (- (kcell-view:indent nil label-sep-len) current-indent))
+ (kview:level-indent kview)))
(setq suffix-val (1+ suffix-val)
label-suffix (int-to-string suffix-val)
current-cell-label (concat label-prefix label-suffix))
@@ -452,7 +454,8 @@ and the start of its contents."
(setq opoint (point))
(if (and (not current-tree-only)
(kcell-view:next nil label-sep-len)
- (= current-indent (kcell-view:indent nil label-sep-len)))
+ (< (abs (- (kcell-view:indent nil label-sep-len) current-indent))
+ (kview:level-indent kview)))
(setq suffix-val (1+ suffix-val)
label-suffix (funcall suffix-function suffix-val)
current-cell-label label-suffix)
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index d0944ba..287cb47 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -1111,16 +1111,16 @@ Leave point at original location but return the tree's
new start point."
(from-indent (kcell-view:indent nil label-sep-len))
(start (kotl-mode:tree-start))
(end (kotl-mode:tree-end))
- (sib-id (if (= 0 (kotl-mode:forward-cell 1))
- (kcell-view:idstamp)))
+ (sib-id (when (= 0 (kotl-mode:forward-cell 1))
+ (kcell-view:idstamp)))
(id-label-flag (eq (kview:label-type kview) 'id))
new-tree-start)
;;
;; We can't move a tree to a point within itself, so if that is the case
;; and this is not a copy operation, signal an error.
- (if (and (not copy-p) (>= move-to-point start) (<= move-to-point end))
- (error "(kotl-mode:move-after): Can't move tree <%s> to within itself"
- from-label))
+ (when (and (not copy-p) (>= move-to-point start) (<= move-to-point end))
+ (error "(kotl-mode:move-after): Can't move tree <%s> to within itself"
+ from-label))
;;
;; If tree to move has a sibling, point is now at the start of the
;; sibling cell. Mark its label with a property which will be deleted
@@ -1208,8 +1208,8 @@ Leave point at original location but return the tree's
new start point."
(from-indent (kcell-view:indent nil label-sep-len))
(start (kotl-mode:tree-start))
(end (kotl-mode:tree-end))
- (sib-id (if (= 0 (kotl-mode:forward-cell 1))
- (kcell-view:idstamp)))
+ (sib-id (when (= 0 (kotl-mode:forward-cell 1))
+ (kcell-view:idstamp)))
new-tree-start)
;;
;; We can't move a tree to a point within itself, so if that is the case
@@ -1595,8 +1595,7 @@ With optional ARG < 0, move to the ARGth previous visible
cell."
(defalias 'kotl-mode:move-end-of-line 'kotl-mode:to-end-of-line)
(defun kotl-mode:end-of-tree ()
- "Move point to the last cell in tree rooted at the current cell.
-Leave point at the start of the cell."
+ "Move point to the start of the last cell in tree rooted at the current
cell."
(interactive)
(kotl-mode:maintain-region-highlight)
;; Enable user to return to this previous position if desired.
@@ -1612,7 +1611,8 @@ Leave point at the start of the cell."
;; or higher level in the outline than the first cell that we
;; processed.
(while (and (kcell-view:next nil label-sep-len)
- (> (kcell-view:indent nil label-sep-len) cell-indent))
+ (>= (- (kcell-view:indent nil label-sep-len) cell-indent)
+ (kview:level-indent kview)))
(setq end-point (point)))
(goto-char end-point)))
(kotl-mode:beginning-of-cell)))
@@ -1872,14 +1872,14 @@ The paragraph marked is the one that contains point or
follows point."
(point))
(defun kotl-mode:next-tree ()
- "Move past current tree to next tree, or to last cell in tree if no next
tree.
-Return non-nil iff there is a next tree within this koutline."
+ "Move past current tree to the start of the next tree, or to the start of
the last cell in tree if no next tree.
+Return non-nil iff there is a next tree within the koutline."
(let ((start-indent (kcell-view:indent))
(label-sep-len (kview:label-separator-length kview))
(same-tree t))
(while (and (kcell-view:next nil label-sep-len)
- (setq same-tree (< start-indent
- (kcell-view:indent nil label-sep-len)))))
+ (setq same-tree (>= (- (kcell-view:indent nil label-sep-len)
start-indent)
+ (kview:level-indent kview)))))
(not same-tree)))
(defun kotl-mode:previous-line (arg)
@@ -2953,7 +2953,8 @@ newlines at end of tree."
(next))
(save-excursion
(while (and (setq next (kcell-view:next nil label-sep-len))
- (< start-indent (kcell-view:indent nil label-sep-len))))
+ (>= (- (kcell-view:indent nil label-sep-len) start-indent)
+ (kview:level-indent kview))))
(cond (next
(goto-char (progn (kcell-view:previous nil label-sep-len)
(kcell-view:end))))
diff --git a/kotl/kview.el b/kotl/kview.el
index ef33c9f..619112a 100644
--- a/kotl/kview.el
+++ b/kotl/kview.el
@@ -98,7 +98,8 @@ Return t unless no such cell."
(progn (setq done t)
(goto-char opoint))
(setq curr-indent (kcell-view:indent nil label-sep-len))
- (cond ((= curr-indent start-indent)
+ (cond ((< (abs (- curr-indent start-indent))
+ (kview:level-indent kview))
(goto-char (kcell-view:start nil label-sep-len))
(setq found t))
((< curr-indent start-indent)
@@ -138,7 +139,8 @@ a cell's label and the start of its contents."
(setq label-sep-len (kview:label-separator-length kview)))
;; Since kcell-view:next leaves point at the start of a cell, the cell's
;; indent is just the current-column of point.
- (if (and next (> (current-column) prev-indent))
+ (if (and next (>= (- (current-column) prev-indent)
+ (kview:level-indent kview)))
t
;; Move back to previous point and return nil.
(goto-char opoint)
@@ -300,7 +302,8 @@ Return t unless no such cell."
(while (and (not (or found done))
(kcell-view:next visible-p label-sep-len))
(setq curr-indent (kcell-view:indent nil label-sep-len))
- (cond ((= curr-indent start-indent)
+ (cond ((< (abs (- curr-indent start-indent))
+ (kview:level-indent kview))
(goto-char (kcell-view:start nil label-sep-len))
(setq found t))
((< curr-indent start-indent)
@@ -406,7 +409,8 @@ Optional START and END are start and endpoints of cell to
use."
If parent is top cell, move to first cell within view and return 0.
Otherwise, return t unless optional VISIBLE-P is non-nil and the parent cell
is not part of the current view, else nil."
- (or label-sep-len (setq label-sep-len (kview:label-separator-length kview)))
+ (unless label-sep-len
+ (setq label-sep-len (kview:label-separator-length kview)))
(let ((opoint (point))
(parent-level (1- (kcell-view:level nil label-sep-len))))
(if (= parent-level 0) ;; top cell
@@ -835,7 +839,7 @@ See documentation for kview:default-label-type."
(kview:get-attr kview 'label-type)))
(defun kview:level-indent (kview)
- "Return KVIEW's level-indent setting or nil if argument is not a kview.
+ "Return KVIEW's per level-indent setting or nil if argument is not a kview.
See documentation for kview:default-level-indent."
(when (kview:is-p kview)
(kview:get-attr kview 'level-indent)))
@@ -867,7 +871,8 @@ See also `kview:map-region', `kview:map-siblings' and
`kview:map-tree'."
;; or higher level in the kotl than the first cell that we processed.
(while (and (setq results (cons (funcall func kview) results))
(kcell-view:next visible-p label-sep-len)
- (> (kcell-view:indent nil label-sep-len) cell-indent)))
+ (>= (- (kcell-view:indent nil label-sep-len) cell-indent)
+ (kview:level-indent kview))))
(nreverse results)))))
(defun kview:map-region (func kview &optional visible-p start end)
@@ -987,8 +992,8 @@ See also `kview:map-region', `kview:map-branch' and
`kview:map-siblings'."
;; or higher level in the kotl than the first cell that we
processed.
(while (and (setq results (cons (funcall func kview) results))
(kcell-view:next nil label-sep-len)
- (> (kcell-view:indent nil label-sep-len)
- cell-indent))))
+ (>= (- (kcell-view:indent nil label-sep-len)
cell-indent)
+ (kview:level-indent kview)))))
;;
;; Restore status of temporarily expanded cells.
(when (remq 0 collapsed-cells)
@@ -1033,8 +1038,8 @@ See also `kview:map-region', `kview:map-branch' and
`kview:map-siblings'."
;; or higher level in the kotl than the first cell that we
processed.
(while (and (setq results (cons (funcall func kview) results))
(kcell-view:next visible-p label-sep-len)
- (> (kcell-view:indent nil label-sep-len)
- cell-indent))))
+ (>= (- (kcell-view:indent nil label-sep-len)
cell-indent)
+ (kview:level-indent kview)))))
(nreverse results)))))
(defun kview:move (from-start from-end to-start from-indent to-indent