From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id OIxAMu4Le2Wy4QAAkFu2QA (envelope-from ) for ; Thu, 14 Dec 2023 15:06:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id mHfHLe4Le2V0QAEAe85BDQ (envelope-from ) for ; Thu, 14 Dec 2023 15:06:38 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=CAG9a2g9; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1702562798; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=CA8SJoS9NsLWXWOg1PwqYrLJGBPyMBbeXiXqgEWu5Ok=; b=aEddl0/JimzLjvN9e08VGpKaMPM08hwmUdZK6iTpe18cZQiaAgJ+SCppNpU0j2DPkCRzSn TBrtorJKuYqbq5CBaW1ARTzcjhrrRfEQHnt59MQXjTNIHUbAiGM11/q/fCAbsOyIWYLmMQ QxPN15U6ixbYW3rdvDQVQY851vXyH/K8JtPLUhDvdb4gWrZIUPB/3g/Vh7YszojgEL8bwu G06LaAOJTw7glSjjq+xxbbhQ4//ebqaRlSoX2fpmqqpJ44X9bYHk1ONb3pQPxOPRqMBRzp mUXmlMxMvtDMF1bkdqilMGdQnyfw9ySm8bjGnbhQa3jqWXR853eqoLKBOzW/Eg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=CAG9a2g9; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702562798; a=rsa-sha256; cv=none; b=n7r5XmVEdR98aILIiXuPCcEpH6IZzWdFLOxLYjfD/vxzQEjcYayPZ+/eWGUHtIG2tAViwH BJzOR/71Bih3QMgwA2UF3wVRb0KxGLtse8mpG65BnaOE+TK/CV5zBCqBXsRfV8CYqJoPij LioTjSpHMRyhmOSXcfAoiLG7uoz1jMdSSyYOORj3vNul9j0w8IMwfBDjjuScZsOpVdD/zm Ru/hs9q+3gxkf82n1L93/155xjoRcAbD9Q97/9RqsWxc3G8W6qCcyxpyr+27nkysuwmibL OJoFNlESSzFjovIcmbIsgLr2a5hPVh/0ooYuqbgnXeeMCeVeg9MiS5LEUGg5XA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4EC44327F6 for ; Thu, 14 Dec 2023 15:06:38 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDmLP-0001xb-R5; Thu, 14 Dec 2023 09:05:43 -0500 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 1rDmLJ-0001s1-NY for emacs-orgmode@gnu.org; Thu, 14 Dec 2023 09:05:39 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDmLH-0007cX-6e for emacs-orgmode@gnu.org; Thu, 14 Dec 2023 09:05:37 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B430D240101 for ; Thu, 14 Dec 2023 15:05:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1702562730; bh=hi9hdDnR+JVOW6MhdDCTfRi8kVnp/BJJPiFIVZtvbhU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=CAG9a2g9z4pcLszZa24DE0HkDXHVVTzcXoH61n5BuhymKAyuuvhC6Wf5PyLR71BSm tvaGo4Nnutxk/0gVKY60jLBep5lvqg41jw1lFs8Aj+xkxwMH3GUKb0NX4Z7XXrWzO4 oLOhBAd5abjGsmAQjx12StGIKiAT2vQQ4K1+1+zSjmjD2VvjZaa4E+pijO6qa1GjLF fRcvY/HYxefUhUzQmG+mRjI94SS/d0mUWbKcGVUM6j5yz8kIJrjQHSFrwiTpCCs9Nf V2XBu868CVxbyLDhqFrW6pjc00CtPD1FtobLuezCuNbR5XYyjJHcc/EDctxaOl4pCY CxdPKEtSJLKxg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SrYyy0nqgz6tyg; Thu, 14 Dec 2023 15:05:30 +0100 (CET) From: Ihor Radchenko To: Leo Butler Cc: tbanelwebmin , "emacs-orgmode@gnu.org" Subject: Re: How to use mpirun with C or C++ Org-babel? In-Reply-To: <87r0jq3x0e.fsf@t14.reltub.ca> References: <1819406926.505980.1701990611441@fidget.co-bxl> <6efe8fc4-c12f-e128-8d7e-9e32887b127c@free.fr> <87plzg7l25.fsf@t14.reltub.ca> <87msukbadu.fsf@localhost> <87r0jq3x0e.fsf@t14.reltub.ca> Date: Thu, 14 Dec 2023 14:08:36 +0000 Message-ID: <87r0joq3kr.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -8.41 X-Spam-Score: -8.41 X-Migadu-Queue-Id: 4EC44327F6 X-Migadu-Scanner: mx10.migadu.com X-TUID: PZQDq6pRRf4H Leo Butler writes: > From 7d8e406bc4a92e2e2eab772b2671dcd72ca8c202 Mon Sep 17 00:00:00 2001 > From: Leo Butler > Date: Tue, 12 Dec 2023 12:32:41 -0600 > Subject: [PATCH] lisp/ob-C.el: add :compile-only header to compile to a named > target Thanks for the patch! > * lisp/ob-C.el (org-babel-C-execute): The new header argument, > `:compile-only', causes source and compiled binary files to be named > using the `:file' header argument. When `:compile-only' is set, > execution of source block ends at compilation. The naming of source > and binary filenames is factored out to `org-babel-C-src/bin-file'. What will happen if we have something like :results value or :results output instead of :results file link? > * lisp/ob-C.el (org-babel-C-src/bin-file): A new function that factors > out the setting of source and binary filenames. It also signals an > error if `:compile-only' is set, but `:file' is not. > * testing/examples/ob-C-test.org: Add three example that exercise the > `:compile-only' header argument, including one that causes an error. > * testing/lisp/test-ob-C.el: Add three tests of the `:compile-only' > header argument. New tests: ob-C/set-src+bin-file-name-{1,2,3}. You should also announce the new feature in ORG-NEWS and document it in WORG. > + (compile-only . (nil no t yes))) Why nil/t? No other header argument allow "nil" or "t". Just yes/no. > +(defun org-babel-C-src/bin-file (params src? compile-only?) > + "Return the src or bin filename to `org-babel-C-execute'. > + > +If `SRC?' is T, a file extension is added to the filename. By Just SRC?. You should only quote Elisp symbols and upcase the function arguments. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html Also, why upcase "T"? > +default, the filename is created by `org-babel-temp-file'. If > +`COMPILE-ONLY?' is T, the filename is taken from the `:file' I think quoting :file is not necessary. > +field in `PARAMS'; if that is NIL, an error occurs." No need to upcase NIL. Also, "if that is nil, throw an error" - this is more common style (saying what function does). > + (let ((f (cdr (assq :file params)))) Please avoid short variable names - they are harder to understand and search in code. > + (when (and compile-only? (null f)) > + (error "Error: When COMPILE-ONLY is T or YES, output FILE needs to be set")) t or "yes". Also, what does "output FILE" refer to? Upcasing implies function argument, but you are referring to :file header argument in PARAMS. > + (let* ((file (cond (compile-only? f) (src? "C-src-") (t "C-bin-"))) > + (ext (if src? (pcase org-babel-c-variant > + (`c ".c") (`cpp ".cpp") (`d ".d")) We usually split `cond' and `case' into multiple lines for readability. Otherwise, it is confusing, especially in `let' forms where one can confuse `cond' forms with `let' bindings. > + (unless compile-only? > + (let ((results > + (org-babel-eval > ... No return value at all? I'd expect file link to be returned, as we discussed in another thread. Also, see the above considerations about :results value/output. We might want return the compiler output for :results output. Or maybe even arrange `org-babel-eval-error-notify' to display compile-mode window when there are compilation warnings. > --- a/testing/examples/ob-C-test.org > +++ b/testing/examples/ob-C-test.org > @@ -174,3 +174,29 @@ std::cout << "\"line 1\"\n"; > std::cout << "\"line 2\"\n"; > std::cout << "\"line 3\"\n"; > #+end_src If you can, please avoid adding tests as Org files where possible. Instead, we prefer using `org-test-with-temp-text' or `org-test-with-temp-text-in-file' when the Org fragment for the test is not too long. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at