emacs-diffs
[Top][All Lists]
Advanced

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

master a11d34b53e5 2/3: Fix test about need for explicit printing insert


From: Vincent Belaïche
Subject: master a11d34b53e5 2/3: Fix test about need for explicit printing inserted lines
Date: Sun, 24 Dec 2023 16:08:18 -0500 (EST)

branch: master
commit a11d34b53e5c32dfc7b8a6eb0c64c087b9b046ba
Author: Vincent Belaïche <vincentb1@users.sourceforge.net>
Commit: Vincent Belaïche <vincentb1@users.sourceforge.net>

    Fix test about need for explicit printing inserted lines
    
    * lisp/ses.el (ses--blank-line-needs-printing-p): New
    function. Does not consider that printer `nil' produces a non
    empty string, as `ses-print-cell' removes nil printer by oring to
    fallback.
    (ses-insert-row): Replace the complex and erroneous test about
    blank newline needing printing by a call to
    'ses--blank-line-needs-printing-p'.
---
 lisp/ses.el | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/lisp/ses.el b/lisp/ses.el
index 23018403cda..c86871fa83f 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -2762,6 +2762,18 @@ See `ses-read-cell-printer' for input forms."
 ;;----------------------------------------------------------------------------
 ;; Spreadsheet size adjustments
 ;;----------------------------------------------------------------------------
+(defun ses--blank-line-needs-printing-p ()
+  "Returns `t' when blank new line print-out needs to be initialised
+by calling the printers on it, `nil' otherwise."
+  (let (ret
+        printer
+        (printers (append ses--col-printers (list ses--default-printer))))
+    (while printers
+      (if (and (setq printer (pop printers))
+               (null (string= "" (ses-call-printer printer))))
+          (setq ret t
+                printers nil)))
+    ret))
 
 (defun ses-insert-row (count)
   "Insert a new row before the current one.
@@ -2794,15 +2806,13 @@ With prefix, insert COUNT rows before current one."
     (ses-goto-data row 0)
     (insert (make-string (* (1+ ses--numcols) count) ?\n))
     (ses-relocate-all row 0 count 0)
-    ;;If any cell printers insert constant text, insert that text
-    ;;into the line.
-    (let ((cols   (mapconcat #'ses-call-printer ses--col-printers nil))
-         (global (ses-call-printer ses--default-printer)))
-      (if (or (> (length cols) 0) (> (length global) 0))
-         (dotimes (x count)
-           (dotimes (col ses--numcols)
-             ;;These cells are always nil, only constant formatting printed
-             (1value (ses-print-cell (+ x row) col))))))
+    ;;If any cell printers insert constant text, insert that text into
+    ;;the line.
+    (if (ses--blank-line-needs-printing-p)
+       (dotimes (x count)
+         (dotimes (col ses--numcols)
+           ;;These cells are always nil, only constant formatting printed
+           (1value (ses-print-cell (+ x row) col)))))
     (when (> ses--header-row row)
       ;;Inserting before header
       (ses-set-parameter 'ses--header-row (+ ses--header-row count))



reply via email to

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