unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* using ses programatically
@ 2023-08-21  0:37 Andrés Ramírez
  0 siblings, 0 replies; only message in thread
From: Andrés Ramírez @ 2023-08-21  0:37 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: boruch_baum

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

Hi.

It is about using ses programatically for doing on the fly calculations.
The process has three parts:

1. input file '/tmp/ses202307'
2. template file '/tmp/workbook.ses'
3. elisp file '/tmp/smeter.el'

The output is the file '/tmp/smeter.mbox'

The process is working with a couple of workarounds.
workaround one: it needs yank.
workaround two: manual recalculation of affected cells

As attachments: You would fine
1. smeter.el (version with workarounds)
2. smeter-version-wished-works.el (the name explains it)


The questions are:
1. Is it a bug on 'ses-recalculate-all' (see smeter-version-wished-works.el)
2. why the yank workaround is needed. Why it causes it to work. (see
smeter.el)
3. which one is the right syntax for (ses-range) programatically.
4. how should a user consult a cell value programatically.

Best Regards
Andrés Ramírez


[-- Attachment #2: input --]
[-- Type: application/octet-stream, Size: 91 bytes --]

/tmp/workbook.ses
2990.52
1783.998
2046.323
48.272
164.2
3003.588
1797.543
2056.946
48.272

[-- Attachment #3: spreadsheet --]
[-- Type: application/octet-stream, Size: 10425 bytes --]

          Previous   Actual Difference     Factor   Subtotal Fix.Charge        IVA      Total Proportion  Adjusted% K_Or_J*Bil AddingComm .2d Format
          20230115 20230215         m3                                                                                                              
 Dpto 101 3003.588 3003.588          0      0.909          0     1.2225    0.22005    1.44255       0.25  0.3333333          0        0.5        0.5
 Dpto 201 1797.543 1797.543          0      0.909          0     1.2225    0.22005    1.44255       0.25  0.3333333          0        0.5        0.5
 Dpto 301 2056.946 2056.946          0      0.909          0     1.2225    0.22005    1.44255       0.25  0.3333333          0        0.5        0.5
 Dpto 401   48.272   48.272          0      0.909          0     1.2225    0.22005    1.44255       0.25  0.3333333          8        8.5        8.5
          Factor below                                                                                                                              
   0 a 10    0.909                                                                                                                                  
  10 a 25    1.055                                                                                                                                  
  25 a 50    2.675                                                                                                                                  
Fix Amount:            4.89                                                                                                                         
     IVA:       18                                                                                                                                  
Billed Amount:           10                                                                                                                         
  Common:        2                                                                                                                                  

\f
(ses-cell A1 nil nil nil nil)
(ses-cell B1 "Previous" nil nil nil)
(ses-cell C1 Actual 'Actual nil nil)
(ses-cell D1 "Difference" nil nil nil)
(ses-cell E1 Factor 'Factor nil nil)
(ses-cell F1 "Subtotal" nil nil nil)
(ses-cell G1 "Fix.Charge" nil nil nil)
(ses-cell H1 "IVA" nil nil nil)
(ses-cell I1 "Total" nil nil nil)
(ses-cell J1 "Proportion" nil nil nil)
(ses-cell K1 "Adjusted%" nil nil nil)
(ses-cell L1 "K_Or_J*BilledAmount" nil nil nil)
(ses-cell M1 "AddingCommonAmount" nil nil nil)
(ses-cell N1 ".2d Format" nil nil nil)

(ses-cell A2 nil nil nil nil)
(ses-cell B2 "20230115" nil nil nil)
(ses-cell C2 "20230215" nil nil nil)
(ses-cell D2 m3 'm3 nil nil)
(ses-cell E2 nil nil nil nil)
(ses-cell F2 nil nil nil nil)
(ses-cell G2 nil nil nil nil)
(ses-cell H2 nil nil nil nil)
(ses-cell I2 nil nil nil nil)
(ses-cell J2 nil nil nil nil)
(ses-cell K2 nil nil nil nil)
(ses-cell L2 nil nil nil nil)
(ses-cell M2 nil nil nil nil)
(ses-cell N2 nil nil nil nil)

(ses-cell A3 "Dpto 101" nil nil nil)
(ses-cell B3 3003.588 nil nil (D3))
(ses-cell C3 3003.588 nil nil (D3))
(ses-cell D3 0.0 (- C3 B3) nil (F3 E3))
(ses-cell E3 0.909 (if (<= D3 10) B8 (if (<= D3 25) B9 B10)) nil (F3))
(ses-cell F3 0.0 (if (<= D3 10) (* D3 E3) (if (<= D3 25) (+ (* B8 10) (* (- D3 10) B9)) (+ (* B9 25) (* (- D3 25) B10)))) nil (I3 H3))
(ses-cell G3 1.2225 (/ C11 4) nil (I3 H3))
(ses-cell H3 0.22004999999999997 (* (+ F3 G3) (/ B12 100.0)) nil (I3))
(ses-cell I3 1.4425499999999998 (apply 'ses+ (ses-range F3 H3)) nil (J6 J5 J4 J3))
(ses-cell J3 0.25 (/ I3 (apply 'ses+ (ses-range I3 I6))) nil (L3 K3))
(ses-cell K3 0.3333333333333333 (/ J3 (- 1 J6)) nil (L3))
(ses-cell L3 0.0 (if (= L6 8) (* (- C13 (+ 8 2)) K3) (* (- C13 (+ 0 2)) J3)) nil (M3))
(ses-cell M3 0.5 (+ L3 (/ B14 4.0)) nil (N3))
(ses-cell N3 0.5 (* (round M3 0.01) 0.01) nil nil)

(ses-cell A4 "Dpto 201" nil nil nil)
(ses-cell B4 1797.543 nil nil (D4))
(ses-cell C4 1797.543 nil nil (D4))
(ses-cell D4 0.0 (- C4 B4) nil (F4 E4))
(ses-cell E4 0.909 (if (<= D4 10) B8 (if (<= D4 25) B9 B10)) nil (F4))
(ses-cell F4 0.0 (if (<= D4 10) (* D4 E4) (if (<= D4 25) (+ (* B8 10) (* (- D4 10) B9)) (+ (* B9 25) (* (- D4 25) B10)))) nil (I4 H4))
(ses-cell G4 1.2225 (/ C11 4) nil (I4 H4))
(ses-cell H4 0.22004999999999997 (* (+ F4 G4) (/ B12 100.0)) nil (I4))
(ses-cell I4 1.4425499999999998 (apply 'ses+ (ses-range F4 H4)) nil (J6 J5 J4 J3))
(ses-cell J4 0.25 (/ I4 (apply 'ses+ (ses-range I3 I6))) nil (L4 K4))
(ses-cell K4 0.3333333333333333 (/ J4 (- 1 J6)) nil (L4))
(ses-cell L4 0.0 (if (= L6 8) (* (- C13 (+ 8 2)) K4) (* (- C13 (+ 0 2)) J4)) nil (M4))
(ses-cell M4 0.5 (+ L4 (/ B14 4.0)) nil (N4))
(ses-cell N4 0.5 (* (round M4 0.01) 0.01) nil nil)

(ses-cell A5 "Dpto 301" nil nil nil)
(ses-cell B5 2056.946 nil nil (D5))
(ses-cell C5 2056.946 nil nil (D5))
(ses-cell D5 0.0 (- C5 B5) nil (F5 E5))
(ses-cell E5 0.909 (if (<= D5 10) B8 (if (<= D5 25) B9 B10)) nil (F5))
(ses-cell F5 0.0 (if (<= D5 10) (* D5 E5) (if (<= D5 25) (+ (* B8 10) (* (- D5 10) B9)) (+ (* B9 25) (* (- D5 25) B10)))) nil (I5 H5))
(ses-cell G5 1.2225 (/ C11 4) nil (I5 H5))
(ses-cell H5 0.22004999999999997 (* (+ F5 G5) (/ B12 100.0)) nil (I5))
(ses-cell I5 1.4425499999999998 (apply 'ses+ (ses-range F5 H5)) nil (J6 J5 J4 J3))
(ses-cell J5 0.25 (/ I5 (apply 'ses+ (ses-range I3 I6))) nil (L5 K5))
(ses-cell K5 0.3333333333333333 (/ J5 (- 1 J6)) nil (L5))
(ses-cell L5 0.0 (if (= L6 8) (* (- C13 (+ 8 2)) K5) (* (- C13 (+ 0 2)) J5)) nil (M5))
(ses-cell M5 0.5 (+ L5 (/ B14 4.0)) nil (N5))
(ses-cell N5 0.5 (* (round M5 0.01) 0.01) nil nil)

(ses-cell A6 "Dpto 401" nil nil nil)
(ses-cell B6 48.272 nil nil (D6))
(ses-cell C6 48.272 nil nil (D6))
(ses-cell D6 0.0 (- C6 B6) nil (F6 E6))
(ses-cell E6 0.909 (if (<= D6 10) B8 (if (<= D6 25) B9 B10)) nil (L6 F6))
(ses-cell F6 0.0 (if (<= D6 10) (* D6 E6) (if (<= D6 25) (+ (* B8 10) (* (- D6 10) B9)) (+ (* B9 25) (* (- D6 25) B10)))) nil (I6 H6))
(ses-cell G6 1.2225 (/ C11 4) nil (I6 H6))
(ses-cell H6 0.22004999999999997 (* (+ F6 G6) (/ B12 100.0)) nil (I6))
(ses-cell I6 1.4425499999999998 (apply 'ses+ (ses-range F6 H6)) nil (J6 J5 J4 J3))
(ses-cell J6 0.25 (/ I6 (apply 'ses+ (ses-range I3 I6))) nil (K6 K5 K4 K3))
(ses-cell K6 0.3333333333333333 (/ J6 (- 1 J6)) nil nil)
(ses-cell L6 8 (if (> E6 2) nil 8) nil (M6 L5 L4 L3))
(ses-cell M6 8.5 (+ L6 (/ B14 4.0)) nil (N6))
(ses-cell N6 8.5 (* (round M6 0.01) 0.01) nil nil)

(ses-cell A7 nil nil nil nil)
(ses-cell B7 "Factor below" nil nil nil)
(ses-cell C7 *skip* nil nil nil)
(ses-cell D7 nil nil nil nil)
(ses-cell E7 nil nil nil nil)
(ses-cell F7 nil nil nil nil)
(ses-cell G7 nil nil nil nil)
(ses-cell H7 nil nil nil nil)
(ses-cell I7 nil nil nil nil)
(ses-cell J7 nil nil nil nil)
(ses-cell K7 nil nil nil nil)
(ses-cell L7 nil nil nil nil)
(ses-cell M7 nil nil nil nil)
(ses-cell N7 nil nil nil nil)

(ses-cell A8 "0 a 10" nil nil nil)
(ses-cell B8 0.909 nil nil (F6 F5 F4 F3 E6 E5 E4 E3))
(ses-cell C8 nil nil nil nil)
(ses-cell D8 nil nil nil nil)
(ses-cell E8 nil nil nil nil)
(ses-cell F8 nil nil nil nil)
(ses-cell G8 nil nil nil nil)
(ses-cell H8 nil nil nil nil)
(ses-cell I8 nil nil nil nil)
(ses-cell J8 nil nil nil nil)
(ses-cell K8 nil nil nil nil)
(ses-cell L8 nil nil nil nil)
(ses-cell M8 nil nil nil nil)
(ses-cell N8 nil nil nil nil)

(ses-cell A9 "10 a 25" nil nil nil)
(ses-cell B9 1.055 nil nil (F6 F5 F4 F3 E6 E5 E4 E3))
(ses-cell C9 nil nil nil nil)
(ses-cell D9 nil nil nil nil)
(ses-cell E9 nil nil nil nil)
(ses-cell F9 nil nil nil nil)
(ses-cell G9 nil nil nil nil)
(ses-cell H9 nil nil nil nil)
(ses-cell I9 nil nil nil nil)
(ses-cell J9 nil nil nil nil)
(ses-cell K9 nil nil nil nil)
(ses-cell L9 nil nil nil nil)
(ses-cell M9 nil nil nil nil)
(ses-cell N9 nil nil nil nil)

(ses-cell A10 "25 a 50" nil nil nil)
(ses-cell B10 2.675 nil nil (F6 F5 F4 F3 E6 E5 E4 E3))
(ses-cell C10 nil nil nil nil)
(ses-cell D10 nil nil nil nil)
(ses-cell E10 nil nil nil nil)
(ses-cell F10 nil nil nil nil)
(ses-cell G10 nil nil nil nil)
(ses-cell H10 nil nil nil nil)
(ses-cell I10 nil nil nil nil)
(ses-cell J10 nil nil nil nil)
(ses-cell K10 nil nil nil nil)
(ses-cell L10 nil nil nil nil)
(ses-cell M10 nil nil nil nil)
(ses-cell N10 nil nil nil nil)

(ses-cell A11 "Fix Amount:" nil nil nil)
(ses-cell B11 *skip* nil nil nil)
(ses-cell C11 4.89 nil nil (G6 G5 G4 G3))
(ses-cell D11 nil nil nil nil)
(ses-cell E11 nil nil nil nil)
(ses-cell F11 nil nil nil nil)
(ses-cell G11 nil nil nil nil)
(ses-cell H11 nil nil nil nil)
(ses-cell I11 nil nil nil nil)
(ses-cell J11 nil nil nil nil)
(ses-cell K11 nil nil nil nil)
(ses-cell L11 nil nil nil nil)
(ses-cell M11 nil nil nil nil)
(ses-cell N11 nil nil nil nil)

(ses-cell A12 "IVA:" nil nil nil)
(ses-cell B12 18 nil nil (H6 H5 H4 H3))
(ses-cell C12 nil nil nil nil)
(ses-cell D12 nil nil nil nil)
(ses-cell E12 nil nil nil nil)
(ses-cell F12 nil nil nil nil)
(ses-cell G12 nil nil nil nil)
(ses-cell H12 nil nil nil nil)
(ses-cell I12 nil nil nil nil)
(ses-cell J12 nil nil nil nil)
(ses-cell K12 nil nil nil nil)
(ses-cell L12 nil nil nil nil)
(ses-cell M12 nil nil nil nil)
(ses-cell N12 nil nil nil nil)

(ses-cell A13 "Billed Amount:" nil nil nil)
(ses-cell B13 *skip* nil nil nil)
(ses-cell C13 10 nil nil (L3 L4 L5))
(ses-cell D13 nil nil nil nil)
(ses-cell E13 nil nil nil nil)
(ses-cell F13 nil nil nil nil)
(ses-cell G13 nil nil nil nil)
(ses-cell H13 nil nil nil nil)
(ses-cell I13 nil nil nil nil)
(ses-cell J13 nil nil nil nil)
(ses-cell K13 nil nil nil nil)
(ses-cell L13 nil nil nil nil)
(ses-cell M13 nil nil nil nil)
(ses-cell N13 nil nil nil nil)

(ses-cell A14 "Common:" nil nil nil)
(ses-cell B14 2 nil nil (M6 M5 M4 M3))
(ses-cell C14 nil nil nil nil)
(ses-cell D14 nil nil nil nil)
(ses-cell E14 nil nil nil nil)
(ses-cell F14 nil nil nil nil)
(ses-cell G14 nil nil nil nil)
(ses-cell H14 nil nil nil nil)
(ses-cell I14 nil nil nil nil)
(ses-cell J14 nil nil nil nil)
(ses-cell K14 nil nil nil nil)
(ses-cell L14 nil nil nil nil)
(ses-cell M14 nil nil nil nil)
(ses-cell N14 nil nil nil nil)

(ses-column-widths [9 8 8 10 10 10 10 10 10 10 10 10 10 10])
(ses-column-printers [nil nil nil nil nil nil nil nil nil nil nil nil nil nil])
(ses-default-printer "%.7g")
(ses-header-row 0)

( ;Global parameters (these are read first)
 2 ;SES file-format
 14 ;numrows
 14 ;numcols
)

;; Local Variables:
;; mode: ses
;; End:

[-- Attachment #4: elisp1 --]
[-- Type: text/plain, Size: 3836 bytes --]

;;; with a buffer visiting the file /tmp/ses202307 run this function
;;; /tmp/ses202307 is the output of a newt curses app
;;; /home/user/dev/c/cli/newt/smeter/
(defun smeter/further-processing ()
  "process input on as spreadsheet using ses formulae and composing an email with the ses-output, after ses-recalculate"
  (interactive)
  (let ( (sesbuf nil)
         (measu '())
         (prevmeasu '())
         (waterbill nil)
         (beg nil)
         (workbook-filename) myrowcol )
    (goto-char (point-min))
    (setq beg (point)) (setq workbook-filename (buffer-substring-no-properties beg (line-end-position)))
    (forward-line 1)
    (setq beg (point)) (forward-line 4) (setq prevmeasu (split-string (buffer-substring-no-properties beg (point)) "\n"))
    (setq beg (point)) (setq waterbill (buffer-substring-no-properties beg (line-end-position)))
    (forward-line 1)
    (setq beg (point)) (forward-line 4) (setq measu (split-string (buffer-substring-no-properties beg (point)) "\n"))
    (if (not (file-readable-p workbook-filename))
        (message (format "file not found: '%s'"  workbook-filename))
      (set-buffer (setq sesbuf (find-file-noselect workbook-filename)))
      (setq myrowcol (ses-sym-rowcol (intern "C13"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number waterbill))
      (setq myrowcol (ses-sym-rowcol (intern "B3"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 0 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B4"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 1 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B5"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 2 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B6"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 3 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "C3"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 0 measu)))
      (setq myrowcol (ses-sym-rowcol (intern "C4"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 1 measu)))
      (setq myrowcol (ses-sym-rowcol (intern "C5"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 2 measu)))
      (setq myrowcol (ses-sym-rowcol (intern "C6"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 3 measu)))
      (ses-recalculate-all)
      (ses-jump-safe "N3") ;;; for killing from N3 to N9 the ses-output after applying formulaes 
      (setq beg (point)) (forward-line 4) (copy-region-as-kill beg (point)) 
      (with-temp-buffer ;;; ses-output to an email buffer
        (insert (current-kill 0))
        (goto-char (point-min))
        (dotimes (number (- (length prevmeasu) 1))
          (beginning-of-line)
          (insert (concat "| Dpto" (number-to-string (+ number 1)) "01 |" ))
          (end-of-line)
          (insert "|")
          (forward-line))
        (org-mode) ;; giving format to the org-table and sum
        (org-table-align)
        (org-table-insert-row 1)
        (org-table-goto-column 2)
        (insert (org-table-sum))
        (org-table-align)
        (message-mark-inserted-region (point-min) (point-max))
  ;;; complete composing mail with header and footer
        (goto-char (point-min))
        (insert "To: foo <h@pe.org>\nSubject: agua\nFrom: \"me\" <m@pe.org>\n--text follows this line--\nHi.\n\n")
        (goto-char (point-max))
        (insert "\nBest Regards\n")
        (write-file "/tmp/smeter.mbox")
        (message "smeter/further-processing ended"))
  ;;; kill ses buffer without confirmation (comment line below for not killing the buffer)
      (set-buffer-modified-p nil)
      (let ((kill-buffer-query-functions nil)) (kill-buffer sesbuf)))))

[-- Attachment #5: elisp2 --]
[-- Type: text/plain, Size: 5483 bytes --]

;;; with a buffer visiting the file /tmp/ses202307 run this function
;;; /tmp/ses202307 is the output of a newt curses app
;;; /home/user/dev/c/cli/newt/smeter/
(defun smeter/further-processing ()
  "process input on as spreadsheet using ses formulae and composing an email with the ses-output, after ses-recalculate"
  (interactive)
  (let ( (sesbuf nil)
         (measu nil)
         (prevmeasu '())
         (waterbill nil)
         (beg nil)
         (workbook-filename) myrowcol)
    (goto-char (point-min))
    (setq beg (point)) (setq workbook-filename (buffer-substring-no-properties beg (line-end-position)))
    (forward-line 1)
    (setq beg (point)) (forward-line 4) (setq prevmeasu (split-string (buffer-substring-no-properties beg (point)) "\n"))
    (setq beg (point)) (setq waterbill (buffer-substring-no-properties beg (line-end-position)))
    (forward-line 1)
    (setq beg (point)) (forward-line 4) (setq measu (buffer-substring-no-properties beg (point)))
    (if (not (file-readable-p workbook-filename))
        (message (format "file not found: '%s'"  workbook-filename))
      (set-buffer (setq sesbuf (find-file-noselect workbook-filename)))
      (setq myrowcol (ses-sym-rowcol (intern "B3"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 0 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B4"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 1 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B5"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 2 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "B6"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number (nth 3 prevmeasu)))
      (setq myrowcol (ses-sym-rowcol (intern "C13"))) (ses-set-cell (car myrowcol) (cdr myrowcol) 'value (string-to-number waterbill))
      ;;; NOTE2ME: yank is needed workaround-one
      (ses-jump-safe "C3") ;;; paste 4 cells
      (kill-new measu)
      (yank)
      ;;; (ses-recalculate-all)
      ;;; NOTE2ME: manual refreshing is needed cos ses-recalculate-all is not doing the job then workaround-two
      ;;; Key:R1 refreshOne cos of measures
      ;;; NOTE2ME: ses-dorange should not be needed when ses-recalculate-all works. But It should benefit a lot of persons knowing the right syntax
      ;;;(ses-dorange (ses-range E3 E6) (ses-calculate-cell row col))
      (ses-jump-safe "E3") (ses-recalculate-cell) (ses-jump-safe "E4") (ses-recalculate-cell) (ses-jump-safe "E5") (ses-recalculate-cell) (ses-jump-safe "E6") (ses-recalculate-cell)
      (ses-jump-safe "F3") (ses-recalculate-cell) (ses-jump-safe "F4") (ses-recalculate-cell) (ses-jump-safe "F5") (ses-recalculate-cell) (ses-jump-safe "F6") (ses-recalculate-cell)
      ;;; Key:R2 refreshTwo cos of waterBill-change
      (ses-jump-safe "H3") (ses-recalculate-cell) (ses-jump-safe "H4") (ses-recalculate-cell) (ses-jump-safe "H5") (ses-recalculate-cell) (ses-jump-safe "H6") (ses-recalculate-cell)
      (ses-jump-safe "I3") (ses-recalculate-cell) (ses-jump-safe "I4") (ses-recalculate-cell) (ses-jump-safe "I5") (ses-recalculate-cell) (ses-jump-safe "I6") (ses-recalculate-cell)
      (ses-jump-safe "J3") (ses-recalculate-cell) (ses-jump-safe "J4") (ses-recalculate-cell) (ses-jump-safe "J5") (ses-recalculate-cell) (ses-jump-safe "J6") (ses-recalculate-cell)
      (ses-jump-safe "K3") (ses-recalculate-cell) (ses-jump-safe "K4") (ses-recalculate-cell) (ses-jump-safe "K5") (ses-recalculate-cell) (ses-jump-safe "K6") (ses-recalculate-cell)
      (ses-jump-safe "L3") (ses-recalculate-cell) (ses-jump-safe "L4") (ses-recalculate-cell) (ses-jump-safe "L5") (ses-recalculate-cell) (ses-jump-safe "L6") (ses-recalculate-cell)
      (ses-jump-safe "M3") (ses-recalculate-cell) (ses-jump-safe "M4") (ses-recalculate-cell) (ses-jump-safe "M5") (ses-recalculate-cell) (ses-jump-safe "N6") (ses-recalculate-cell)
      (ses-jump-safe "N3") (ses-recalculate-cell) (ses-jump-safe "N4") (ses-recalculate-cell) (ses-jump-safe "N5") (ses-recalculate-cell) (ses-jump-safe "N6") (ses-recalculate-cell)
      (ses-jump-safe "N3") ;;; for killing from N3 to N9 the ses-output after applying formulaes , ended-with-ses
      (setq beg (point)) (forward-line 4) (copy-region-as-kill beg (point)) 
      (with-temp-buffer ;;; ses-output to an email buffer
        (insert (current-kill 0))
        (goto-char (point-min))
         (dotimes (number (- (length prevmeasu) 1))
           (beginning-of-line)
           (insert (concat "| Dpto" (number-to-string (+ number 1)) "01 |" ))
           (end-of-line)
           (insert "|")
           (forward-line))
        (org-mode) ;; giving format to the org-table and sum
        (org-table-align)
        (org-table-insert-row 1)
        (org-table-goto-column 2)
        (insert (org-table-sum))
        (org-table-align)
        (message-mark-inserted-region (point-min) (point-max))
  ;;; complete composing mail with header and footer
        (goto-char (point-min))
        (insert "To: foo <h@pe.org>\nSubject: agua\nFrom: \"me\" <m@pe.org>\n--text follows this line--\nHi.\n\n")
        (goto-char (point-max))
        (insert "\nBest Regards\n")
        (write-file "/tmp/smeter.mbox")
        (message "smeter/further-processing ended"))
  ;;; kill ses buffer without confirmation (comment line below for not killing the buffer)
      (set-buffer-modified-p nil)
      (let ((kill-buffer-query-functions nil)) (kill-buffer sesbuf)))))

[-- Attachment #6: plain --]
[-- Type: application/mbox, Size: 333 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-21  0:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21  0:37 using ses programatically Andrés Ramírez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).