[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ilist 8c4efd3d7c 11/24: add invisible text property.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ilist 8c4efd3d7c 11/24: add invisible text property. |
Date: |
Tue, 28 Dec 2021 16:58:13 -0500 (EST) |
branch: externals/ilist
commit 8c4efd3d7cb3b596e23d8b710b486f67a91d4cc0
Author: JSDurand <mmemmew@gmail.com>
Commit: JSDurand <mmemmew@gmail.com>
add invisible text property.
* ilist.el (ilist-string): Add some invisible text properties.
(ilist-mode): Prepare the buffer-invisibility-spec to adapt to the
changes.
(ilist-forward-line): Add the option to control skipping invisible
lines. This is now needed since the texts are not "physically"
deleted from the buffer, which may thus cause unexpected results.
---
ilist.el | 70 ++++++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 48 insertions(+), 22 deletions(-)
diff --git a/ilist.el b/ilist.el
index 0f78f38ff9..8696a2919e 100644
--- a/ilist.el
+++ b/ilist.el
@@ -538,26 +538,39 @@ trailing spaces."
(append
;; special properties
(list (propertize header 'ilist-header t)
- (propertize title-sep 'ilist-title-sep t))
+ (string #xa)
+ (propertize title-sep 'ilist-title-sep t)
+ (string #xa))
;; transform back to the format we want
- (mapcar
- (lambda (element)
- (concat
- ;; title
- (car element)
- ;; for empty groups don't add a newline
- (cond ((cdr element) (string #xa)))
- ;; rows
- (mapconcat
- (lambda (row)
+ (let ((len (length group-strs))
+ (index 0))
+ (mapcar
+ (lambda (element)
+ (setq index (1+ index))
+ (concat
+ ;; title
+ (car element)
+ ;; for empty groups don't add a newline
+ (cond ((cdr element) (string #xa)))
+ ;; rows
+ (mapconcat
+ (lambda (row)
+ (propertize
+ (mapconcat
+ #'identity (cdr row) (string #x20))
+ 'ilist-index (car row)
+ 'invisible (intern (car element))))
+ (cdr element)
(propertize
- (mapconcat
- #'identity (cdr row) (string #x20))
- 'ilist-index (car row)))
- (cdr element)
- (string #xa))))
- group-strs)))
- (mapconcat #'identity group-strs (string #xa))))
+ (string #xa)
+ 'invisible (intern (car element))))
+ (cond
+ ((< index len)
+ (propertize
+ (string #xa)
+ 'invisible (intern (car element)))))))
+ group-strs))))
+ (mapconcat #'identity group-strs (string))))
;;; map over lines
@@ -603,7 +616,8 @@ over which the function is executed."
(cons
(funcall fun)
res))))
- (ilist-forward-line 1))
+ ;; don't skip invisible lines here
+ (ilist-forward-line 1 nil nil t))
(nreverse res))))
;;; Get index at point
@@ -831,13 +845,16 @@ FORWARDP determines the direction to test for the
boundary."
;;;; moving between lines
-(defun ilist-forward-line (&optional arg rounded skip-groups)
+(defun ilist-forward-line (&optional arg rounded skip-groups no-skip-invisible)
"Go to ARG th next line.
If ROUNDED is non-nil, assume the top of the buffer is connected
to the bottom of the buffer.
If SKIP-GROUPS is non-nil, try not to stop point on a group
-header."
+header.
+
+If NO-SKIP-INVISIBLE is non-nil, invisible lines will not be
+skipped."
;; make sure ARG is a number
(setq arg (prefix-numeric-value arg))
(let* ((forwardp (> arg 0))
@@ -846,6 +863,7 @@ header."
(goto-char (point-max))
(line-beginning-position)))))
(original-point (point))
+ (line-move-ignore-invisible t)
(arg (abs arg)))
(ilist-skip-properties t forwardp
'(ilist-header
@@ -856,6 +874,11 @@ header."
(setq arg (1- arg))))
(while (> arg 0)
(forward-line (cond (forwardp 1) (-1)))
+ ;; skip invisible lines if needed
+ (while (and (not no-skip-invisible)
+ (memq (get-text-property (point) 'invisible)
+ buffer-invisibility-spec))
+ (forward-line (cond (forwardp 1) (-1))))
;; skip the group and the boundary twice to ensure that we avoid
;; the edges as much as possible.
(ilist-skip-boundary rounded forwardp other-end)
@@ -954,7 +977,10 @@ with ELEMENTS removed."
(define-derived-mode ilist-mode special-mode "IList"
"Display a list in a similar fashion to ibuffer."
- (setq truncate-lines t))
+ (setq truncate-lines t)
+ ;; This is to make sure that by default the bookmarks are not
+ ;; hidden.
+ (setq buffer-invisibility-spec (list t)))
;; It is intentional that no key-bindings are defined.
- [elpa] externals/ilist 8b5d5f382f 22/24: Update docs, (continued)
- [elpa] externals/ilist 8b5d5f382f 22/24: Update docs, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist f021d7d8ab 20/24: fix: account for an invisible beginning, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 282f60c93a 21/24: I forgot to byte-compile again. Silly me!, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist c3f0e61360 13/24: fix missing parameter, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist b2bf67c5d8 24/24: Add changelog, and update documentation, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist ed18678569 05/24: new: get group and marks, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 5362c106a8 04/24: more functionalities, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 347effebbe 07/24: fix the calculation of lengths of strings, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist ebb207c520 08/24: Fix an ilist error, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 76f29b61bb 10/24: Minor format change, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 8c4efd3d7c 11/24: add invisible text property.,
ELPA Syncer <=
- [elpa] externals/ilist c4a48491ee 15/24: fix previous bugs caused by invisibility, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 1b16d5789d 14/24: ilist: fix some errors caused by invisibility again., ELPA Syncer, 2021/12/28
- [elpa] externals/ilist c9b456103c 16/24: Fix errors and byte-compile, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist df91da4d46 17/24: ilist: try to fix a bug, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 0892dd8ffc 18/24: ilist: update the byte-compiled version, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 2279028fd5 23/24: ilist: Adding automatic filter groups, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 66bc6e0101 19/24: ilist: fix a bug about moving between items, ELPA Syncer, 2021/12/28