From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to tame compiler? Date: Tue, 4 May 2021 00:39:33 +0300 Message-ID: References: <875z03th9b.fsf@web.de> <87mttdwuas.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9062"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: Help GNU Emacs To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 03 23:44:29 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1ldgMe-0002F9-MY for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 23:44:28 +0200 Original-Received: from localhost ([::1]:55886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldgMd-0003gJ-Qa for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 17:44:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldgM7-0003eK-9x for help-gnu-emacs@gnu.org; Mon, 03 May 2021 17:43:55 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:45033) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldgM4-0000cL-30 for help-gnu-emacs@gnu.org; Mon, 03 May 2021 17:43:55 -0400 Original-Received: from localhost ([::ffff:154.227.59.100]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000046165.0000000060906E95.00007970; Mon, 03 May 2021 14:43:48 -0700 Mail-Followup-To: Michael Heerdegen , Help GNU Emacs Content-Disposition: inline In-Reply-To: <87mttdwuas.fsf@web.de> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129386 Archived-At: * Michael Heerdegen [2021-05-02 08:59]: > Jean Louis writes: > > > How do I go to create dynamical bindings? Help me. > > Newest Emacs versions have `dlet' to create dynamical bindings. Here is > the definition: > > #+begin_src emacs-lisp > (defmacro dlet (binders &rest body) > "Like `let*' but using dynamic scoping." > (declare (indent 1) (debug let)) > `(let (_) > ,@(mapcar (lambda (binder) > `(defvar ,(if (consp binder) (car binder) binder))) > binders) > (let* ,binders ,@body))) > #+end_src > > Use that macro to create dynamical bindings where you really need, and > rely on lexical binding else. That really helped me, or I would be lost today. As my `rcd-template-eval' function did work, but somehow, for unknown reasons as indicated already by developers, it started misbehaving, and variables sometimes interpolated, sometimes not, or maybe at second invokation not. And I had to enclose the variables in the function within `dlet' and now it works well. But I have to tame compiler... This function can now generate thousands of pages, pre-process it, process with Markdown, Asciidoctor, txt2tags, Org mode, or however, page is written (or not process...) and produce the output. I guess it is very inefficient. Important is that it works. (defun wrs-generate-page (page-id) (dlet ((page (rcd-db-table-id-hash "pages" page-id cf-db)) (area (rcd-db-table-id-hash "areas" (gethash "pages_area" page) cf-db)) (template (rcd-db-table-id-hash "templates" (or (gethash "pages_templates" page) (gethash "areas_template" area)) cf-db)) (pages_title (gethash "pages_title" page)) (pages_keywords (gethash "pages_keywords" page)) (pages_description (gethash "pages_description" page)) (variables (make-hash-table :test 'equal)) (_ (hash-append variables (wrs-variables-hash nil nil nil 3))) (_ (hash-append variables (wrs-variables-hash (gethash "pages_area" page)))) (_ (hash-append variables (wrs-variables-hash nil (gethash "templates_id" template)))) (language (rcd-db-get-entry "languages" "languages_extension" (or (gethash "pages_language" page) (gethash "areas_defaultlanguage" area)) cf-db)) (_ (puthash "languages_extension" language variables)) (_ (when (gethash "areas_company" area) (puthash "areas_company" (rcd-db-get-entry "accounts" "accounts_name" (gethash "areas_company" area) cf-db) variables))) (_ (hash-append variables page area template)) (text (rcd-template-eval (gethash "pages_content" page "") '("⟦" "⟧") variables)) (processor (gethash "templates_processor" template)) (text (wrs-process-text processor text)) (_ (puthash "pages_content" text variables)) (template (gethash "templates_content" template)) (open-graph-type "Article") (html (rcd-template-eval template '("⟦" "⟧") variables)) (local-file (wrs-page-url page-id t))) (string-to-file-force html local-file))) -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns Sign an open letter in support of Richard M. Stallman https://stallmansupport.org/ https://rms-support-letter.github.io/