From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 6PyvECWcQ2R4ewAASxT56A (envelope-from ) for ; Sat, 22 Apr 2023 10:34:45 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QAa5DyWcQ2SgOgAAG6o9tA (envelope-from ) for ; Sat, 22 Apr 2023 10:34:45 +0200 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 AB2221A0A for ; Sat, 22 Apr 2023 10:34:44 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pq8gl-0008Qj-VG; Sat, 22 Apr 2023 04:33:48 -0400 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 1pq8gk-0008QV-5K for emacs-orgmode@gnu.org; Sat, 22 Apr 2023 04:33:46 -0400 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pq8gi-00036O-DT; Sat, 22 Apr 2023 04:33:45 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 0b712321 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 22 Apr 2023 08:33:41 +0000 (UTC) References: <388850760.3644614.1634354740816.ref@mail.yahoo.com> <388850760.3644614.1634354740816@mail.yahoo.com> <87k0h5gbad.fsf@gmail.com> <1410400175.3014347.1637221629433@mail.yahoo.com> <147485378.6546620.1638236479358@mail.yahoo.com> <87czmiqnmh.fsf@gmail.com> <115088871.6596146.1638252307206@mail.yahoo.com> <877d5sszc2.fsf@localhost> User-agent: mu4e 1.9.22; emacs 30.0.50 To: lin Sun Cc: Timothy , Bastien Guerry , emacs-orgmode@gnu.org Subject: Re: [PATCH] before emit an error message, try to load the babel language Date: Sat, 22 Apr 2023 16:25:29 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz 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_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: , Reply-to: Ruijie Yu From: Ruijie Yu via "General discussions about Org-mode." 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682152485; a=rsa-sha256; cv=none; b=C22S2UmSwmarJ0PqHuFOqCxFKwswOFE1ynK0Kp1I0cod0ixdHvj/drjhGV9M+cAzLRbQs7 X+o1aejrE0Z/YICMe77o+L3K25V7/sJEFbwoUxwo4wqHsr4qaNtuqsWzgOFEMawo/lBMZi Ggh7ywe5RoNreT1pZqdAFlEIXfJq9L3qDlSGqnVPpQVo61ksO183vtxSplavybYYraFTfA bmPB8BDOHZORTDrfhXxIyP/gyA4uBRdlNuYmjtRFKzBpuyjVGv25zezaMXm4482q6QP20C N0yoyjre4O39roW3r7XN/2js242WzVhSNblnxrejcb0rB40DUNTswGp5xJY3bw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682152485; h=from:from:sender:sender:reply-to: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; bh=+OEHihDbF5LSsWmwySPtJ41cJTM6TGLigCjB7LdHz5E=; b=YL/YxmqXxt0fg1WDKVHUUMvyA3reVGZCm3g2DZvXJOujxGtFt6TUWIc65wLKCt+rkCKFIN FE+wTNdQJwvnShQSE6P1q72O1jStE1eqfm8C0SEAQK/wnwsv/7tTPlkfN4hb3pAtR+WxKX HguxYW3c60wOJaO0zEoGBO8JbFHs/OoTh9QoCGDVCcYl6RqAzAxaXFakab01VmXsgwCjvW IlBIzhq/2NeMb9oCJWPPZL8cFiC3RvxdLT6eeVTKN22JvnBYFd1SH8xW8vMJE8WKxSMo3N 1iHxTrK8LhDNULFp0hfs+84aKQ90rb8l4F0Xc4q8/8L6v3AVJtN997ddAyaeMg== X-Migadu-Spam-Score: -3.51 X-Spam-Score: -3.51 X-Migadu-Queue-Id: AB2221A0A X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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" X-TUID: CM0TPWSGyvPE lin Sun writes: > Hi, > The function `org-babel-execute-src-block' will emit an error message > if the language is not loaded. > > Before the error message, the patch will give a try to load the > associated babel language. > > Why does the language exist in the `lang org-babel-load-languages' but > not be loaded? > Because the `org-babel-load-languages' are defined as a customer > variable with :set 'org-babel-do-load-languages, the ":set" function > can only be triggered with function `custom-set-variables`. > While setq/cl-pushnew `org-babel-load-languages' won't trigger the > `:set' function, then the error message will be displayed if I run the > code in the org file. > > Please help review that patch. Thanks. Regards > > [2. text/x-patch; 0001-lisp-ob-core.el-load-lang-in-org-babel-execute-src-b.patch]... I think this patch slightly modifies the logic of the error. --8<---------------cut here---------------start------------->8--- (unless (fboundp cmd) - (error "No org-babel-execute function for %s!" lang)) + (if (alist-get lang org-babel-load-languages) + (require (intern (concat "ob-" lang))) + (error "No org-babel-execute function for %s!" lang))) --8<---------------cut here---------------end--------------->8--- You are saying, that when (fboundp cmd) returns nil, and when (alist-get ...) returns non-nil, then perform the `require', and assume this function is now available. Instead of that, I think you should have some sort of conditional in the `unless' condition. Something like: --8<---------------cut here---------------start------------->8--- (unless (or (fboundp cmd) (ignore (and (alist-get lang org-babel-load-languages) (require (intern (concat "ob-" lang))))) (fboundp cmd)) (error "... %s" lang)) --8<---------------cut here---------------end--------------->8--- This preserves the logic of the message: when we cannot get "org-babel-execute" immediately, we then try to require the module and try again. Then, we check the function again and conclude that the org-babel-execute function is not found for this language. Thoughts? -- Best, RY [Please note that this mail might go to spam due to some misconfiguration in my mail server -- still investigating.]