From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Andr=C3=A9s_Ram=C3=ADrez?= Newsgroups: gmane.emacs.devel Subject: Re: a ses question Date: Wed, 01 Nov 2023 17:07:52 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21778"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , boruch_baum@gmx.com To: Vincent =?utf-8?Q?Bela=C3=AFche?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 01 18:18:56 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qyErm-0005K5-W3 for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Nov 2023 18:18:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyEqz-00029U-Rf; Wed, 01 Nov 2023 13:18:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyEm9-0001l7-7M for emacs-devel@gnu.org; Wed, 01 Nov 2023 13:13:05 -0400 Original-Received: from mail-dm6nam10olkn20828.outbound.protection.outlook.com ([2a01:111:f400:7e88::828] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyEm7-0007Ym-1m for emacs-devel@gnu.org; Wed, 01 Nov 2023 13:13:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QZUzZBKAxPmNC9uk/WMDLXaz2wrJGcyi7WCNgl4F0qnpnTYSmHbhala8wifnJQcC2x1VtK1wxaa+oNyIuPucl7wfGsV7N/MgDAXXZ3NzeOagYFv+ojwL4MsdACdlsAyuMx0rFalOFhbXVkc5LfjK5fkUv6kBZaG3X0X3KydR1lBA83JhrL8phK38bhDmNUJIs0zbOuHL9Qx97Dmz+/5/rsOuUzIXHh3bCWIc25sCD9MHF2fOr+A/Xbhhayn7CNmO+98xychZpjKqbXj8sfi1K93tGFdKQuowL2JU1yxr/2IBCAWoLwDv0oDH2GOgl0oyX9+7V3FECWDcvwOsqPAr6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JRMlpXhvHSo3pag9NlV/sRYmhvl5x53gU/T/7Dp+5Uw=; b=U4NGHgn5YepnwLJj5e9BBLHLkKij/C5IrD8VgPTBEfW6NkqCX60ZDtK5RraeL22cQ0cz8sRZVZoT01ZuG3ADyWq0igsUKSkkbAjktGwyRpUdAtU5Xj2mtPXXIJgU0FBxheOviS3LppwOv9xFGWENdk2vaKVgJ/YCQRGbODwKTSsPfGFkTJlUlGY4k61+wqhZ41xy0ug5kXVe6ZJeFr7lH8jh5ysu+XwaHn5TkM3woptOS3hBfOu6vsnpMav6tK1aGBC0QYVsmZKa9uh1efGLmKYNAPJ74sYJ8Sgnq6it2Tu0CsPP1SeUySbL09Sf5ps3IjI8ZjVSnJKhCyWpEgz3fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JRMlpXhvHSo3pag9NlV/sRYmhvl5x53gU/T/7Dp+5Uw=; b=c6/siuMv0l39WagguXv7+6T7Z+7bR67eAX7U2rYz2pGgdK1agsURemfqli57XEYACe4MikL/PwC1J+BE9wpMTPyRC395b6zj67KIXo3vptxFgyX3fNGVp+PMkdupYEY8EnJoLTyrkXq5xxiFIpCCYmSJU5FnQMnD8Nv+5hJxY3ZhRh4ZjYFgVx9bSGo9bKYLTBGxNzCgKfgdyjAjB6SAnJsHPw7Phg8PNmo4BNQ48Qm3MvYX3sgQhE7G0UuQK6o3pkjbvp1O15MAnQqk+Jf6yCOEAtqd2KN14CczzVe1T4m5bm/l/C2MAh28FjcqkG6M+H/Jvmr8UKgesOtE2cjwwA== Original-Received: from SJ1PR12MB6363.namprd12.prod.outlook.com (2603:10b6:a03:453::9) by SJ2PR12MB8943.namprd12.prod.outlook.com (2603:10b6:a03:547::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28; Wed, 1 Nov 2023 17:07:58 +0000 Original-Received: from SJ1PR12MB6363.namprd12.prod.outlook.com ([fe80::b621:3063:2c6f:56e7]) by SJ1PR12MB6363.namprd12.prod.outlook.com ([fe80::b621:3063:2c6f:56e7%6]) with mapi id 15.20.6954.019; Wed, 1 Nov 2023 17:07:58 +0000 X-TMN: [/h7vPYaipWYDbZp45bqYuCc2vYR+Oie8] X-ClientProxiedBy: SCZP152CA0030.LAMP152.PROD.OUTLOOK.COM (2603:10d6:300:52::15) To SJ1PR12MB6363.namprd12.prod.outlook.com (2603:10b6:a03:453::9) X-Microsoft-Original-Message-ID: <86bkcdl7vb.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PR12MB6363:EE_|SJ2PR12MB8943:EE_ X-MS-Office365-Filtering-Correlation-Id: 2255f049-5d9c-4c3e-bc9e-08dbdafd185d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QYeK4W6kEix/7OpD4B11XHPtGVHbvmUsHLCSETFvusm4DjBSkm5NpTGL+wJaS2wpzIKk2nMinclDhlpMCZzKAQco5R/MyupWlJdcBR3R8j/3Kozm0voqNojSZj+aVGzus0uO7zgYz9zWHbv64UAL3wJv/Sbt3DwS2/cgwydzJokowj3mLByzV0H9R15Qrz6mklqwdBHx64+BsMDdZhe3DhBYUs9iz5i+INW+ELVRvtr5xwF+L40sf5PmgK2nKt2jjwnIimf2Zl+LWaiLcK3ZWVfLpO/K/Eqr3VvOpiilCzKn5Z3JBK3f81K259/G89+Cmt6HWTnAEknnPQIUk2aMWXbHXDMgvkasduejGIlptoRrFLDT4zH7TvuiYimOcbnM10XOua2MCyu022SxNOnCzOwjR+8Clc8vV0I1uc+IZT/MspkcCl0yEACwo8XESb4OjVwq1ySEKfxtVuL2ajgxyJ8wAQqcV/PwIQPNqqyoaFXPb9G6xZ7mftVLhyZGEn3bAwn5PpOMXQIKZoDOVDPt1KHk9axCLFwDwglePI3RFmya2CZpHpy9nrRYbx6i7os2 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QmlpQ3FkM2NkbXJKcmVRT3FrMzNlRXd0KzVqNTNFcHhmcGxKRjFhSGNtb1Bj?= =?utf-8?B?TFZhLzZjS3Bkck92UHcvQXczWGlNaEZWUElGTzRBa0owWTRad2pmMlVTTlA0?= =?utf-8?B?b2ZhNlFFMkorQWJZT2ZuSkRuelNmRVQvS00rc1hIT2ROeUlhSFBxd2FDVTh0?= =?utf-8?B?WG16YWFSQkVFRVJPV21JMHBhMGxCeSt3VVpOZVlQeXJndWJxbTBXMndvTDNa?= =?utf-8?B?SVhqa2FaWXFBVlJrMkJJWmswU3VLVWFMMGxqOWNQUzFhRGZqNlRkUCs3Z2Jp?= =?utf-8?B?U0JBUGFvWFQ4YmFEbmp5blRCSUZXRmhaRmdrVWJYb2NqV2Y3UkRqQTNsTVNo?= =?utf-8?B?OVd6MmRvcUtTd2MyczErVDF3T21oU3hXUkxqRGtHR203V21vQ2xBbTJIMXp2?= =?utf-8?B?MTczbmwxL25zbWI4ajNrVFhIS3RDU0ZDNjNzdlJyK2Q1SE1BdStCYTRaRDZN?= =?utf-8?B?YXJpeUpwdUtkTEUxOWJoK3N0a2pBRGN1c0lCK25qNzU0amJ3aXEwcGg5Umls?= =?utf-8?B?NE1MeWJObFlIbVlsQnpnckxrQ3JscmM4dVBMbDVIMWJvaHJGLzV2SEprSnBG?= =?utf-8?B?UTJHRzBvNHAyUnRDQUpIR3pTaU5hUnhPVFpLMm1DdUlVcjJIY2hDMFJHR2N0?= =?utf-8?B?aXBmWSs0QktjVG4yTGhmbjJDWGVJSEsyS2NIcV X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-71ea3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 2255f049-5d9c-4c3e-bc9e-08dbdafd185d X-MS-Exchange-CrossTenant-AuthSource: SJ1PR12MB6363.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 17:07:57.9669 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8943 Received-SPF: pass client-ip=2a01:111:f400:7e88::828; envelope-from=rrandresf@hotmail.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PP_MIME_FAKE_ASCII_TEXT=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 01 Nov 2023 13:18:01 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:312078 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi again Vincent. In the last email was missing the way the code looks now (I am updating it cos now the ses computation result is recovered on a different way), see the var mysesoutput. --8<---------------cut here---------------start------------->8--- ;;; with a buffer visiting the file /tmp/smeteroutput (output of smeterApp)= run this function (defun smeter/further-processing () "process input on as spreadsheet using ses formulae and extracting the se= s computation result" (interactive) (let ( (sesbuf nil) (measu nil) (prevmeasu '()) (waterbill nil) (beg nil) (workbook-filename) myyyyymm mysesoutput) (goto-char (point-min)) (setq beg (point)) (setq workbook-filename (buffer-substring-no-propert= ies beg (line-end-position))) (forward-line 1) (setq beg (point)) (forward-line 4) (setq prevmeasu (split-string (buff= er-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-pr= operties beg (point))) (setq beg (point)) (setq myyyyymm (buffer-substring-no-properties beg (= line-end-position))) (if (not (file-readable-p workbook-filename)) (message (format "file not found: '%s'" workbook-filename)) (set-buffer (setq sesbuf (find-file-noselect workbook-filename))) (ses-set-cell 12 2 'value (string-to-number waterbill)) ;;; C13 (ses-set-cell 2 1 'value (string-to-number (nth 0 prevmeasu))) ;;; B3 (ses-set-cell 3 1 'value (string-to-number (nth 1 prevmeasu))) (ses-set-cell 4 1 'value (string-to-number (nth 2 prevmeasu))) (ses-set-cell 5 1 'value (string-to-number (nth 3 prevmeasu))) ;;; B6 ;;; NOTE2ME: yank is needed workaround-one (perhaps cos of deferred c= alculations) =C2=BFHow to call manually the deferred-calculation? (ses-jump-safe "C3") ;;; paste 4 cells (kill-new measu) (yank) ;;; how to get rid of yank? 4 using ses-set-cell in place of y= ank ;;; (ses-recalculate-all) ;;; NOTE2ME: manual refreshing is needed cos ses-recalculate-all is n= ot doing the job (then workaround-two) ;;; Key:R1 refreshOne cos of measures (all-refreshes-are-workaround-t= wo) ;;; NOTE2ME: It should benefit a lot of persons knowing the right syn= tax 4 ses-range (let ((minrow 2)(maxrow 5)(mincol 4)(maxcol 5)) (ses-recalculate-cell= )) ;;; E3 F6 ;;; Key:R2 refreshTwo cos of waterBill-change (let ((minrow 2)(maxrow 5)(mincol 7)(maxcol 13)) (ses-recalculate-cel= l)) ;;; H3 N6 ;;; below is for N3 N6 the computation result (setq mysesoutput (concat (number-to-string (ses-cell-value 2 13)) "\= n" (number-to-string (ses-cell-value 3 13)) "\n" (number-to-string (ses-cel= l-value 4 13)) "\n" (number-to-string (ses-cell-value 5 13)))) ;;; kill ses buffer without confirmation (comment 2-lines below for n= ot killing workbook-buffer) (set-buffer-modified-p nil) (let ((kill-buffer-query-functions nil)) (kill-buffer sesbuf)) ;;;(smeter/compose-mail mysesoutput (- (length prevmeasu) 1) myyyyymm= ) (with-temp-buffer (insert (replace-regexp-in-string "\n" "|" mysesout= put)) (write-file "/tmp/smeter-ses-computation-result-on-one-line")) ;;;(smeter/receipts-amounts) ))) --8<---------------cut here---------------end--------------->8--- Best Regards --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 8bit From: andrés ramírez To: Vincent Belaïche Cc: emacs-devel , boruch_baum@gmx.com Subject: Re: a ses question Date: Mon, 30 Oct 2023 19:03:19 +0000 Content-Type: text/plain MIME-Version: 1.0 I just yanked the elisp snippet You shared (without any modification) I just did M-x eval-defun, and It gave me this error: --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (error "Eager macro-expansion failure: (void-variable ses-...") signal(error ("Eager macro-expansion failure: (void-variable ses-...")) error("Eager macro-expansion failure: %S" (void-variable ses--cells)) internal-macroexpand-for-load((setq elisp--eval-defun-result (let ((print-level nil) (print-length nil)) (defalias 'smeter/further-processing #'(lambda nil "process input on as spreadsheet using ses formulae..." (interactive) (let (... ... ... ... ... ... myyyyymm mysesoutput chunk bigchunk) (goto-char ...) (setq beg ...) (setq workbook-filename ...) (forward-line 1) (setq beg ...) (forward-line 4) (setq prevmeasu ...) (setq beg ...) (setq waterbill ...) (forward-line 1) (setq beg ...) (forward-line 4) (setq measu ...) (setq beg ...) (setq myyyyymm ...) (if ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...)))))) t) eval-region(162 5110 t #f(compiled-function (ignore) #)) ; Reading at buffer position 2635 elisp--eval-defun() eval-defun(nil) funcall-interactively(eval-defun nil) call-interactively(eval-defun record nil) command-execute(eval-defun record) execute-extended-command(nil "eval-defun" "eval-defun") funcall-interactively(execute-extended-command nil "eval-defun" "eval-defun") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) --8<---------------cut here---------------end--------------->8--- Best Regards Andrés Ramírez >>>>> "Vincent" == Vincent Belaïche writes: Vincent> Just reading again the code which I sent in my Vincent> previous email, I found a problem, there would be one trailing column separator « & » Vincent> too many. Probably the following would be better: Vincent> (let ((range (with-current-buffer the-ses-buffer (ses-range A1 C3 ; adapt to your case Vincent>                                            *2 '>v ; use 'v> to read columnwsise Vincent>                                            )))) (dolist (row (cdr range)) ; cdr to Vincent> remove 'vec (pop row) ; remove 'vec (while (progn        (insert (format "%f" (pop Vincent> row))) ; assuming all cells are floating point numbers        (when row        (insert Vincent>        "&" ; if & is the column separator        ) t ; loop again              ))) Vincent> (insert "\\\\\n"; if \\ is the row separator        ))) --=-=-=--